Skip to content

Commit d7d110c

Browse files
andrii-ijtpio
andauthored
Change "Interface" menu to "Open in...", shorten names of menu items inside (#6847)
* rename commandLabel * attemp to keep longer name in command palette * Remove trying to keep longer name for command palette * Attempt to register 2 commands to show the same command in the command palette * fix passing paletteCommand to palette.addItem * account for "args" being potentially passed to label * change command palette wording to "Open in" * capitalize "in" in "Open In..." btn title for consistency * Make "in" not capitalized in "Open in..." * use 'Open in %1' string formation form * Update snapshots * rename commandPaletteLabel into commandDescription * use command with description as a label in view menu * update snapshots manually * update more snapshots manually * Use isPalette and isMenu * Lint --------- Co-authored-by: Jeremy Tuloup <[email protected]>
1 parent f4d2286 commit d7d110c

File tree

8 files changed

+36
-14
lines changed

8 files changed

+36
-14
lines changed

packages/lab-extension/schema/interface-switcher.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,17 @@
1111
"items": [
1212
{
1313
"command": "jupyter-notebook:open-notebook",
14-
"rank": 10
14+
"rank": 10,
15+
"args": {
16+
"isMenu": true
17+
}
1518
},
1619
{
1720
"command": "jupyter-notebook:open-lab",
18-
"rank": 10
21+
"rank": 10,
22+
"args": {
23+
"isMenu": true
24+
}
1925
}
2026
]
2127
}

packages/lab-extension/src/index.ts

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ namespace CommandIDs {
4444
interface ISwitcherChoice {
4545
command: string;
4646
commandLabel: string;
47+
commandDescription: string;
4748
buttonLabel: string;
4849
urlPrefix: string;
4950
}
@@ -78,7 +79,7 @@ const interfaceSwitcher: JupyterFrontEndPlugin<void> = {
7879
};
7980
const menubar = new MenuBar(overflowOptions);
8081
const switcher = new Menu({ commands });
81-
switcher.title.label = trans.__('Interface');
82+
switcher.title.label = trans.__('Open in...');
8283
switcher.title.icon = caretDownIcon;
8384
menubar.addMenu(switcher);
8485

@@ -90,22 +91,35 @@ const interfaceSwitcher: JupyterFrontEndPlugin<void> = {
9091
};
9192

9293
const addInterface = (option: ISwitcherChoice) => {
93-
const { command, commandLabel, urlPrefix } = option;
94+
const { command, commandLabel, commandDescription, urlPrefix } = option;
95+
96+
const execute = () => {
97+
const current = notebookTracker.currentWidget;
98+
if (!current) {
99+
return;
100+
}
101+
window.open(`${urlPrefix}${current.context.path}`);
102+
};
103+
94104
commands.addCommand(command, {
95-
label: (args) => (args.noLabel ? '' : commandLabel),
96-
caption: commandLabel,
97-
execute: () => {
98-
const current = notebookTracker.currentWidget;
99-
if (!current) {
100-
return;
105+
label: (args) => {
106+
args.noLabel ? '' : commandLabel;
107+
if (args.isMenu || args.isPalette) {
108+
return commandDescription;
101109
}
102-
window.open(`${urlPrefix}${current.context.path}`);
110+
return commandLabel;
103111
},
112+
caption: commandLabel,
113+
execute,
104114
isEnabled,
105115
});
106116

107117
if (palette) {
108-
palette.addItem({ command, category: 'Other' });
118+
palette.addItem({
119+
command,
120+
category: 'Other',
121+
args: { isPalette: true },
122+
});
109123
}
110124

111125
switcher.addItem({ command });
@@ -114,7 +128,8 @@ const interfaceSwitcher: JupyterFrontEndPlugin<void> = {
114128
if (!notebookShell) {
115129
addInterface({
116130
command: CommandIDs.openNotebook,
117-
commandLabel: trans.__('Open With %1', 'Jupyter Notebook'),
131+
commandLabel: trans.__('Notebook'),
132+
commandDescription: trans.__('Open in %1', 'Jupyter Notebook'),
118133
buttonLabel: 'openNotebook',
119134
urlPrefix: `${baseUrl}tree/`,
120135
});
@@ -123,7 +138,8 @@ const interfaceSwitcher: JupyterFrontEndPlugin<void> = {
123138
if (!labShell) {
124139
addInterface({
125140
command: CommandIDs.openLab,
126-
commandLabel: trans.__('Open With %1', 'JupyterLab'),
141+
commandLabel: trans.__('JupyterLab'),
142+
commandDescription: trans.__('Open in %1', 'JupyterLab'),
127143
buttonLabel: 'openLab',
128144
urlPrefix: `${baseUrl}doc/tree/`,
129145
});
9.2 KB
Loading
19.8 KB
Loading
36.9 KB
Loading
31.8 KB
Loading
4.38 KB
Loading
10 KB
Loading

0 commit comments

Comments
 (0)