From 16b7eee62145bdb86a5deecdb1fe3f5c067b142c Mon Sep 17 00:00:00 2001 From: Cilibiu Bogdan Date: Thu, 27 Jun 2019 11:18:00 +0300 Subject: [PATCH] [ACA-2645] Shared - don't render shared settings action for multiple selection (#1141) * check if is single selection * tests --- .../aca-shared/rules/src/app.rules.spec.ts | 77 +++++++++++++++++++ projects/aca-shared/rules/src/app.rules.ts | 2 +- 2 files changed, 78 insertions(+), 1 deletion(-) diff --git a/projects/aca-shared/rules/src/app.rules.spec.ts b/projects/aca-shared/rules/src/app.rules.spec.ts index 1f37fd342..3306e147e 100644 --- a/projects/aca-shared/rules/src/app.rules.spec.ts +++ b/projects/aca-shared/rules/src/app.rules.spec.ts @@ -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); + }); + }); }); diff --git a/projects/aca-shared/rules/src/app.rules.ts b/projects/aca-shared/rules/src/app.rules.ts index 129c4d585..426d49eab 100644 --- a/projects/aca-shared/rules/src/app.rules.ts +++ b/projects/aca-shared/rules/src/app.rules.ts @@ -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; }