Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Run Che command in selected container if container doesn't specified in configuration #274

Closed
wants to merge 1 commit into from
Closed
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
23 changes: 21 additions & 2 deletions plugins/containers-plugin/src/containers-tree-data-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import * as theia from '@theia/plugin';
import { IContainer } from './containers-service';

const CHE_TASK_TYPE = 'che';

interface ITreeNodeItem {
id: string;
name: string;
Expand All @@ -19,7 +21,7 @@ interface ITreeNodeItem {
parentId?: string;
command?: {
id: string;
arguments?: string[]
arguments?: (string | Object)[]
},
isExpanded?: boolean;
}
Expand Down Expand Up @@ -106,7 +108,7 @@ export class ContainersTreeDataProvider implements theia.TreeDataProvider<ITreeN
name: commandName,
tooltip: 'execute the command',
iconPath: 'fa-cogs medium-yellow',
command: { id: 'task:run', arguments: ['che', commandName] }
command: { id: 'task:run', arguments: [CHE_TASK_TYPE, commandName, this.overrideContainerName(container.name)] }
Copy link
Contributor

Choose a reason for hiding this comment

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

hello, it couldn't be another field ? looks like we're now having complex types for command

Copy link
Contributor

Choose a reason for hiding this comment

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

I would not use dedicated method and constant.
Just inline

{
    type: 'che',
    target: {
        machineName: containerName
    }
}

});
});
}
Expand Down Expand Up @@ -226,6 +228,23 @@ export class ContainersTreeDataProvider implements theia.TreeDataProvider<ITreeN
return uniqueId;
}

/**
* Builds object which has one time amend of machineName field for already defined task.
* Is used for tasks which should be executed inside specific container this time,
* but they do not have a container specified in persistent configuration.
* Return value is a subset of CheTaskDefinition.
*
* @param containerName name of the container in which the task should be executed
*/
private overrideContainerName(containerName: string): object {
return {
type: CHE_TASK_TYPE,
target: {
machineName: containerName
}
};
}

dispose(): void {
this.onDidChangeTreeDataEmitter.dispose();
}
Expand Down