Skip to content

Commit

Permalink
Prompt users to configure tasks
Browse files Browse the repository at this point in the history
Fixes #6525
Fixes #1017

- adjust the `run task` to display an item which prompts users to configure tasks when
no tasks are currently available.
- adjusts the `run build task` to display an item which prompts users to configure
tasks when no tasks are currently available.
- adjusts the `run test task` to display an item which prompts users to configure
tasks when no tasks are currently available.

Signed-off-by: vince-fugnitto <[email protected]>
  • Loading branch information
vince-fugnitto committed Nov 13, 2019
1 parent 83c5913 commit 27cba60
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions packages/task/src/browser/quick-open-task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,22 @@ export class QuickOpenTask implements QuickOpenModel, QuickOpenHandler {
);

this.actionProvider = this.items.length ? this.taskActionProvider : undefined;
}

async open(): Promise<void> {
await this.init();
if (!this.items.length) {
this.items.push(new QuickOpenItem({
label: 'No tasks found',
run: (mode: QuickOpenMode): boolean => false
label: 'No task to run found. Configure Tasks...',
run: (mode: QuickOpenMode): boolean => {
if (mode !== QuickOpenMode.OPEN) {
return false;
}
this.configure();
return true;
}
}));
}
}

async open(): Promise<void> {
await this.init();
this.quickOpenService.open(this, {
placeholder: 'Select the task to run',
fuzzyMatchLabel: true,
Expand Down Expand Up @@ -290,7 +295,7 @@ export class QuickOpenTask implements QuickOpenModel, QuickOpenHandler {

} else { // no build / test tasks, display an action item to configure the build / test task
this.items = [new QuickOpenItem({
label: `No ${buildOrTestType} task to run found. Configure ${buildOrTestType} task...`,
label: `No ${buildOrTestType} task to run found. Configure ${buildOrTestType.charAt(0).toUpperCase() + buildOrTestType.slice(1)} Task...`,
run: (mode: QuickOpenMode): boolean => {
if (mode !== QuickOpenMode.OPEN) {
return false;
Expand Down Expand Up @@ -322,6 +327,19 @@ export class QuickOpenTask implements QuickOpenModel, QuickOpenHandler {
}
})];
}
} else { // no tasks are currently present, prompt users if they'd like to configure a task.
this.items = [
new QuickOpenItem({
label: `No ${buildOrTestType} task to run found. Configure ${buildOrTestType.charAt(0).toUpperCase() + buildOrTestType.slice(1)} Task...`,
run: (mode: QuickOpenMode): boolean => {
if (mode !== QuickOpenMode.OPEN) {
return false;
}
this.configure();
return true;
}
})
];
}

this.quickOpenService.open(this, {
Expand Down

0 comments on commit 27cba60

Please sign in to comment.