Skip to content

Commit

Permalink
Allow updating user-level task
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Mäder <tmader@redhat.com>
  • Loading branch information
tsmaeder committed Jun 3, 2020
1 parent 3ae0586 commit 598d251
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

Breaking Changes:

- [task] Widened the scope of some methods in TaskManager and TaskConfigurations from string to TaskConfigurationScope. This is only breaking for extenders, not callers. [#7928](https://github.com/eclipse-theia/theia/pull/7928)

## v1.2.0

- [application-manager] added ability for clients to add `windowOptions` using an IPC-Event [#7803](https://github.com/eclipse-theia/theia/pull/7803)
Expand Down
10 changes: 5 additions & 5 deletions packages/task/src/browser/task-configuration-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,17 @@ export class TaskConfigurationManager {
}
}

async addTaskConfiguration(sourceFolderUri: string, taskConfig: TaskCustomization): Promise<boolean> {
const taskPrefModel = this.getModel(sourceFolderUri);
async addTaskConfiguration(scope: TaskConfigurationScope, taskConfig: TaskCustomization): Promise<boolean> {
const taskPrefModel = this.getModel(scope);
if (taskPrefModel) {
const configurations = taskPrefModel.configurations;
return this.setTaskConfigurations(sourceFolderUri, [...configurations, taskConfig]);
return this.setTaskConfigurations(scope, [...configurations, taskConfig]);
}
return false;
}

async setTaskConfigurations(sourceFolderUri: string, taskConfigs: (TaskCustomization | TaskConfiguration)[]): Promise<boolean> {
const taskPrefModel = this.getModel(sourceFolderUri);
async setTaskConfigurations(scope: TaskConfigurationScope, taskConfigs: (TaskCustomization | TaskConfiguration)[]): Promise<boolean> {
const taskPrefModel = this.getModel(scope);
if (taskPrefModel) {
return taskPrefModel.setConfigurations(taskConfigs);
}
Expand Down
9 changes: 2 additions & 7 deletions packages/task/src/browser/task-configurations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,10 +370,10 @@ export class TaskConfigurations implements Disposable {
}

/** Writes the task to a config file. Creates a config file if this one does not exist */
saveTask(sourceFolderUri: string, task: TaskConfiguration): Promise<boolean> {
saveTask(scope: TaskConfigurationScope, task: TaskConfiguration): Promise<boolean> {
const { _source, $ident, ...preparedTask } = task;
const customizedTaskTemplate = this.getTaskCustomizationTemplate(task) || preparedTask;
return this.taskConfigurationManager.addTaskConfiguration(sourceFolderUri, customizedTaskTemplate);
return this.taskConfigurationManager.addTaskConfiguration(scope, customizedTaskTemplate);
}

/**
Expand Down Expand Up @@ -460,11 +460,6 @@ export class TaskConfigurations implements Disposable {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
async updateTaskConfig(task: TaskConfiguration, update: { [name: string]: any }): Promise<void> {
const scope = task._scope;
if (typeof scope !== 'string') {
// ToDo: configure workspace and user-level scope tasks
console.error('Global task cannot be customized');
return;
}
const configuredAndCustomizedTasks = await this.getTasks();
if (configuredAndCustomizedTasks.some(t => this.taskDefinitionRegistry.compareTasks(t, task))) { // task is already in `tasks.json`
const jsonTasks = this.taskConfigurationManager.getTasks(scope);
Expand Down

0 comments on commit 598d251

Please sign in to comment.