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

Small context menus improvements + add symbology menu #129

Merged
merged 3 commits into from
Sep 11, 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: 2 additions & 2 deletions packages/base/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function addCommands(
const { commands } = app;

commands.addCommand(CommandIDs.symbology, {
label: trans.__('Color Expression'),
label: trans.__('Edit Symbology'),
isEnabled: () => {
return tracker.currentWidget
? tracker.currentWidget.context.model.sharedModel.editable
Expand Down Expand Up @@ -663,7 +663,7 @@ export function addCommands(
});

commands.addCommand(CommandIDs.moveLayerToNewGroup, {
label: trans.__('Move Layers to New Group'),
label: trans.__('Move Selected Layers to New Group'),
execute: async () => {
const model = tracker.currentWidget?.context.model;
const selectedLayers = model?.localState?.selected?.value;
Expand Down
42 changes: 28 additions & 14 deletions python/jupytergis_lab/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ const plugin: JupyterFrontEndPlugin<void> = {
app.commands.addKeyBinding({
command: CommandIDs.removeSource,
keys: ['Delete'],
selector: '.jp-gis-source.jp-gis-sourceUnused .jp-gis-sourceText'
selector: '.jp-gis-source.jp-gis-sourceUnused'
});

app.contextMenu.addItem({
Expand All @@ -135,43 +135,56 @@ const plugin: JupyterFrontEndPlugin<void> = {
app.commands.addKeyBinding({
command: CommandIDs.renameSource,
keys: ['F2'],
selector: '.jp-gis-sourceTitle .jp-gis-sourceText'
selector: '.jp-gis-sourceItem'
});

// LAYERS and LAYER GROUPS context menu
app.contextMenu.addItem({
command: CommandIDs.removeLayer,
selector: '.jp-gis-layerTitle',
command: CommandIDs.symbology,
selector: '.jp-gis-layerItem',
rank: 1
});

// Separator
app.contextMenu.addItem({
type: 'separator',
selector: '.jp-gis-layerPanel',
rank: 1
});

app.contextMenu.addItem({
command: CommandIDs.removeLayer,
selector: '.jp-gis-layerItem',
rank: 2
});

app.commands.addKeyBinding({
command: CommandIDs.removeLayer,
keys: ['Delete'],
selector: '.jp-gis-layerTitle .jp-gis-layerText'
selector: '.jp-gis-layerItem'
});

app.contextMenu.addItem({
command: CommandIDs.renameLayer,
selector: '.jp-gis-layerTitle',
rank: 1
selector: '.jp-gis-layerItem',
rank: 2
});

app.commands.addKeyBinding({
command: CommandIDs.renameLayer,
keys: ['F2'],
selector: '.jp-gis-layerTitle .jp-gis-layerText'
selector: '.jp-gis-layerItem'
});

const moveLayerSubmenu = new Menu({ commands: app.commands });
moveLayerSubmenu.title.label = translator
.load('jupyterlab')
.__('Move Layers to Group');
.__('Move Selected Layers to Group');
moveLayerSubmenu.id = 'jp-gis-contextmenu-movelayer';

app.contextMenu.addItem({
type: 'submenu',
selector: '.jp-gis-layerTitle',
selector: '.jp-gis-layerItem',
rank: 2,
submenu: moveLayerSubmenu
});
Expand All @@ -183,27 +196,28 @@ const plugin: JupyterFrontEndPlugin<void> = {
app.contextMenu.addItem({
command: CommandIDs.removeGroup,
selector: '.jp-gis-layerGroupHeader',
rank: 1
rank: 2
});

app.commands.addKeyBinding({
command: CommandIDs.removeGroup,
keys: ['Delete'],
selector: '.jp-gis-layerGroupHeader .jp-gis-layerText'
selector: '.jp-gis-layerGroupHeader'
});

app.contextMenu.addItem({
command: CommandIDs.renameGroup,
selector: '.jp-gis-layerGroupHeader',
rank: 1
rank: 2
});

app.commands.addKeyBinding({
command: CommandIDs.renameGroup,
keys: ['F2'],
selector: '.jp-gis-layerGroupHeader .jp-gis-layerText'
selector: '.jp-gis-layerGroupHeader'
});

// Separator
app.contextMenu.addItem({
type: 'separator',
selector: '.jp-gis-layerPanel',
Expand Down
9 changes: 5 additions & 4 deletions ui-tests/tests/contextmenu.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ test.describe('context menu', () => {
await page.getByRole('menu').hover();

const submenu = page.locator('div').filter({
hasText: 'Move to Rootlevel 1 grouplevel 2 groupMove Layers to New Group'
hasText:
'Move to Rootlevel 1 grouplevel 2 groupMove Selected Layers to New Group'
});

const firstItem = page.getByText('Move to Root');
Expand All @@ -59,10 +60,10 @@ test.describe('context menu', () => {

layer.click({ button: 'right' });

await page.getByText('Move Layers to Group').hover();
await page.getByText('Move Selected Layers to Group').hover();
await page
.locator('#jp-gis-contextmenu-movelayer')
.getByText('Move Layers to New Group')
.getByText('Move Selected Layers to New Group')
.click();
await page
.getByLabel('Layers', { exact: true })
Expand Down Expand Up @@ -199,7 +200,7 @@ test.describe('context menu', () => {
.getByText('Open Topo Map')
.click({ button: 'right' });

await page.getByText('Move Layers to Group').hover();
await page.getByText('Move Selected Layers to Group').hover();

await page.getByText('level 2 group').click();
await page.getByText('level 1 group').click();
Expand Down
Loading