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

Add ability to configure task #4714

Merged
merged 1 commit into from
Apr 3, 2019
Merged

Add ability to configure task #4714

merged 1 commit into from
Apr 3, 2019

Conversation

RomanNikitenko
Copy link
Contributor

@RomanNikitenko RomanNikitenko commented Mar 26, 2019

Add ability to configure Task:

  • provides 'Configure task' action for each 'TaskRunQuickOpenItem'
  • adds 'Configure Tasks' menu action

'Configure Tasks' menu action displays only provided tasks.
'Run Task' action displays both: configured and filtered provided tasks. Provided tasks are filtered by label: for example, when we have configured and provided tasks with the same label - only configured task is displayed (provided task is still available from 'Configure Tasks' menu)

'Configure task' action allows to copy task configuration to tasks.json file and provides ability to edit this one. Config file will be created if this one does not exist.

Please see a short demo: https://youtu.be/FKkSnWJy2ac

Related issue: eclipse-che/che#12712

Signed-off-by: Roman Nikitenko rnikiten@redhat.com

@@ -743,8 +743,125 @@ declare module monaco.quickOpen {
setShowBorder(showBorder: boolean): void;
getEntry(): QuickOpenEntry | undefined;
}

export interface INextIterator<T> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please expose only what is used and remove everything what is not used in this PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

next(): T | null;
}

export interface ITree {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we avoid exposing it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

@RomanNikitenko
Copy link
Contributor Author

@akosyakov I removed all extra objects and updated the PR. Could you review?

@akosyakov
Copy link
Member

@RomanNikitenko monaco code looks good, thank you 👍

will test in the afternoon, @elaihau could you test as well when you have a chance, you know more about tasks

);

this.actionProvider = this.items.length ? this.taskActionProvider : this.noActionProvider;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need NoActionProvider? How about assigning undefined instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used NoActionProvider to avoid potential NPE, but I reviewed code - we have check, so I removed this entry.

@akosyakov
Copy link
Member

akosyakov commented Mar 27, 2019

@RomanNikitenko Do I understand correctly that it's basically cover this section of VS Code: https://code.visualstudio.com/Docs/editor/tasks#_customizing-autodetected-tasks

So I can test it against grunt built-in extension for example?

@akosyakov
Copy link
Member

akosyakov commented Mar 27, 2019

It works nicely for Run Task, but missing for task prefix in the quick palette. It seems to be the same widget in VS Code in both cases. Could we do the same?

  • VS Code:

Screen Shot 2019-03-27 at 14 32 55

  • Theia:

Screen Shot 2019-03-27 at 14 40 59

Also icon is different, is there a way to reuse from VS Code? You don't need to wait for CQ to be approved, but have to file one if you copy an icon. It would be approved eventually, everything in VS Code is under MIT.

@akosyakov
Copy link
Member

akosyakov commented Mar 27, 2019

There are also visual differences to VS Code. It would be nice to align, but separately. cc @elaihau

  • VS Code:

Screen Shot 2019-03-27 at 14 32 38

  • Theia:

Screen Shot 2019-03-27 at 14 32 44

  • placeholder is different
  • recently used tasks is missing
  • configured -> configured tasks
  • provided -> detected tasks
  • grouping of configured and detected tasks to separate them
  • there is not point to show a workspace for a task description if there is only one root
  • if a workspace root is shown it should be aligned for configured and detected tasks

import { QuickOpenBaseAction, QuickOpenActionProvider, QuickOpenAction } from '@theia/core/lib/browser/quick-open/quick-open-action';

@injectable()
export class ConfigureTaskAction extends QuickOpenBaseAction {
Copy link
Member

@akosyakov akosyakov Mar 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please keep file named after main class, i.e. task-action-provider.ts, it is a part of naming conventions for Theia to simplify searching classes by file names

please have a look at other files and rename where it is appropriate

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

task-action.ts ---> task-action-provider.ts
quick-open-action.ts ---> quick-open-action-provider.ts

@elaihau
Copy link
Contributor

elaihau commented Mar 27, 2019

It works nicely for Run Task, but missing for task prefix in the quick palette. It seems to be the same widget in VS Code in both cases. Could we do the same?

Yes we can. Sorry I am in the team training today, will test once it is done.

protected actionRadio: boolean;

constructor(
@unmanaged() id: string,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

enabled: boolean;
checked: boolean;
radio: boolean;
// tslint:disable-next-line:no-any
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

run(event?: { item?: QuickOpenItem }): PromiseLike<any>; would it be correct type?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: I added MonacoQuickOpenAction to provide ability to use QuickOpenItem here

}

export interface QuickOpenActionProvider {
// tslint:disable-next-line:no-any
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hasActions(item: QuickOpenItem): boolean;
getActions(item: QuickOpenItem): Promise<QuickOpenAction[]>;

Would it be correct item type?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


import { injectable, inject } from 'inversify';
import { TaskService } from './task-service';
import { QuickOpenBaseAction, QuickOpenActionProvider, QuickOpenAction } from '@theia/core/lib/browser/quick-open/quick-open-action';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to reexport them in @theia/core/lib/browser/quick-open.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

super('configure:task', '', 'fa fa-cog');
}

// tslint:disable-next-line:no-any
Copy link
Member

@akosyakov akosyakov Mar 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

async run(event?: { item: QuickOpenItem }): Promise<void> {
        if (event && event.item instanceof TaskRunQuickOpenItem) {

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

registry.registerCommand(
TaskCommands.TASK_CONFIGURE,
{
isEnabled: () => true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bwt isEnabled is true by default as well as isVisible

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

@@ -56,7 +58,11 @@ export class TaskConfigurations implements Disposable {

constructor(
@inject(FileSystemWatcher) protected readonly watcherServer: FileSystemWatcher,
@inject(FileSystem) protected readonly fileSystem: FileSystem
@inject(FileSystem) protected readonly fileSystem: FileSystem,
@inject(WorkspaceService) protected readonly workspaceService: WorkspaceService,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add new dependenices always vis property injection, otherwise it is a breaking change, see inversify conventions : https://github.com/theia-ide/theia/wiki/Coding-Guidelines#property-injection

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thank you!

@elaihau
Copy link
Contributor

elaihau commented Mar 27, 2019

one thing that i found was, the "configure task" button put everything in the task object into task.json, regardless of the place that the task comes from.

this is what vscode does for configuring detected tasks:

Peek 2019-03-27 11-26

And this is theia (same workspace & same task):

Peek 2019-03-27 11-28

in spite of the difference / inconsistency, i would say we could probably leave it to the future PRs to resolve, as we are not supporting the problem matchers, problem patterns, or task definitions at the moment. we will need to pass more information through plugin-ext, and i am currently working on it.

@akosyakov
Copy link
Member

@elaihau ok, would be good to have follow-up issues for #4714 (comment), #4714 (comment) and #4714 (comment) that all these things get fixed eventually

@RomanNikitenko
Copy link
Contributor Author

@akosyakov @elaihau thank you for your comments, I will fix and update the PR today.

@RomanNikitenko
Copy link
Contributor Author

RomanNikitenko commented Apr 1, 2019

There are also visual differences to VS Code. It would be nice to align, but separately. cc @elaihau

  • VS Code:
Screen Shot 2019-03-27 at 14 32 38
  • Theia:
Screen Shot 2019-03-27 at 14 32 44
  • placeholder is different
  • recently used tasks is missing
  • configured -> configured tasks
  • provided -> detected tasks
  • grouping of configured and detected tasks to separate them
  • there is not point to show a workspace for a task description if there is only one root
  • if a workspace root is shown it should be aligned for configured and detected tasks

Changes:

  • placeholder ---> Select the task to run
  • configured -> configured tasks
  • provided -> detected tasks
  • VS Code icon is used for dark and light themes

please see the short video https://youtu.be/Hhlls33wqmQ

btw, where I should create CQ for VS code icon? Do you have some template/sample?
thank you!

CHANGELOG.md Outdated
@@ -5,6 +5,7 @@
- [cpp] added new clang-tidy and clang-tidy-checks preferences to lint cpp program when clangd v9+ is used.
- [plugin] `workspace.openTextDocument` API now respects the contributed `FileSystemProviders`
- [search-in-workspace] added a new preference `search.lineNumbers` to control whether to show line numbers for search results.
- [task] added support to configure tasks
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please move to 0.6.0


getDescription(): string {
if (this.task._scope) {
return new URI(this.task._scope).path.toString();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use LabelProvider.getLongName to get human readable representation of a URI relative the workspace

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


const resource = await this.resourceProvider(new URI(configFileUri));
if (resource.saveContents) {
await resource.saveContents(JSON.stringify({ tasks: preparedTasks }, undefined, 4));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should try to preserve formatting, like here: https://github.com/theia-ide/theia/blob/3886397750b34e6cb65976578c4eb848639adfae/packages/workspace/src/browser/workspace-service.ts#L363-L364

You can use Resource.save and provide delta as well as full context. It knows when apply what.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just tested, changing tasks.json and then configuring a new task via Run Task breaks user formatting

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Member

@akosyakov akosyakov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it works well, except breaking formatting #4714 (comment)

Please take case about it and merge. I would open an issue for remaining UI improvements.

@elaihau is it fine from your side?

@akosyakov
Copy link
Member

Follow-up issues: #4768, #4769 and #4770

Copy link
Contributor

@elaihau elaihau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me, thank you !

@l0rd l0rd mentioned this pull request Apr 2, 2019
@RomanNikitenko RomanNikitenko force-pushed the configureTask branch 2 times, most recently from 2d4537e to 6ee2014 Compare April 2, 2019 14:17
Signed-off-by: Roman Nikitenko <rnikiten@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants