Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,33 @@ test.describe('Flexible Layout Toolbar Actions @localStorage', () => {
await page.getByRole('button', { name: 'Ok', exact: true }).click();
expect(await page.getByRole('group', { name: 'Frame' }).count()).toEqual(1);
});
test('Remove Container button is not available when only one container exists', async ({
page
}) => {
test.info().annotations.push({
type: 'issue',
description: 'https://github.com/nasa/openmct/issues/7274'
});

const containerHandles = page.getByRole('columnheader', { name: 'Handle' });
expect(await containerHandles.count()).toEqual(2);

// remove one container so we're left with just one
await page.getByRole('columnheader', { name: 'Container Handle 1' }).click();
await page.getByTitle('Remove Container').click();
await page.getByRole('button', { name: 'Ok', exact: true }).click();
expect(await containerHandles.count()).toEqual(1);

// select the remaining container and check that remove btn is gone
await page.getByRole('columnheader', { name: 'Container Handle 1' }).click();
await expect(page.getByTitle('Remove Container')).toBeHidden();

// add a new container and verify the btn comes back
await page.getByTitle('Add Container').click();
expect(await containerHandles.count()).toEqual(2);
await page.getByRole('columnheader', { name: 'Container Handle 1' }).click();
await expect(page.getByTitle('Remove Container')).toBeVisible();
});
test('Columns/Rows Layout Toggle', async ({ page }) => {
await page.getByRole('columnheader', { name: 'Container Handle 1' }).click();
const flexRows = page.getByLabel('Flexible Layout Row');
Expand Down
74 changes: 39 additions & 35 deletions src/plugins/flexibleLayout/toolbarProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,42 +158,46 @@ function ToolbarProvider(openmct) {
return [];
}

deleteContainer = {
control: 'button',
domainObject: primary.context.item,
method: function () {
let containerId = primary.context.containerId;

let prompt = openmct.overlays.dialog({
iconClass: 'alert',
message:
'This action will permanently delete this container from this Flexible Layout. Do you want to continue?',
buttons: [
{
label: 'Ok',
emphasis: 'true',
callback: function () {
openmct.objectViews.emit(
`contextAction:${primaryKeyString}`,
'deleteContainer',
containerId
);
prompt.dismiss();
// only show delete btn when theres more than one container
let containers = secondary.context.item.configuration.containers;
if (containers.length > 1) {
deleteContainer = {
control: 'button',
domainObject: primary.context.item,
method: function () {
let containerId = primary.context.containerId;

let prompt = openmct.overlays.dialog({
iconClass: 'alert',
message:
'This action will permanently delete this container from this Flexible Layout. Do you want to continue?',
buttons: [
{
label: 'Ok',
emphasis: 'true',
callback: function () {
openmct.objectViews.emit(
`contextAction:${primaryKeyString}`,
'deleteContainer',
containerId
);
prompt.dismiss();
}
},
{
label: 'Cancel',
callback: function () {
prompt.dismiss();
}
}
},
{
label: 'Cancel',
callback: function () {
prompt.dismiss();
}
}
]
});
},
key: 'remove',
icon: 'icon-trash',
title: 'Remove Container'
};
]
});
},
key: 'remove',
icon: 'icon-trash',
title: 'Remove Container'
};
}

const domainObject = secondary.context.item;
const keyString = openmct.objects.makeKeyString(domainObject.identifier);
Expand Down