Skip to content

Commit

Permalink
Add Open Desktop item in the end of tools list
Browse files Browse the repository at this point in the history
  • Loading branch information
mmorhun committed Aug 2, 2019
1 parent 4c2c225 commit ea16b03
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 2 deletions.
90 changes: 90 additions & 0 deletions resources/desktop.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 9 additions & 1 deletion src/che-theia-git-ui-tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import * as theia from '@theia/plugin';
import { GIT_TOOLS_CONFIGURATION } from './tools-config';
import { createToolsManager } from './tools-manager';
import { GitUiToolsTreeDataProvider, LAUNCH_GIT_UI_TOOL_COMMAND_ID } from './git-ui-tools-tree';
import { GitUiToolsTreeDataProvider, LAUNCH_GIT_UI_TOOL_COMMAND_ID, OPEN_GIT_TOOLS_DESKTOP_COMMAND_ID } from './git-ui-tools-tree';
import { getProjectRoot, PROJECTS_ROOT } from './git-utils';

const INITIALIZATION_FAILED_MESSAGE = 'Failed to initialize Git UI Tools plugin';
Expand Down Expand Up @@ -41,6 +41,14 @@ export async function start(context: theia.PluginContext) {
toolsManager.runTool(toolId, projectDir || PROJECTS_ROOT);
toolsManager.openDesktop();
}));
// Register open desktop handler
const GitUiToolsOpenDesktopCommand: theia.CommandDescription = {
id: OPEN_GIT_TOOLS_DESKTOP_COMMAND_ID,
label: 'Open git UI Tools desktop'
};
context.subscriptions.push(theia.commands.registerCommand(GitUiToolsOpenDesktopCommand, (...args: any[]) => {
toolsManager.openDesktop();
}));

// Clean up desktop on plugin start
toolsManager.closeAllWindows();
Expand Down
25 changes: 24 additions & 1 deletion src/git-ui-tools-tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,37 @@ import * as theia from '@theia/plugin';
import { ToolInformation } from './tools-manager';

export const LAUNCH_GIT_UI_TOOL_COMMAND_ID = 'che-theia-git-ui-tools-launch';
export const OPEN_GIT_TOOLS_DESKTOP_COMMAND_ID = 'che-theia-git-ui-tools-open-desktop';

const OPEN_DESKTOP_ITEM_ID = 'open-desktop';

export class GitUiToolsTreeDataProvider implements theia.TreeDataProvider<ToolInformation> {

constructor(
private toolsInfo: ToolInformation[]
) { }
) {
// Add open desktop item
toolsInfo.push({
id: OPEN_DESKTOP_ITEM_ID,
name: '',
command: ''
});
}

getTreeItem(element: ToolInformation): theia.TreeItem | PromiseLike<theia.TreeItem> {
if (element.id === OPEN_DESKTOP_ITEM_ID) {
return {
id: OPEN_DESKTOP_ITEM_ID,
label: 'Open desktop',
tooltip: 'Opens desktop with git tools in a new tab',
iconPath: 'resources/desktop.svg',
command: {
id: OPEN_GIT_TOOLS_DESKTOP_COMMAND_ID
},
collapsibleState: theia.TreeItemCollapsibleState.None
}
}

return {
id: element.id,
label: element.name,
Expand Down

0 comments on commit ea16b03

Please sign in to comment.