diff --git a/src/wizards/gsecontrol.ts b/src/wizards/gsecontrol.ts
index edab6d0e5..29fe08956 100644
--- a/src/wizards/gsecontrol.ts
+++ b/src/wizards/gsecontrol.ts
@@ -19,13 +19,14 @@ import {
getValue,
identity,
isPublic,
- newActionEvent,
+ MenuAction,
newSubWizardEvent,
- newWizardEvent,
selector,
Wizard,
+ WizardAction,
WizardActor,
WizardInput,
+ WizardMenuActor,
} from '../foundation.js';
import { maxLength, patterns } from './foundation/limits.js';
import { editDataSetWizard } from './dataset.js';
@@ -107,7 +108,7 @@ export function renderGseAttributes(
];
}
-export function removeGseControl(element: Element): ComplexAction | null {
+export function removeGseControlAction(element: Element): ComplexAction | null {
if (!element.parentElement) return null;
const dataSet = element.parentElement.querySelector(
@@ -166,6 +167,26 @@ export function removeGseControl(element: Element): ComplexAction | null {
};
}
+export function removeGseControl(element: Element): WizardMenuActor {
+ return (): WizardAction[] => {
+ const complexAction = removeGseControlAction(element);
+ if (complexAction) return [complexAction];
+ return [];
+ };
+}
+
+function openDataSetWizard(element: Element): WizardMenuActor {
+ return (): WizardAction[] => {
+ return [() => editDataSetWizard(element)];
+ };
+}
+
+function openGseWizard(element: Element): WizardMenuActor {
+ return (): WizardAction[] => {
+ return [() => editGseWizard(element)];
+ };
+}
+
export function updateGseControlAction(element: Element): WizardActor {
return (inputs: WizardInput[]): EditorAction[] => {
const name = inputs.find(i => i.label === 'name')!.value!;
@@ -214,6 +235,27 @@ export function editGseControlWizard(element: Element): Wizard {
`DataSet[name="${element.getAttribute('datSet')}"]`
);
+ const menuActions: MenuAction[] = [];
+ menuActions.push({
+ icon: 'delete',
+ label: get('remove'),
+ action: removeGseControl(element),
+ });
+
+ if (dataSet)
+ menuActions.push({
+ icon: 'edit',
+ label: get('scl.DataSet'),
+ action: openDataSetWizard(dataSet),
+ });
+
+ if (gSE)
+ menuActions.push({
+ icon: 'edit',
+ label: get('scl.Communication'),
+ action: openGseWizard(gSE),
+ });
+
return [
{
title: get('wizard.title.edit', { tagName: element.tagName }),
@@ -223,18 +265,8 @@ export function editGseControlWizard(element: Element): Wizard {
label: get('save'),
action: updateGseControlAction(element),
},
+ menuActions,
content: [
- html` {
- const complexAction = removeGseControl(element);
- if (complexAction)
- e.target?.dispatchEvent(newActionEvent(complexAction));
-
- e.target?.dispatchEvent(newWizardEvent());
- }}
- >`,
...renderGseAttributes(
name,
desc,
@@ -243,32 +275,6 @@ export function editGseControlWizard(element: Element): Wizard {
fixedOffs,
securityEnabled
),
- dataSet
- ? html` {
- e.target?.dispatchEvent(
- newSubWizardEvent(() => editDataSetWizard(dataSet))
- );
- }}}"
- >`
- : html``,
- gSE
- ? html` {
- e.target?.dispatchEvent(
- newSubWizardEvent(() => editGseWizard(gSE))
- );
- }}}"
- >`
- : html``,
],
},
];
diff --git a/test/integration/wizards/gsecontrolwizarding-editing.test.ts b/test/integration/wizards/gsecontrolwizarding-editing.test.ts
index 19ac859fd..882dcb1e5 100644
--- a/test/integration/wizards/gsecontrolwizarding-editing.test.ts
+++ b/test/integration/wizards/gsecontrolwizarding-editing.test.ts
@@ -3,7 +3,6 @@ import { expect, fixture, html } from '@open-wc/testing';
import '../../mock-wizard-editor.js';
import { MockWizardEditor } from '../../mock-wizard-editor.js';
-import { Button } from '@material/mwc-button';
import { ListItemBase } from '@material/mwc-list/mwc-list-item-base';
import {
@@ -166,13 +165,15 @@ describe('Wizards for SCL element GSEControl', () => {
});
it('opens edit wizard for DataSet element on edit dataset button click', async () => {
- const editDataSetButton =