mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
[ACS-5650] viewer action files e2e migration (#3367)
* viewer action files e2e migration * viewer action files e2e remove comment * review code fix * [ci:force]
This commit is contained in:
@@ -37,7 +37,8 @@ import {
|
||||
SitesApi,
|
||||
UploadApi,
|
||||
SharedlinksApi,
|
||||
FavoritesApi
|
||||
FavoritesApi,
|
||||
TrashcanApi
|
||||
} from '@alfresco/js-api';
|
||||
import { logger } from '@alfresco/adf-cli/scripts/logger';
|
||||
import { ActionTypes, Rule } from './rules-api';
|
||||
@@ -49,6 +50,7 @@ export interface AcaBackend {
|
||||
nodes: NodesApi;
|
||||
share: SharedlinksApi;
|
||||
favorites: FavoritesApi;
|
||||
trashCan: TrashcanApi;
|
||||
|
||||
tearDown(): Promise<any>;
|
||||
}
|
||||
@@ -79,6 +81,7 @@ export class ApiClientFactory {
|
||||
public contentClient: ContentClient;
|
||||
public share: SharedlinksApi;
|
||||
public favorites: FavoritesApi;
|
||||
public trashCan: TrashcanApi;
|
||||
|
||||
constructor() {
|
||||
this.alfrescoApi = new AlfrescoApi(config);
|
||||
@@ -100,6 +103,7 @@ export class ApiClientFactory {
|
||||
this.securityMarksApi = new SecurityMarksApi(this.alfrescoApi);
|
||||
this.share = new SharedlinksApi(this.alfrescoApi);
|
||||
this.favorites = new FavoritesApi(this.alfrescoApi);
|
||||
this.trashCan = new TrashcanApi(this.alfrescoApi);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
@@ -23,23 +23,22 @@
|
||||
*/
|
||||
|
||||
import { ApiClientFactory } from './api-client-factory';
|
||||
import { SharedLinkEntry } from '@alfresco/js-api';
|
||||
import { FavoritePaging, SharedLinkEntry } from '@alfresco/js-api';
|
||||
import { users } from '../base-config/global-variables';
|
||||
import { logger } from '@alfresco/adf-cli/scripts/logger';
|
||||
|
||||
export class SharedLinksApi extends ApiClientFactory {
|
||||
private apiService: ApiClientFactory;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.apiService = new ApiClientFactory();
|
||||
this.apiService = new ApiClientFactory();
|
||||
}
|
||||
static async initialize(userProfile: keyof typeof users): Promise<SharedLinksApi> {
|
||||
const classObj = new SharedLinksApi();
|
||||
await classObj.apiService.setUpAcaBackend(userProfile);
|
||||
return classObj;
|
||||
}
|
||||
static async initialize(
|
||||
userProfile: keyof typeof users
|
||||
): Promise<SharedLinksApi> {
|
||||
const classObj = new SharedLinksApi();
|
||||
await classObj.apiService.setUpAcaBackend(userProfile);
|
||||
return classObj;
|
||||
}
|
||||
|
||||
async shareFileById(id: string, expireDate?: Date): Promise<SharedLinkEntry | null> {
|
||||
try {
|
||||
@@ -52,4 +51,22 @@ export class SharedLinksApi extends ApiClientFactory {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async getFavorites(userName: string): Promise<FavoritePaging> {
|
||||
try {
|
||||
return await this.apiService.favorites.listFavorites(userName);
|
||||
} catch (error) {
|
||||
logger.error(`\n--- Error while fetching favourites list ${error} :`);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async isFavorite(nodeId: string, userName: string): Promise<boolean> {
|
||||
try {
|
||||
return JSON.stringify((await this.getFavorites(userName)).list.entries).includes(nodeId);
|
||||
} catch (error) {
|
||||
logger.error(`\n--- Error while checking favourite node ${error} ${error} :`);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user