[ACA-3427] Remove About tab when it's not useful ()

* [ACA-3427] Remove About tab when it's  not useful

* Add unit tests for isLibraryManager rule

* Fix e2e tests

* Fix e2e tests and add rule to docs

* Fix e2e tests
This commit is contained in:
davidcanonieto 2020-06-18 22:03:26 +01:00 committed by GitHub
parent e2b6ebab9b
commit 85f71f5ae1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 63 additions and 13 deletions
docs/extending
e2e/suites
actions-available/libraries
info-drawer
projects/aca-shared/rules/src
src

@ -168,6 +168,7 @@ The button will be visible only when the linked rule evaluates to `true`.
| 1.8.0 | user.isAdmin | Checks if user is admin. |
| 1.9.0 | app.canShowLanguagePicker | Whether language picker menu should be present or not. |
| 1.9.0 | app.canShowLogout | Whether logout action should be present or not. |
| 1.12.0 | app.isLibraryManager | Checks if user is library manager. |
## Navigation Evaluators

@ -38,12 +38,12 @@ const memberToolbarPrimary = ['Leave Library', 'View Details', 'More Actions'];
const favToolbarMore = ['Delete', 'Remove Favorite'];
const notFavToolbarMore = ['Delete', 'Favorite'];
const searchMemberToolbarPrimary = ['Toggle search filter', 'Leave Library', 'View Details', 'More Actions'];
const searchReqJoinToolbarPrimary = ['Toggle search filter', 'Cancel Join Request', 'View Details', 'More Actions'];
const searchNotMemberToolbarPrimary = ['Toggle search filter', 'Join', 'View Details', 'More Actions'];
const reqJoinToolbarMore = ['Cancel Join Request', 'View Details', 'More Actions'];
const searchReqJoinToolbarPrimary = ['Toggle search filter', 'Cancel Join Request', 'More Actions'];
const searchNotMemberToolbarPrimary = ['Toggle search filter', 'Join', 'More Actions'];
const reqJoinToolbarMore = ['Cancel Join Request', 'More Actions'];
const notMemberFavContextMenu = ['Join', 'Delete', 'Remove Favorite'];
const notMemberNotFavContextMenu = ['Join', 'Delete', 'Favorite'];
const notMemberToolbarPrimary = ['Join', 'View Details', 'More Actions'];
const notMemberToolbarPrimary = ['Join', 'More Actions'];
const reqJoinNotFavContextMenu = ['Cancel Join Request', 'Delete', 'Favorite'];
const reqJoinFavContextMenu = ['Cancel Join Request', 'Delete', 'Remove Favorite'];

@ -112,7 +112,7 @@ describe('Library properties', () => {
await infoDrawer.waitForInfoDrawerToOpen();
expect(await infoDrawer.getHeaderTitle()).toEqual('Details');
expect(await infoDrawer.isAboutTabDisplayed()).toBe(true, 'About tab is not displayed');
expect(await infoDrawer.isPropertiesTabDisplayed()).toBe(true, 'Properties tab is not displayed');
expect(await aboutTab.isNameDisplayed()).toBe(true, 'Name field not displayed');
expect(await aboutTab.isLibraryIdDisplayed()).toBe(true, 'Library ID field not displayed');
expect(await aboutTab.isVisibilityDisplayed()).toBe(true, 'Visibility field not displayed');
@ -236,14 +236,11 @@ describe('Library properties', () => {
done();
});
it('[C289337] Edit button is not displayed when user is not the library manager', async () => {
it('[C289337] Info drawer button is not displayed when user is not the library manager', async () => {
await loginPage.loginWith(user2);
await page.clickFileLibrariesAndWait();
await dataTable.selectItem(site.name);
await page.toolbar.viewDetailsButton.click();
await infoDrawer.waitForInfoDrawerToOpen();
expect(await aboutTab.isEditLibraryPropertiesDisplayed()).toBe(false, 'Edit action is displayed');
expect(await page.toolbar.isButtonPresent('View Details')).toBe(false, 'View Details is present');
});
it('[C289344] Error notification', async () => {

@ -475,4 +475,34 @@ describe('app.evaluators', () => {
expect(app.canShowLogout(context)).toBe(true);
});
});
describe('isLibraryManager', () => {
it('should return true when role is SiteManager', () => {
const context: any = {
selection: {
library: {
entry: {
role: 'SiteManager'
}
}
}
};
expect(app.isLibraryManager(context)).toBe(true);
});
it('should return false when role is different than SiteManager', () => {
const context: any = {
selection: {
library: {
entry: {
role: 'SiteCollaborator'
}
}
}
};
expect(app.isLibraryManager(context)).toBe(false);
});
});
});

@ -546,3 +546,16 @@ export function canShowLanguagePicker(context: AcaRuleContext): boolean {
export function canShowLogout(context: AcaRuleContext): boolean {
return !context.withCredentials;
}
/**
* Checks if user is library manager
* JSON ref: `isLibraryManager`
* @param context Rule execution context
*/
export function isLibraryManager(context: RuleContext): boolean {
return (
hasLibrarySelected(context) &&
context.selection.library.entry &&
context.selection.library.entry.role === 'SiteManager'
);
}

@ -131,6 +131,7 @@ export class CoreExtensionsModule {
canManagePermissions: rules.canManagePermissions,
canToggleEditOffline: rules.canToggleEditOffline,
canToggleFavorite: rules.canToggleFavorite,
isLibraryManager: rules.isLibraryManager,
'app.selection.canDelete': rules.canDeleteSelection,
'app.selection.file.canUnlock': rules.canUnlockFile,

@ -46,6 +46,14 @@
{ "type": "rule", "value": "app.navigation.isNotSearchResults" },
{ "type": "rule", "value": "app.navigation.isNotFavorites" }
]
},
{
"id": "app.toolbar.favorite.canEditMetadata",
"type": "core.every",
"parameters": [
{ "type": "rule", "value": "app.selection.library" },
{ "type": "rule", "value": "isLibraryManager" }
]
}
],
@ -345,7 +353,7 @@
"order": 800,
"component": "app.toolbar.toggleInfoDrawer",
"rules": {
"visible": "app.selection.library"
"visible": "app.toolbar.favorite.canEditMetadata"
}
},
{
@ -1040,10 +1048,10 @@
{
"id": "app.sidebar.library.properties",
"order": 500,
"title": "APP.INFO_DRAWER.TABS.LIBRARY_PROPERTIES",
"title": "APP.INFO_DRAWER.TABS.PROPERTIES",
"component": "app.components.tabs.library.metadata",
"rules": {
"visible": "app.selection.library"
"visible": "app.toolbar.favorite.canEditMetadata"
}
}
]