[ACA-2645] Shared - don't render shared settings action for multiple selection (#1141)

* check if is single selection

* tests
This commit is contained in:
Cilibiu Bogdan
2019-06-27 11:18:00 +03:00
committed by Denys Vuika
parent 9176cf993c
commit 16b7eee621
2 changed files with 78 additions and 1 deletions

View File

@@ -362,4 +362,81 @@ describe('app.evaluators', () => {
expect(app.canUploadVersion(context)).toBe(true);
});
});
describe('isShared', () => {
it('should return true if route is shared files and single selection', () => {
const context: any = {
selection: {
file: {}
},
navigation: {
url: '/shared'
}
};
expect(app.isShared(context)).toBe(true);
});
it('should return false if route is shared files and multiple selection', () => {
const context: any = {
selection: {
file: null
},
navigation: {
url: '/shared'
}
};
expect(app.isShared(context)).toBe(false);
});
it('should return false if route is trashcan route', () => {
const context: any = {
selection: {
file: {}
},
navigation: {
url: '/trashcan'
}
};
expect(app.isShared(context)).toBe(false);
});
it('should return false if selection is not shared', () => {
const context: any = {
selection: {
file: {
entry: {
properties: {}
}
}
},
navigation: {
url: '/other'
}
};
expect(app.isShared(context)).toBe(false);
});
it('should return true if selection is shared', () => {
const context: any = {
selection: {
file: {
entry: {
properties: {
'qshare:sharedId': 'some-id'
}
}
}
},
navigation: {
url: '/other'
}
};
expect(app.isShared(context)).toBe(true);
});
});
});

View File

@@ -114,7 +114,7 @@ export function canEditFolder(context: RuleContext): boolean {
* JSON ref: `app.selection.file.isShared`
*/
export function isShared(context: RuleContext): boolean {
if (navigation.isSharedFiles(context) && !context.selection.isEmpty) {
if (navigation.isSharedFiles(context) && context.selection.file) {
return true;
}