+
Skip to content

Allow clicking a warning, like 'Please select repo' #211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/common/BaseIoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import SelectRepo from 'command/SelectRepo';
import Spawn from 'common/Spawn';
import TryProcessAgain from 'command/TryProcessAgain';
import UncommittedFile from 'containerization/UncommittedFile';
import WarningCommandFactory from 'job/WarningCommandFactory';
import WarningFactory from 'job/WarningFactory';
import Workspace from 'common/Workspace';

Expand Down Expand Up @@ -106,6 +107,7 @@ export default class BaseIoc {
this.container.bind(Spawn).toSelf();
this.container.bind(TryProcessAgain).toSelf();
this.container.bind(UncommittedFile).toSelf();
this.container.bind(WarningCommandFactory).toSelf();
this.container.bind(WarningFactory).toSelf();
this.container.bind(Workspace).toSelf();

Expand Down
14 changes: 9 additions & 5 deletions src/config/ConfigFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import type vscode from 'vscode';
import Types from 'common/Types';
import AllConfigFiles from './AllConfigFiles';
import EditorGateway from 'gateway/EditorGateway';
import { CREATE_CONFIG_FILE_COMMAND, SELECTED_CONFIG_PATH } from 'constant';
import {
CREATE_CONFIG_FILE_COMMAND,
SELECTED_CONFIG_PATH,
SELECT_REPO_COMMAND,
} from 'constant';

@injectable()
export default class ConfigFile {
Expand Down Expand Up @@ -56,17 +60,17 @@ export default class ConfigFile {
return allConfigFilePaths[0].fsPath;
}

const chooseRepoText = 'Choose repo';
const selectRepoText = 'Select repo';
this.editorGateway.editor.window
.showInformationMessage(
'Please select the repo to run Local CI on',
{ detail: 'There is no repo selected to run Local CI on' },
chooseRepoText
selectRepoText
)
.then((clicked) => {
if (clicked === chooseRepoText) {
if (clicked === selectRepoText) {
this.editorGateway.editor.commands.executeCommand(
'localCiJobs.selectRepo'
SELECT_REPO_COMMAND
);
}
});
Expand Down
1 change: 1 addition & 0 deletions src/constant/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const DYNAMIC_CONFIG_PATH_IN_CONTAINER = path.join(
export const HOST_TMP_DIRECTORY = '/tmp/local-ci';
export const RUN_JOB_COMMAND = 'local-ci.job.run';
export const CREATE_CONFIG_FILE_COMMAND = 'local-ci.create.config';
export const SELECT_REPO_COMMAND = 'localCiJobs.selectRepo';
export const SHOW_LOG_FILE_COMMAND = 'local-ci.show.log-file';
export const LOG_FILE_SCHEME = 'local-ci-log';
export const CONTINUE_PIPELINE_STEP_NAME = 'Continue the pipeline';
Expand Down
12 changes: 10 additions & 2 deletions src/job/Children.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import CommandFactory from './ComandFactory';
import JobFactory from './JobFactory';
import JobTreeItem from './JobTreeItem';
import WarningFactory from './WarningFactory';
import WarningCommandFactory from './WarningCommandFactory';
import type EditorGateway from 'gateway/EditorGateway';
import {
COMPLAIN_COMMAND,
Expand All @@ -16,6 +17,7 @@ import {
GET_LICENSE_COMMAND,
JOB_TREE_VIEW_ID,
PROCESS_TRY_AGAIN_COMMAND,
SELECT_REPO_COMMAND,
} from 'constant';

type Logs = Record<string, string[]>;
Expand All @@ -35,6 +37,9 @@ export default class Children {
@inject(LogFactory)
logFactory!: LogFactory;

@inject(WarningCommandFactory)
warningCommandFactory!: WarningCommandFactory;

@inject(WarningFactory)
warningFactory!: WarningFactory;

Expand Down Expand Up @@ -149,8 +154,11 @@ export default class Children {
];
case JobError.NoConfigFilePathSelected:
return [
this.warningFactory.create('Please select repo'),
this.commandFactory.create('Select repo', 'localCiJobs.selectRepo'),
this.warningCommandFactory.create(
'Please select repo',
SELECT_REPO_COMMAND
),
this.commandFactory.create('Select repo', SELECT_REPO_COMMAND),
this.commandFactory.create('Complain to me', COMPLAIN_COMMAND),
];
case JobError.ProcessFile:
Expand Down
20 changes: 20 additions & 0 deletions src/job/WarningCommandFactory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { inject, injectable } from 'inversify';
import type vscode from 'vscode';
import WarningFactory from './WarningFactory';

@injectable()
export default class WarningCommandFactory {
@inject(WarningFactory)
warningFactory!: WarningFactory;

create(label: string, command: string): vscode.TreeItem {
return {
...this.warningFactory.create(label),
command: {
command,
title: label,
tooltip: label,
},
};
}
}
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载