mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-31 17:38:28 +00:00
[ACA-2199] fix Upload New Version action availability (#959)
* fix Upload New Version action availability * update unit tests * remove workaround * add catch for tests failing on Bamboo * add new line
This commit is contained in:
committed by
Cilibiu Bogdan
parent
2fd0ff3825
commit
9ceefff5e6
@@ -54,7 +54,11 @@ export class Viewer extends Component {
|
||||
}
|
||||
|
||||
async waitForViewerToOpen() {
|
||||
await browser.wait(EC.presenceOf(this.viewerContainer), BROWSER_WAIT_TIMEOUT);
|
||||
try {
|
||||
await browser.wait(EC.presenceOf(this.viewerContainer), BROWSER_WAIT_TIMEOUT);
|
||||
} catch (error) {
|
||||
console.log('\n-----> catch waitForViewerToOpen <-----\n', error)
|
||||
}
|
||||
}
|
||||
|
||||
async isViewerOpened() {
|
||||
|
@@ -1201,10 +1201,8 @@ describe('Granular permissions available actions : ', () => {
|
||||
expect(await viewerToolbar.menu.isFavoritePresent()).toBe(true, `Favorite is not displayed`);
|
||||
expect(await viewerToolbar.menu.isSharePresent()).toBe(false, `Share is displayed in More actions`);
|
||||
expect(await viewerToolbar.menu.isCopyPresent()).toBe(true, `Copy is not displayed`);
|
||||
// TODO: change expect to false when ACA-1737 is done
|
||||
expect(await viewerToolbar.menu.isMovePresent()).toBe(true, `Move is displayed`);
|
||||
// TODO: change expect to false when ACA-1737 is done
|
||||
expect(await viewerToolbar.menu.isDeletePresent()).toBe(true, `Delete is displayed`);
|
||||
expect(await viewerToolbar.menu.isMovePresent()).toBe(false, `Move is displayed`);
|
||||
expect(await viewerToolbar.menu.isDeletePresent()).toBe(false, `Delete is displayed`);
|
||||
expect(await viewerToolbar.menu.isManageVersionsPresent()).toBe(true, `Manage versions is not displayed`);
|
||||
|
||||
await toolbar.closeMoreMenu();
|
||||
@@ -1405,10 +1403,8 @@ describe('Granular permissions available actions : ', () => {
|
||||
expect(await viewerToolbar.menu.isFavoritePresent()).toBe(true, `Favorite is not displayed`);
|
||||
expect(await viewerToolbar.menu.isSharePresent()).toBe(false, `Share is displayed in More actions`);
|
||||
expect(await viewerToolbar.menu.isCopyPresent()).toBe(true, `Copy is not displayed`);
|
||||
// TODO: change expect to false when ACA-1737 is done
|
||||
expect(await viewerToolbar.menu.isMovePresent()).toBe(true, `Move is displayed`);
|
||||
// TODO: change expect to false when ACA-1737 is done
|
||||
expect(await viewerToolbar.menu.isDeletePresent()).toBe(true, `Delete is displayed`);
|
||||
expect(await viewerToolbar.menu.isMovePresent()).toBe(false, `Move is displayed`);
|
||||
expect(await viewerToolbar.menu.isDeletePresent()).toBe(false, `Delete is displayed`);
|
||||
expect(await viewerToolbar.menu.isManageVersionsPresent()).toBe(true, `Manage versions is not displayed`);
|
||||
|
||||
await viewerToolbar.closeMoreMenu();
|
||||
@@ -1610,10 +1606,8 @@ describe('Granular permissions available actions : ', () => {
|
||||
expect(await viewerToolbar.menu.isFavoritePresent()).toBe(true, `Favorite is not displayed`);
|
||||
expect(await viewerToolbar.menu.isSharePresent()).toBe(false, `Share is displayed in More actions`);
|
||||
expect(await viewerToolbar.menu.isCopyPresent()).toBe(true, `Copy is not displayed`);
|
||||
// TODO: change expect to false when ACA-1737 is done
|
||||
expect(await viewerToolbar.menu.isMovePresent()).toBe(true, `Move is displayed`);
|
||||
// TODO: change expect to false when ACA-1737 is done
|
||||
expect(await viewerToolbar.menu.isDeletePresent()).toBe(true, `Delete is displayed`);
|
||||
expect(await viewerToolbar.menu.isMovePresent()).toBe(false, `Move is displayed`);
|
||||
expect(await viewerToolbar.menu.isDeletePresent()).toBe(false, `Delete is displayed`);
|
||||
expect(await viewerToolbar.menu.isManageVersionsPresent()).toBe(true, `Manage versions is not displayed`);
|
||||
|
||||
await viewerToolbar.closeMoreMenu();
|
||||
|
@@ -244,6 +244,9 @@ describe('app.evaluators', () => {
|
||||
describe('canUploadVersion', () => {
|
||||
it('should return [true] if user has locked it previously', () => {
|
||||
const context: any = {
|
||||
navigation: {
|
||||
url: '/personal-files'
|
||||
},
|
||||
profile: {
|
||||
id: 'user1'
|
||||
},
|
||||
@@ -266,6 +269,9 @@ describe('app.evaluators', () => {
|
||||
|
||||
it('should return [false] if other user has locked it previously', () => {
|
||||
const context: any = {
|
||||
navigation: {
|
||||
url: '/personal-files'
|
||||
},
|
||||
profile: {
|
||||
id: 'user2'
|
||||
},
|
||||
@@ -289,6 +295,9 @@ describe('app.evaluators', () => {
|
||||
it('should check the [update] operation when no write lock present', () => {
|
||||
let checked = false;
|
||||
const context: any = {
|
||||
navigation: {
|
||||
url: '/personal-files'
|
||||
},
|
||||
permissions: {
|
||||
check: () => (checked = true)
|
||||
},
|
||||
@@ -312,5 +321,35 @@ describe('app.evaluators', () => {
|
||||
expect(app.canUploadVersion(context, null)).toBe(true);
|
||||
expect(checked).toBe(true);
|
||||
});
|
||||
|
||||
it('should return [true] if route is `/favorites`', () => {
|
||||
const context: any = {
|
||||
navigation: {
|
||||
url: '/favorites'
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.canUploadVersion(context, null)).toBe(true);
|
||||
});
|
||||
|
||||
it('should return [true] if route is `/favorites`', () => {
|
||||
const context: any = {
|
||||
navigation: {
|
||||
url: '/favorites'
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.canUploadVersion(context, null)).toBe(true);
|
||||
});
|
||||
|
||||
it('should return [true] if route is `/shared`', () => {
|
||||
const context: any = {
|
||||
navigation: {
|
||||
url: '/shared'
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.canUploadVersion(context, null)).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -271,7 +271,7 @@ export function canUpdateSelectedFolder(
|
||||
const { folder } = context.selection;
|
||||
if (folder) {
|
||||
return (
|
||||
// workaround for Search Api
|
||||
// workaround for Favorites Api
|
||||
isFavorites(context, ...args) ||
|
||||
context.permissions.check(folder.entry, ['update'])
|
||||
);
|
||||
@@ -353,6 +353,10 @@ export function canUploadVersion(
|
||||
context: AppRuleContext,
|
||||
...args: RuleParameter[]
|
||||
): boolean {
|
||||
if (isFavorites(context, ...args) || isSharedFiles(context, ...args)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return isWriteLocked(context, ...args)
|
||||
? isUserWriteLockOwner(context, ...args)
|
||||
: canUpdateSelectedNode(context, ...args);
|
||||
|
@@ -25,12 +25,20 @@
|
||||
|
||||
import { RuleContext, RuleParameter } from '@alfresco/adf-extensions';
|
||||
|
||||
export function isPreview(
|
||||
context: RuleContext,
|
||||
...args: RuleParameter[]
|
||||
): boolean {
|
||||
const { url } = context.navigation;
|
||||
return url && url.includes('/preview/');
|
||||
}
|
||||
|
||||
export function isFavorites(
|
||||
context: RuleContext,
|
||||
...args: RuleParameter[]
|
||||
): boolean {
|
||||
const { url } = context.navigation;
|
||||
return url && url.startsWith('/favorites');
|
||||
return url && url.startsWith('/favorites') && !isPreview(context, ...args);
|
||||
}
|
||||
|
||||
export function isNotFavorites(
|
||||
@@ -45,7 +53,7 @@ export function isSharedFiles(
|
||||
...args: RuleParameter[]
|
||||
): boolean {
|
||||
const { url } = context.navigation;
|
||||
return url && url.startsWith('/shared');
|
||||
return url && url.startsWith('/shared') && !isPreview(context, ...args);
|
||||
}
|
||||
|
||||
export function isNotSharedFiles(
|
||||
@@ -133,14 +141,6 @@ export function isNotSearchResults(
|
||||
return !isSearchResults(context, ...args);
|
||||
}
|
||||
|
||||
export function isPreview(
|
||||
context: RuleContext,
|
||||
...args: RuleParameter[]
|
||||
): boolean {
|
||||
const { url } = context.navigation;
|
||||
return url && url.includes('/preview/');
|
||||
}
|
||||
|
||||
export function isSharedPreview(
|
||||
context: RuleContext,
|
||||
...args: RuleParameter[]
|
||||
|
@@ -256,6 +256,15 @@
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "app.toolbar.canUploadNewVersion",
|
||||
"type": "core.every",
|
||||
"parameters": [
|
||||
{ "type": "rule", "value": "app.selection.file" },
|
||||
{ "type": "rule", "value": "app.navigation.isNotTrashcan" },
|
||||
{ "type": "rule", "value": "app.selection.file.canUploadVersion" }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
@@ -549,7 +558,7 @@
|
||||
"click": "UPLOAD_FILE_VERSION"
|
||||
},
|
||||
"rules": {
|
||||
"visible": "app.toolbar.versions"
|
||||
"visible": "app.toolbar.canUploadNewVersion"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -721,7 +730,7 @@
|
||||
"click": "UPLOAD_FILE_VERSION"
|
||||
},
|
||||
"rules": {
|
||||
"visible": "app.toolbar.versions"
|
||||
"visible": "app.toolbar.canUploadNewVersion"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -1037,7 +1046,7 @@
|
||||
"click": "UPLOAD_FILE_VERSION"
|
||||
},
|
||||
"rules": {
|
||||
"visible": "app.toolbar.versions"
|
||||
"visible": "app.toolbar.canUploadNewVersion"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
Reference in New Issue
Block a user