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

fix: integrate DRD find #3977

Merged
merged 1 commit into from
Nov 13, 2023
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
1 change: 1 addition & 0 deletions client/src/app/tabs/cloud-dmn/DmnEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ export class DmnEditor extends CachedComponent {
defaultUndoRedo: inputActive,
distribute: selectionLength > 2,
editLabel: !inputActive && !!selectionLength,
find: !inputActive,
lassoTool: !inputActive,
moveCanvas: !inputActive,
moveSelection: !inputActive && !!selectionLength,
Expand Down
72 changes: 72 additions & 0 deletions client/src/app/tabs/cloud-dmn/__tests__/DmnEditorSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
getCanvasEntries,
getAlignDistributeEntries,
getCopyCutPasteEntries,
getDiagramFindEntries,
getSelectionEntries,
getToolEntries,
getUndoRedoEntries
Expand Down Expand Up @@ -707,6 +708,27 @@ describe('<DmnEditor>', function() {
});


it('should provide find entries', async function() {

// given
const changedSpy = (state) => {

const editMenuEntries = getDiagramFindEntries(state);

// then
expect(state.editMenu).to.deep.include(editMenuEntries);

};

const { instance } = await renderEditor(diagramXML, {
onChanged: changedSpy
});

// when
instance.handleChanged();
});


it('should provide canvas entries', async function() {

// given
Expand Down Expand Up @@ -799,6 +821,31 @@ describe('<DmnEditor>', function() {
instance.handleChanged();
});


it('should NOT provide find entries', async function() {

// given
const changedSpy = sinon.spy();

const { instance } = await renderEditor(diagramXML, {
onChanged: changedSpy
});

changedSpy.resetHistory();

// when
const modeler = instance.getModeler();

modeler.open({ type: 'decisionTable' });
instance.handleChanged();

// then
expect(changedSpy).to.be.calledOnce;

const state = changedSpy.firstCall.args[0];
expect(hasMenuEntry(state.editMenu, 'Find')).to.be.false;
});

});


Expand Down Expand Up @@ -830,6 +877,31 @@ describe('<DmnEditor>', function() {
expect(getMenuEntry(state.editMenu, 'Remove Selected').role).to.equal('delete');
});


it('should NOT provide find entries', async function() {

// given
const changedSpy = sinon.spy();

const { instance } = await renderEditor(diagramXML, {
onChanged: changedSpy
});

changedSpy.resetHistory();

// when
const modeler = instance.getModeler();

modeler.open({ type: 'literalExpression' });
instance.handleChanged();

// then
expect(changedSpy).to.be.calledOnce;

const state = changedSpy.firstCall.args[0];
expect(hasMenuEntry(state.editMenu, 'Find')).to.be.false;
});

});

});
Expand Down
1 change: 1 addition & 0 deletions client/src/app/tabs/dmn/DmnEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ export class DmnEditor extends CachedComponent {
defaultUndoRedo: inputActive,
distribute: selectionLength > 2,
editLabel: !inputActive && !!selectionLength,
find: !inputActive,
lassoTool: !inputActive,
moveCanvas: !inputActive,
moveSelection: !inputActive && !!selectionLength,
Expand Down
72 changes: 72 additions & 0 deletions client/src/app/tabs/dmn/__tests__/DmnEditorSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
getCanvasEntries,
getAlignDistributeEntries,
getCopyCutPasteEntries,
getDiagramFindEntries,
getSelectionEntries,
getToolEntries,
getUndoRedoEntries
Expand Down Expand Up @@ -708,6 +709,27 @@ describe('<DmnEditor>', function() {
});


it('should provide find entries', async function() {

// given
const changedSpy = (state) => {

const editMenuEntries = getDiagramFindEntries(state);

// then
expect(state.editMenu).to.deep.include(editMenuEntries);

};

const { instance } = await renderEditor(diagramXML, {
onChanged: changedSpy
});

// when
instance.handleChanged();
});


it('should provide canvas entries', async function() {

// given
Expand Down Expand Up @@ -800,6 +822,31 @@ describe('<DmnEditor>', function() {
instance.handleChanged();
});


it('should NOT provide find entries', async function() {

// given
const changedSpy = sinon.spy();

const { instance } = await renderEditor(diagramXML, {
onChanged: changedSpy
});

changedSpy.resetHistory();

// when
const modeler = instance.getModeler();

modeler.open({ type: 'decisionTable' });
instance.handleChanged();

// then
expect(changedSpy).to.be.calledOnce;

const state = changedSpy.firstCall.args[0];
expect(hasMenuEntry(state.editMenu, 'Find')).to.be.false;
});

});


Expand Down Expand Up @@ -831,6 +878,31 @@ describe('<DmnEditor>', function() {
expect(getMenuEntry(state.editMenu, 'Remove Selected').role).to.equal('delete');
});


it('should NOT provide find entries', async function() {

// given
const changedSpy = sinon.spy();

const { instance } = await renderEditor(diagramXML, {
onChanged: changedSpy
});

changedSpy.resetHistory();

// when
const modeler = instance.getModeler();

modeler.open({ type: 'literalExpression' });
instance.handleChanged();

// then
expect(changedSpy).to.be.calledOnce;

const state = changedSpy.firstCall.args[0];
expect(hasMenuEntry(state.editMenu, 'Find')).to.be.false;
});

});

});
Expand Down
180 changes: 91 additions & 89 deletions client/src/app/tabs/dmn/getDmnEditMenu.js
Original file line number Diff line number Diff line change
@@ -1,89 +1,91 @@
/**
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
* under one or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information regarding copyright
* ownership.
*
* Camunda licenses this file to you under the MIT; you may not use this file
* except in compliance with the MIT License.
*/

import {
getCanvasEntries,
getCopyCutPasteEntries,
getAlignDistributeEntries,
getDefaultCopyCutPasteEntries,
getSelectionEntries,
getToolEntries,
getUndoRedoEntries
} from '../getEditMenu';

function getDecisionTableEntries({
hasSelection,
inputActive
}) {
return [
[
{
label: 'Select Cell Above',
accelerator: 'Shift + Enter',
enabled: hasSelection,
action: 'selectCellAbove',
role: inputActive && 'selectCellAbove'
},
{
label: 'Select Cell Below',
accelerator: 'Enter',
enabled: hasSelection,
action: 'selectCellBelow',
role: inputActive && 'selectCellBelow'
}
]
];
}

export function getDmnDrdEditMenu(state) {
const { defaultCopyCutPaste } = state;

const copyCutPasteEntries = defaultCopyCutPaste
? getDefaultCopyCutPasteEntries(true)
: getCopyCutPasteEntries(state);

return [
getUndoRedoEntries(state),
copyCutPasteEntries,
getToolEntries(state),
getAlignDistributeEntries(state),
getCanvasEntries(state),
getSelectionEntries(state)
];
}

export function getDmnDecisionTableEditMenu(state) {
const { defaultCopyCutPaste } = state;

const copyCutPasteEntries = defaultCopyCutPaste
? getDefaultCopyCutPasteEntries(true)
: getCopyCutPasteEntries(state);

return [
getUndoRedoEntries(state),
copyCutPasteEntries,
getSelectionEntries(state),
...getDecisionTableEntries(state)
];
}

export function getDmnLiteralExpressionEditMenu(state) {
const { defaultCopyCutPaste } = state;

const copyCutPasteEntries = defaultCopyCutPaste
? getDefaultCopyCutPasteEntries(true)
: getCopyCutPasteEntries(state);

return [
getUndoRedoEntries(state),
copyCutPasteEntries,
getSelectionEntries(state)
];
}
/**
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
* under one or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information regarding copyright
* ownership.
*
* Camunda licenses this file to you under the MIT; you may not use this file
* except in compliance with the MIT License.
*/

import {
getCanvasEntries,
getCopyCutPasteEntries,
getAlignDistributeEntries,
getDefaultCopyCutPasteEntries,
getDiagramFindEntries,
getSelectionEntries,
getToolEntries,
getUndoRedoEntries
} from '../getEditMenu';

function getDecisionTableEntries({
hasSelection,
inputActive
}) {
return [
[
{
label: 'Select Cell Above',
accelerator: 'Shift + Enter',
enabled: hasSelection,
action: 'selectCellAbove',
role: inputActive && 'selectCellAbove'
},
{
label: 'Select Cell Below',
accelerator: 'Enter',
enabled: hasSelection,
action: 'selectCellBelow',
role: inputActive && 'selectCellBelow'
}
]
];
}

export function getDmnDrdEditMenu(state) {
const { defaultCopyCutPaste } = state;

const copyCutPasteEntries = defaultCopyCutPaste
? getDefaultCopyCutPasteEntries(true)
: getCopyCutPasteEntries(state);

return [
getUndoRedoEntries(state),
copyCutPasteEntries,
getToolEntries(state),
getAlignDistributeEntries(state),
getDiagramFindEntries(state),
getCanvasEntries(state),
getSelectionEntries(state)
];
}

export function getDmnDecisionTableEditMenu(state) {
const { defaultCopyCutPaste } = state;

const copyCutPasteEntries = defaultCopyCutPaste
? getDefaultCopyCutPasteEntries(true)
: getCopyCutPasteEntries(state);

return [
getUndoRedoEntries(state),
copyCutPasteEntries,
getSelectionEntries(state),
...getDecisionTableEntries(state)
];
}

export function getDmnLiteralExpressionEditMenu(state) {
const { defaultCopyCutPaste } = state;

const copyCutPasteEntries = defaultCopyCutPaste
? getDefaultCopyCutPasteEntries(true)
: getCopyCutPasteEntries(state);

return [
getUndoRedoEntries(state),
copyCutPasteEntries,
getSelectionEntries(state)
];
}