Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show short title for notebook toolbar commands #13586

Merged
merged 1 commit into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions packages/core/src/common/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ export interface Command {
* An icon class of this command.
*/
iconClass?: string;
/**
* A short title used for display in menus.
*/
shortTitle?: string;
/**
* A category of this command.
*/
Expand Down
6 changes: 4 additions & 2 deletions packages/notebook/src/browser/view/notebook-main-toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,17 @@ export class NotebookMainToolbar extends React.Component<NotebookMainToolbarProp
if (!visibleCommand) {
return undefined;
}
const title = (this.props.commandRegistry.getCommand(item.command ?? '') as NotebookCommand)?.tooltip ?? item.label;
const command = this.props.commandRegistry.getCommand(item.command ?? '') as NotebookCommand | undefined;
const label = command?.shortTitle ?? item.label;
const title = command?.tooltip ?? item.label;
return <div key={item.id} title={title} className={`theia-notebook-main-toolbar-item action-label${this.getAdditionalClasses(item)}`}
onClick={() => {
if (item.command && (!item.when || this.props.contextKeyService.match(item.when, this.props.editorNode))) {
this.props.commandRegistry.executeCommand(item.command, this.props.notebookModel);
}
}}>
<span className={item.icon} />
<span className='theia-notebook-main-toolbar-item-text'>{item.label}</span>
<span className='theia-notebook-main-toolbar-item-text'>{label}</span>
</div>;
}
return undefined;
Expand Down
2 changes: 2 additions & 0 deletions packages/plugin-ext/src/common/plugin-protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ export interface PluginPackageViewWelcome {
export interface PluginPackageCommand {
command: string;
title: string;
shortTitle?: string;
original?: string;
category?: string;
icon?: string | { light: string; dark: string; };
Expand Down Expand Up @@ -858,6 +859,7 @@ export interface ViewWelcome {
export interface PluginCommand {
command: string;
title: string;
shortTitle?: string;
originalTitle?: string;
category?: string;
iconUrl?: IconUrl;
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-ext/src/hosted/node/scanners/scanner-theia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,9 +455,9 @@ export class TheiaPluginScanner extends AbstractPluginScanner {
return translation;
}

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

protected transformIconUrl(plugin: PluginPackage, original?: IconUrl): { iconUrl?: IconUrl; themeIcon?: string } | undefined {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ export class PluginContributionHandler {
return Disposable.NULL;
}
const toDispose = new DisposableCollection();
for (const { iconUrl, themeIcon, command, category, title, originalTitle, enablement } of contribution.commands) {
for (const { iconUrl, themeIcon, command, category, shortTitle, title, originalTitle, enablement } of contribution.commands) {
const reference = iconUrl && this.style.toIconClass(iconUrl);
const icon = themeIcon && ThemeIcon.fromString(themeIcon);
let iconClass;
Expand All @@ -473,7 +473,7 @@ export class PluginContributionHandler {
} else if (icon) {
iconClass = ThemeIcon.asClassName(icon);
}
toDispose.push(this.registerCommand({ id: command, category, label: title, originalLabel: originalTitle, iconClass }, enablement));
toDispose.push(this.registerCommand({ id: command, category, shortTitle, label: title, originalLabel: originalTitle, iconClass }, enablement));
}
return toDispose;
}
Expand Down
Loading