From c0c33b39587ae234fa89212eb01d6a5436077b38 Mon Sep 17 00:00:00 2001 From: Akos Kitta Date: Thu, 9 Mar 2023 12:52:10 +0100 Subject: [PATCH] fix: render inline signature Signed-off-by: Akos Kitta --- .../cloud-sketchbook-tree-widget.tsx | 2 +- .../sketchbook/sketchbook-tree-widget.tsx | 19 ++++++++----------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/arduino-ide-extension/src/browser/widgets/cloud-sketchbook/cloud-sketchbook-tree-widget.tsx b/arduino-ide-extension/src/browser/widgets/cloud-sketchbook/cloud-sketchbook-tree-widget.tsx index d4dbc0872..8877d2381 100644 --- a/arduino-ide-extension/src/browser/widgets/cloud-sketchbook/cloud-sketchbook-tree-widget.tsx +++ b/arduino-ide-extension/src/browser/widgets/cloud-sketchbook/cloud-sketchbook-tree-widget.tsx @@ -121,7 +121,7 @@ export class CloudSketchbookTreeWidget extends SketchbookTreeWidget { protected override renderInlineCommands(node: any): React.ReactNode { if (CloudSketchbookTree.CloudSketchDirNode.is(node) && node.commands) { return Array.from(new Set(node.commands)).map((command) => - this.renderInlineCommand(command.id, node, { + this.renderInlineCommand(command, node, { username: this.authenticationService.session?.account?.label, }) ); diff --git a/arduino-ide-extension/src/browser/widgets/sketchbook/sketchbook-tree-widget.tsx b/arduino-ide-extension/src/browser/widgets/sketchbook/sketchbook-tree-widget.tsx index 3b3e3ab93..5b709a30e 100644 --- a/arduino-ide-extension/src/browser/widgets/sketchbook/sketchbook-tree-widget.tsx +++ b/arduino-ide-extension/src/browser/widgets/sketchbook/sketchbook-tree-widget.tsx @@ -5,7 +5,7 @@ import { postConstruct, } from '@theia/core/shared/inversify'; import { TreeNode } from '@theia/core/lib/browser/tree/tree'; -import { CommandRegistry } from '@theia/core/lib/common/command'; +import { Command, CommandRegistry } from '@theia/core/lib/common/command'; import { NodeProps, TreeProps, @@ -132,25 +132,22 @@ export class SketchbookTreeWidget extends FileTreeWidget { protected renderInlineCommands(node: TreeNode): React.ReactNode { if (SketchbookTree.SketchDirNode.is(node) && node.commands) { return Array.from(new Set(node.commands)).map((command) => - this.renderInlineCommand( - Array.isArray(command) - ? command - : typeof command === 'string' - ? command - : command.id, - node - ) + this.renderInlineCommand(command, node) ); } return undefined; } protected renderInlineCommand( - command: string | [command: string, label: string], + command: Command | string | [command: string, label: string], node: SketchbookTree.SketchDirNode, options?: any ): React.ReactNode { - const commandId = Array.isArray(command) ? command[0] : command; + const commandId = Command.is(command) + ? command.id + : Array.isArray(command) + ? command[0] + : command; const resolvedCommand = this.commandRegistry.getCommand(commandId); const icon = resolvedCommand?.iconClass; const args = { model: this.model, node: node, ...options };