|
5 | 5 | postConstruct,
|
6 | 6 | } from '@theia/core/shared/inversify';
|
7 | 7 | import { TreeNode } from '@theia/core/lib/browser/tree/tree';
|
8 |
| -import { CommandRegistry } from '@theia/core/lib/common/command'; |
| 8 | +import { Command, CommandRegistry } from '@theia/core/lib/common/command'; |
9 | 9 | import {
|
10 | 10 | NodeProps,
|
11 | 11 | TreeProps,
|
@@ -132,25 +132,22 @@ export class SketchbookTreeWidget extends FileTreeWidget {
|
132 | 132 | protected renderInlineCommands(node: TreeNode): React.ReactNode {
|
133 | 133 | if (SketchbookTree.SketchDirNode.is(node) && node.commands) {
|
134 | 134 | return Array.from(new Set(node.commands)).map((command) =>
|
135 |
| - this.renderInlineCommand( |
136 |
| - Array.isArray(command) |
137 |
| - ? command |
138 |
| - : typeof command === 'string' |
139 |
| - ? command |
140 |
| - : command.id, |
141 |
| - node |
142 |
| - ) |
| 135 | + this.renderInlineCommand(command, node) |
143 | 136 | );
|
144 | 137 | }
|
145 | 138 | return undefined;
|
146 | 139 | }
|
147 | 140 |
|
148 | 141 | protected renderInlineCommand(
|
149 |
| - command: string | [command: string, label: string], |
| 142 | + command: Command | string | [command: string, label: string], |
150 | 143 | node: SketchbookTree.SketchDirNode,
|
151 | 144 | options?: any
|
152 | 145 | ): React.ReactNode {
|
153 |
| - const commandId = Array.isArray(command) ? command[0] : command; |
| 146 | + const commandId = Command.is(command) |
| 147 | + ? command.id |
| 148 | + : Array.isArray(command) |
| 149 | + ? command[0] |
| 150 | + : command; |
154 | 151 | const resolvedCommand = this.commandRegistry.getCommand(commandId);
|
155 | 152 | const icon = resolvedCommand?.iconClass;
|
156 | 153 | const args = { model: this.model, node: node, ...options };
|
|
0 commit comments