Skip to content
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

[tasks] prompt users to configure tasks #6539

Merged
merged 1 commit into from
Nov 13, 2019
Merged
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
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