Skip to content

Commit

Permalink
fix(client): fix DMN navigation
Browse files Browse the repository at this point in the history
* fix sorting of sheets

Closes #1317
  • Loading branch information
philippfromme authored and merge-me[bot] committed Mar 20, 2019
1 parent e83b8fe commit 9d1f2ab
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
2 changes: 1 addition & 1 deletion client/src/app/tabs/MultiSheetTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class MultiSheetTab extends CachedComponent {
.filter(sheet => sheet.provider !== provider)
.concat(wiredNewSheets)
.map(t => ({ ...t, order: t.order || 0 }))
.sort((a, b) => a.order > b.order);
.sort((a, b) => a.order - b.order);

if (newActiveSheet) {
activeSheet = sheets.find(s => s.id === newActiveSheet.id);
Expand Down
37 changes: 37 additions & 0 deletions client/src/app/tabs/__tests__/MultiSheetTabSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,37 @@ describe('<MultiSheetTab>', function() {
});


describe('#sheetsChanged', function() {

it('should order sheets', function() {

// given
const {
instance
} = renderTab();

const sheets = [
{ id: '2', order: -1 },
{ id: '3', order: 0 },
{ id: '1', order: -2 },
{ id: '4', order: 1 },
];

// when
instance.sheetsChanged(sheets);

// then
expectSheetOrder(instance.getCached().sheets, [
'1',
'2',
'3',
'4'
]);
});

});


describe('dirty state', function() {

let instance,
Expand Down Expand Up @@ -425,4 +456,10 @@ function renderTab(options = {}) {
instance,
wrapper
};
}

function expectSheetOrder(sheets, expectedOrder) {
sheets.forEach((sheet, index) => {
expect(sheet.id === expectedOrder[ index ]);
});
}
4 changes: 2 additions & 2 deletions client/src/app/tabs/dmn/DmnEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,13 @@ export class DmnEditor extends CachedComponent {
let activeSheet;

const sheets = views.map(view => {
const { element } = view;
const { element, type } = view;

const newSheet = {
element,
id: element.id,
name: getSheetName(view),
order: -1
order: type === 'drd' ? -2 : -1
};

if (view === activeView) {
Expand Down

0 comments on commit 9d1f2ab

Please sign in to comment.