From 6c27d24d241ce88b1e30192f076fcd5c067ca784 Mon Sep 17 00:00:00 2001 From: vince-fugnitto Date: Tue, 12 Nov 2019 16:08:20 -0500 Subject: [PATCH] Prompt users to configure tasks 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 --- packages/task/src/browser/quick-open-task.ts | 32 +++++++++++++++----- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/packages/task/src/browser/quick-open-task.ts b/packages/task/src/browser/quick-open-task.ts index ee17b332d8018..8a4949d4e49e4 100644 --- a/packages/task/src/browser/quick-open-task.ts +++ b/packages/task/src/browser/quick-open-task.ts @@ -111,17 +111,22 @@ export class QuickOpenTask implements QuickOpenModel, QuickOpenHandler { ); this.actionProvider = this.items.length ? this.taskActionProvider : undefined; + } + async open(): Promise { + 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 { - await this.init(); this.quickOpenService.open(this, { placeholder: 'Select the task to run', fuzzyMatchLabel: true, @@ -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; @@ -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, {