Skip to content

Commit 635eb5b

Browse files
authored
Show short title for notebook toolbar commands (#13586)
1 parent e99e42b commit 635eb5b

File tree

5 files changed

+14
-6
lines changed

5 files changed

+14
-6
lines changed

packages/core/src/common/command.ts

+4
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ export interface Command {
4141
* An icon class of this command.
4242
*/
4343
iconClass?: string;
44+
/**
45+
* A short title used for display in menus.
46+
*/
47+
shortTitle?: string;
4448
/**
4549
* A category of this command.
4650
*/

packages/notebook/src/browser/view/notebook-main-toolbar.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,17 @@ export class NotebookMainToolbar extends React.Component<NotebookMainToolbarProp
123123
if (!visibleCommand) {
124124
return undefined;
125125
}
126-
const title = (this.props.commandRegistry.getCommand(item.command ?? '') as NotebookCommand)?.tooltip ?? item.label;
126+
const command = this.props.commandRegistry.getCommand(item.command ?? '') as NotebookCommand | undefined;
127+
const label = command?.shortTitle ?? item.label;
128+
const title = command?.tooltip ?? item.label;
127129
return <div key={item.id} title={title} className={`theia-notebook-main-toolbar-item action-label${this.getAdditionalClasses(item)}`}
128130
onClick={() => {
129131
if (item.command && (!item.when || this.props.contextKeyService.match(item.when, this.props.editorNode))) {
130132
this.props.commandRegistry.executeCommand(item.command, this.props.notebookModel.uri);
131133
}
132134
}}>
133135
<span className={item.icon} />
134-
<span className='theia-notebook-main-toolbar-item-text'>{item.label}</span>
136+
<span className='theia-notebook-main-toolbar-item-text'>{label}</span>
135137
</div>;
136138
}
137139
return undefined;

packages/plugin-ext/src/common/plugin-protocol.ts

+2
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ export interface PluginPackageViewWelcome {
198198
export interface PluginPackageCommand {
199199
command: string;
200200
title: string;
201+
shortTitle?: string;
201202
original?: string;
202203
category?: string;
203204
icon?: string | { light: string; dark: string; };
@@ -858,6 +859,7 @@ export interface ViewWelcome {
858859
export interface PluginCommand {
859860
command: string;
860861
title: string;
862+
shortTitle?: string;
861863
originalTitle?: string;
862864
category?: string;
863865
iconUrl?: IconUrl;

packages/plugin-ext/src/hosted/node/scanners/scanner-theia.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -455,9 +455,9 @@ export class TheiaPluginScanner extends AbstractPluginScanner {
455455
return translation;
456456
}
457457

458-
protected readCommand({ command, title, original, category, icon, enablement }: PluginPackageCommand, pck: PluginPackage): PluginCommand {
458+
protected readCommand({ command, title, shortTitle, original, category, icon, enablement }: PluginPackageCommand, pck: PluginPackage): PluginCommand {
459459
const { themeIcon, iconUrl } = this.transformIconUrl(pck, icon) ?? {};
460-
return { command, title, originalTitle: original, category, iconUrl, themeIcon, enablement };
460+
return { command, title, shortTitle, originalTitle: original, category, iconUrl, themeIcon, enablement };
461461
}
462462

463463
protected transformIconUrl(plugin: PluginPackage, original?: IconUrl): { iconUrl?: IconUrl; themeIcon?: string } | undefined {

packages/plugin-ext/src/main/browser/plugin-contribution-handler.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ export class PluginContributionHandler {
463463
return Disposable.NULL;
464464
}
465465
const toDispose = new DisposableCollection();
466-
for (const { iconUrl, themeIcon, command, category, title, originalTitle, enablement } of contribution.commands) {
466+
for (const { iconUrl, themeIcon, command, category, shortTitle, title, originalTitle, enablement } of contribution.commands) {
467467
const reference = iconUrl && this.style.toIconClass(iconUrl);
468468
const icon = themeIcon && ThemeIcon.fromString(themeIcon);
469469
let iconClass;
@@ -473,7 +473,7 @@ export class PluginContributionHandler {
473473
} else if (icon) {
474474
iconClass = ThemeIcon.asClassName(icon);
475475
}
476-
toDispose.push(this.registerCommand({ id: command, category, label: title, originalLabel: originalTitle, iconClass }, enablement));
476+
toDispose.push(this.registerCommand({ id: command, category, shortTitle, label: title, originalLabel: originalTitle, iconClass }, enablement));
477477
}
478478
return toDispose;
479479
}

0 commit comments

Comments
 (0)