Skip to content

Commit

Permalink
Align tasks quick-open
Browse files Browse the repository at this point in the history
Fixes #4770

- aligned the `tasks` quick-open to display borders between categories (recently opened, configured, and provided tasks).
- aligned the `tasks` quick-open to only display a description (uri) when running in multi-root.
- fixed issue regarding right spacing in the quick-open which did not display the border correctly nor the action providers.

Signed-off-by: Vincent Fugnitto <vincent.fugnitto@ericsson.com>
  • Loading branch information
vince-fugnitto committed Apr 15, 2019
1 parent a4a71ca commit c561d60
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 11 deletions.
4 changes: 0 additions & 4 deletions packages/monaco/src/browser/style/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@
margin-right: 0px;
}

.monaco-tree-row {
padding-right: 11px;
}

.quick-open-entry .quick-open-row .monaco-icon-label .monaco-icon-label-description-container .monaco-highlighted-label .highlight {
color: var(--theia-accent-color1);
}
Expand Down
44 changes: 37 additions & 7 deletions packages/task/src/browser/quick-open-task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
import { inject, injectable } from 'inversify';
import {
QuickOpenService, QuickOpenModel, QuickOpenItem,
QuickOpenGroupItem, QuickOpenMode, QuickOpenHandler, QuickOpenOptions, QuickOpenActionProvider
QuickOpenGroupItem, QuickOpenMode, QuickOpenHandler, QuickOpenOptions, QuickOpenActionProvider, QuickOpenGroupItemOptions
} from '@theia/core/lib/browser/quick-open/';
import { TaskService } from './task-service';
import { ContributedTaskConfiguration, TaskInfo, TaskConfiguration } from '../common/task-protocol';
import { TaskConfigurations } from './task-configurations';
import URI from '@theia/core/lib/common/uri';
import { TaskActionProvider } from './task-action-provider';
import { LabelProvider } from '@theia/core/lib/browser';
import { WorkspaceService } from '@theia/workspace/lib/browser';

@injectable()
export class QuickOpenTask implements QuickOpenModel, QuickOpenHandler {
Expand All @@ -48,6 +49,9 @@ export class QuickOpenTask implements QuickOpenModel, QuickOpenHandler {
@inject(LabelProvider)
protected readonly labelProvider: LabelProvider;

@inject(WorkspaceService)
protected readonly workspaceService: WorkspaceService;

/**
* @deprecated To be removed in 0.5.0
*/
Expand All @@ -61,11 +65,33 @@ export class QuickOpenTask implements QuickOpenModel, QuickOpenHandler {
const providedTasks = await this.taskService.getProvidedTasks();

const { filteredRecentTasks, filteredConfiguredTasks, filteredProvidedTasks } = this.getFilteredTasks(recentTasks, configuredTasks, providedTasks);
const stat = await this.workspaceService.workspace;
const isMulti = stat ? !stat.isDirectory : false;
this.items = [];
this.items.push(
...filteredRecentTasks.map((t, ind) => new TaskRunQuickOpenItem(t, this.taskService, ind === 0 ? 'recently used tasks' : undefined)),
...filteredConfiguredTasks.map((t, ind) => new TaskRunQuickOpenItem(t, this.taskService, ind === 0 ? 'configured tasks' : undefined)),
...filteredProvidedTasks.map((t, ind) => new TaskRunQuickOpenItem(t, this.taskService, ind === 0 ? 'detected tasks' : undefined))
...filteredRecentTasks.map((task, index) =>
new TaskRunQuickOpenItem(task, this.taskService, isMulti, {
groupLabel: index === 0 ? 'recently used tasks' : undefined,
showBorder: false
})),
...filteredConfiguredTasks.map((task, index) =>
new TaskRunQuickOpenItem(task, this.taskService, isMulti, {
groupLabel: index === 0 ? 'configured tasks' : undefined,
showBorder: (
filteredRecentTasks.length <= 0
? false
: index === 0 ? true : false
)
})),
...filteredProvidedTasks.map((task, index) =>
new TaskRunQuickOpenItem(task, this.taskService, isMulti, {
groupLabel: index === 0 ? 'detected tasks' : undefined,
showBorder: (
filteredRecentTasks.length <= 0 && filteredConfiguredTasks.length <= 0
? false
: index === 0 ? true : false
)
}))
);

this.actionProvider = this.items.length ? this.taskActionProvider : undefined;
Expand Down Expand Up @@ -198,9 +224,10 @@ export class TaskRunQuickOpenItem extends QuickOpenGroupItem {
constructor(
protected readonly task: TaskConfiguration,
protected taskService: TaskService,
protected readonly groupLabel: string | undefined
protected isMulti: boolean,
protected readonly options: QuickOpenGroupItemOptions,
) {
super();
super(options);
}

getTask(): TaskConfiguration {
Expand All @@ -215,10 +242,13 @@ export class TaskRunQuickOpenItem extends QuickOpenGroupItem {
}

getGroupLabel(): string {
return this.groupLabel || '';
return this.options.groupLabel || '';
}

getDescription(): string {
if (!this.isMulti) {
return '';
}
if (ContributedTaskConfiguration.is(this.task)) {
if (this.task._scope) {
return new URI(this.task._scope).path.toString();
Expand Down

0 comments on commit c561d60

Please sign in to comment.