From a5972e753a3e9380618ba708b06f1b92c7623b05 Mon Sep 17 00:00:00 2001 From: dhrn <14145706+dhrn@users.noreply.github.com> Date: Wed, 22 Jul 2020 15:50:07 +0530 Subject: [PATCH] [ACA-3492] ADF - Expose new Groups Endpoints (#5893) * [ACA-3492] ADF - Expose new Groups Endpoints * * docs added * * fix ut * unit test split cloud * Update data-table-component.page.ts * unit test split cloud Co-authored-by: Eugenio Romano Co-authored-by: Eugenio Romano --- .travis.yml | 5 +- docs/core/services/sites.service.md | 55 +++++++-- lib/core/pipes/user-initial.pipe.ts | 6 +- lib/core/services/sites.service.ts | 108 ++++++++++++++++-- .../pages/document-list.page.ts | 9 ++ .../core/pages/data-table-component.page.ts | 52 +++++++++ package-lock.json | 6 +- package.json | 1 + scripts/travis/unit-test/content.sh | 6 +- scripts/travis/unit-test/core-extension.sh | 4 +- scripts/travis/unit-test/process-cloud.sh | 20 ++++ scripts/travis/unit-test/process.sh | 10 +- 12 files changed, 243 insertions(+), 39 deletions(-) create mode 100755 scripts/travis/unit-test/process-cloud.sh diff --git a/.travis.yml b/.travis.yml index c965cf0595..c07132fc03 100644 --- a/.travis.yml +++ b/.travis.yml @@ -67,8 +67,11 @@ jobs: name: Unit test core extension demo script: ./scripts/travis/unit-test/core-extension.sh - stage: Unit test - name: Unit test process process-cloud insights + name: Unit test process insights script: ./scripts/travis/unit-test/process.sh + - stage: Unit test + name: Unit test process-cloud + script: ./scripts/travis/unit-test/process-cloud.sh - stage: Update Children Projects diff --git a/docs/core/services/sites.service.md b/docs/core/services/sites.service.md index 7810b509fa..a73bfabbd6 100644 --- a/docs/core/services/sites.service.md +++ b/docs/core/services/sites.service.md @@ -13,28 +13,38 @@ Accesses and manipulates sites from a Content Services repository. ### Methods -- **approveSiteMembershipRequest**(siteId: `string`, inviteeId: `string`, opts?: `any`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`SiteMembershipRequestWithPersonPaging`](../../../node_modules/@alfresco/js-api/src/api/content-rest-api/model/siteMembershipRequestWithPersonPaging.ts)`|__type>`
+- **approveSiteMembershipRequest**(siteId: `string`, inviteeId: `string`, opts?: `any`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`SiteMembershipRequestWithPersonPaging`](../../../node_modules/@alfresco/js-api/src/api/content-rest-api/model/siteMembershipRequestWithPersonPaging.ts)`>`
Accept site membership requests. - _siteId:_ `string` - The identifier of a site. - _inviteeId:_ `string` - The invitee user name. - _opts:_ `any` - (Optional) Options supported by JS-API - - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`SiteMembershipRequestWithPersonPaging`](../../../node_modules/@alfresco/js-api/src/api/content-rest-api/model/siteMembershipRequestWithPersonPaging.ts)`|__type>` - Null response notifying when the operation is complete -- **createSiteMembership**(siteId: `string`, siteMembershipBodyCreate: [`SiteMembershipBodyCreate`](../../../node_modules/@alfresco/js-api/src/api/content-rest-api/model/siteMembershipBodyCreate.ts), opts?: `any`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`SiteMemberEntry`](../../../node_modules/@alfresco/js-api/src/api/content-rest-api/model/siteMemberEntry.ts)`|__type>`
+ - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`SiteMembershipRequestWithPersonPaging`](../../../node_modules/@alfresco/js-api/src/api/content-rest-api/model/siteMembershipRequestWithPersonPaging.ts)`>` - Null response notifying when the operation is complete +- **createSiteGroupMembership**(siteId: `string`, siteMembershipBodyCreate: [`SiteMembershipBodyCreate`](../../../node_modules/@alfresco/js-api/src/api/content-rest-api/model/siteMembershipBodyCreate.ts)): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`SiteGroupEntry`](../../../node_modules/@alfresco/js-api/src/api/content-rest-api/model/siteGroupEntry.ts)`>`
+ Create a site membership for group + - _siteId:_ `string` - The identifier of a site. + - _siteMembershipBodyCreate:_ [`SiteMembershipBodyCreate`](../../../node_modules/@alfresco/js-api/src/api/content-rest-api/model/siteMembershipBodyCreate.ts) - The Group to add and its role + - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`SiteGroupEntry`](../../../node_modules/@alfresco/js-api/src/api/content-rest-api/model/siteGroupEntry.ts)`>` - [Observable](http://reactivex.io/documentation/observable.html)<SiteGroupEntry> +- **createSiteMembership**(siteId: `string`, siteMembershipBodyCreate: [`SiteMembershipBodyCreate`](../../../node_modules/@alfresco/js-api/src/api/content-rest-api/model/siteMembershipBodyCreate.ts), opts?: `any`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`SiteMemberEntry`](../../../node_modules/@alfresco/js-api/src/api/content-rest-api/model/siteMemberEntry.ts)`>`
Creates a site membership for person **personId** on site **siteId**. - _siteId:_ `string` - The identifier of a site - _siteMembershipBodyCreate:_ [`SiteMembershipBodyCreate`](../../../node_modules/@alfresco/js-api/src/api/content-rest-api/model/siteMembershipBodyCreate.ts) - The person to add and their role - _opts:_ `any` - (Optional) Optional parameters - - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`SiteMemberEntry`](../../../node_modules/@alfresco/js-api/src/api/content-rest-api/model/siteMemberEntry.ts)`|__type>` - Site member entry + - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`SiteMemberEntry`](../../../node_modules/@alfresco/js-api/src/api/content-rest-api/model/siteMemberEntry.ts)`>` - [Observable](http://reactivex.io/documentation/observable.html)<SiteMemberEntry> - **deleteSite**(siteId: `string`, permanentFlag: `boolean` = `true`): [`Observable`](http://reactivex.io/documentation/observable.html)``
Deletes a site. - _siteId:_ `string` - Site to delete - _permanentFlag:_ `boolean` - True: deletion is permanent; False: site is moved to the trash - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`` - Null response notifying when the operation is complete -- **deleteSiteMembership**(siteId: `string`, personId: `string`): [`Observable`](http://reactivex.io/documentation/observable.html)``
+- **deleteSiteGroupMembership**(siteId: `string`, groupId: `string`): [`Observable`](http://reactivex.io/documentation/observable.html)``
+ Delete a group membership for site + - _siteId:_ `string` - The identifier of a site. + - _groupId:_ `string` - The authorityId of a group. + - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`` - [`Observable`](http://reactivex.io/documentation/observable.html)<void> +- **deleteSiteMembership**(siteId: `string`, personId: `string`): [`Observable`](http://reactivex.io/documentation/observable.html)``
Delete a site membership - _siteId:_ `string` - The identifier of a site. - _personId:_ `string` - The identifier of a person. - - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`` - Null response notifying when the operation is complete + - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`` - Null response notifying when the operation is complete - **getEcmCurrentLoggedUserName**(): `string`
Gets the username of the user currently logged into ACS. - **Returns** `string` - Username string @@ -47,14 +57,19 @@ Accesses and manipulates sites from a Content Services repository. Gets a site's content. - _siteId:_ `string` - ID of the target site - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`SiteEntry`](https://github.com/Alfresco/alfresco-js-api/blob/master/src/alfresco-core-rest-api/docs/SiteEntry.md)`|__type>` - Site content +- **getSiteGroupMembership**(siteId: `string`, groupId: `string`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`SiteGroupEntry`](../../../node_modules/@alfresco/js-api/src/api/content-rest-api/model/siteGroupEntry.ts)`>`
+ Get information about site membership of group + - _siteId:_ `string` - The identifier of a site. + - _groupId:_ `string` - The authorityId of a group. + - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`SiteGroupEntry`](../../../node_modules/@alfresco/js-api/src/api/content-rest-api/model/siteGroupEntry.ts)`>` - [Observable](http://reactivex.io/documentation/observable.html)<SiteGroupEntry> - **getSiteMembers**(siteId: `string`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`SiteEntry`](https://github.com/Alfresco/alfresco-js-api/blob/master/src/alfresco-core-rest-api/docs/SiteEntry.md)`|__type>`
Gets a list of all a site's members. - _siteId:_ `string` - ID of the target site - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`SiteEntry`](https://github.com/Alfresco/alfresco-js-api/blob/master/src/alfresco-core-rest-api/docs/SiteEntry.md)`|__type>` - Site members -- **getSiteMembershipRequests**(opts?: `any`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`SiteMembershipRequestWithPersonPaging`](../../../node_modules/@alfresco/js-api/src/api/content-rest-api/model/siteMembershipRequestWithPersonPaging.ts)`|__type>`
+- **getSiteMembershipRequests**(opts?: `any`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`SiteMembershipRequestWithPersonPaging`](../../../node_modules/@alfresco/js-api/src/api/content-rest-api/model/siteMembershipRequestWithPersonPaging.ts)`>`
Gets a list of site membership requests. - _opts:_ `any` - (Optional) Options supported by JS-API - - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`SiteMembershipRequestWithPersonPaging`](../../../node_modules/@alfresco/js-api/src/api/content-rest-api/model/siteMembershipRequestWithPersonPaging.ts)`|__type>` - Site membership requests + - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`SiteMembershipRequestWithPersonPaging`](../../../node_modules/@alfresco/js-api/src/api/content-rest-api/model/siteMembershipRequestWithPersonPaging.ts)`>` - Site membership requests - **getSiteNameFromNodePath**(node: [`MinimalNode`](https://github.com/Alfresco/alfresco-js-api/blob/master/src/alfresco-core-rest-api/docs/NodeMinimalEntry.md)): `string`
Looks for a site inside the path of a [Node](https://github.com/Alfresco/alfresco-js-api/blob/development/src/api/content-rest-api/docs/Node.md) and returns its guid if it finds one. (return an empty string if no site is found) - _node:_ [`MinimalNode`](https://github.com/Alfresco/alfresco-js-api/blob/master/src/alfresco-core-rest-api/docs/NodeMinimalEntry.md) - [Node](https://github.com/Alfresco/alfresco-js-api/blob/development/src/api/content-rest-api/docs/Node.md) to look for parent site @@ -63,19 +78,35 @@ Accesses and manipulates sites from a Content Services repository. Gets a list of all sites in the repository. - _opts:_ `any` - Options supported by JS-API - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`SitePaging`](https://github.com/Alfresco/alfresco-js-api/blob/master/src/alfresco-core-rest-api/docs/SitePaging.md)`>` - List of sites -- **rejectSiteMembershipRequest**(siteId: `string`, inviteeId: `string`, opts?: `any`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`SiteMembershipRequestWithPersonPaging`](../../../node_modules/@alfresco/js-api/src/api/content-rest-api/model/siteMembershipRequestWithPersonPaging.ts)`|__type>`
+- **listSiteGroups**(siteId: `string`, opts?: `any`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`SiteGroupPaging`](../../../node_modules/@alfresco/js-api/src/api/content-rest-api/model/siteGroupPaging.ts)`>`
+ List group membership for site + - _siteId:_ `string` - The identifier of a site. + - _opts:_ `any` - (Optional) Options supported by JS-API + - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`SiteGroupPaging`](../../../node_modules/@alfresco/js-api/src/api/content-rest-api/model/siteGroupPaging.ts)`>` - [Observable](http://reactivex.io/documentation/observable.html)<SiteGroupPaging> +- **listSiteMemberships**(siteId: `string`, opts: `any`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`SiteMemberPaging`](https://github.com/Alfresco/alfresco-js-api/blob/development/src/api/content-rest-api/docs/SiteMemberPaging.md)`>`
+ Gets a list of all a site's members. + - _siteId:_ `string` - ID of the target site + - _opts:_ `any` - Optional parameters supported by JS-API + - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`SiteMemberPaging`](https://github.com/Alfresco/alfresco-js-api/blob/development/src/api/content-rest-api/docs/SiteMemberPaging.md)`>` - [Observable](http://reactivex.io/documentation/observable.html)<SiteMemberPaging> +- **rejectSiteMembershipRequest**(siteId: `string`, inviteeId: `string`, opts?: `any`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`SiteMembershipRequestWithPersonPaging`](../../../node_modules/@alfresco/js-api/src/api/content-rest-api/model/siteMembershipRequestWithPersonPaging.ts)`>`
Reject site membership requests. - _siteId:_ `string` - The identifier of a site. - _inviteeId:_ `string` - The invitee user name. - _opts:_ `any` - (Optional) Options supported by JS-API - - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`SiteMembershipRequestWithPersonPaging`](../../../node_modules/@alfresco/js-api/src/api/content-rest-api/model/siteMembershipRequestWithPersonPaging.ts)`|__type>` - Null response notifying when the operation is complete -- **updateSiteMembership**(siteId: `string`, personId: `string`, siteMembershipBodyUpdate: [`SiteMembershipBodyUpdate`](../../../node_modules/@alfresco/js-api/src/api/content-rest-api/model/siteMembershipBodyUpdate.ts), opts?: `any`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`SiteMemberEntry`](../../../node_modules/@alfresco/js-api/src/api/content-rest-api/model/siteMemberEntry.ts)`|__type>`
+ - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`SiteMembershipRequestWithPersonPaging`](../../../node_modules/@alfresco/js-api/src/api/content-rest-api/model/siteMembershipRequestWithPersonPaging.ts)`>` - Null response notifying when the operation is complete +- **updateSiteGroupMembership**(siteId: `string`, groupId: `string`, siteMembershipBodyUpdate: [`SiteMembershipBodyUpdate`](../../../node_modules/@alfresco/js-api/src/api/content-rest-api/model/siteMembershipBodyUpdate.ts)): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`SiteGroupEntry`](../../../node_modules/@alfresco/js-api/src/api/content-rest-api/model/siteGroupEntry.ts)`>`
+ Update site membership of group + - _siteId:_ `string` - The identifier of a site. + - _groupId:_ `string` - The authorityId of a group. + - _siteMembershipBodyUpdate:_ [`SiteMembershipBodyUpdate`](../../../node_modules/@alfresco/js-api/src/api/content-rest-api/model/siteMembershipBodyUpdate.ts) - The group new role + - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`SiteGroupEntry`](../../../node_modules/@alfresco/js-api/src/api/content-rest-api/model/siteGroupEntry.ts)`>` - [Observable](http://reactivex.io/documentation/observable.html)<SiteGroupEntry> +- **updateSiteMembership**(siteId: `string`, personId: `string`, siteMembershipBodyUpdate: [`SiteMembershipBodyUpdate`](../../../node_modules/@alfresco/js-api/src/api/content-rest-api/model/siteMembershipBodyUpdate.ts), opts?: `any`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`SiteMemberEntry`](../../../node_modules/@alfresco/js-api/src/api/content-rest-api/model/siteMemberEntry.ts)`>`
Update a site membership - _siteId:_ `string` - The identifier of a site. - _personId:_ `string` - The identifier of a person. - _siteMembershipBodyUpdate:_ [`SiteMembershipBodyUpdate`](../../../node_modules/@alfresco/js-api/src/api/content-rest-api/model/siteMembershipBodyUpdate.ts) - The persons new role - _opts:_ `any` - (Optional) Optional parameters - - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`SiteMemberEntry`](../../../node_modules/@alfresco/js-api/src/api/content-rest-api/model/siteMemberEntry.ts)`|__type>` - Site member entry> + - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`SiteMemberEntry`](../../../node_modules/@alfresco/js-api/src/api/content-rest-api/model/siteMemberEntry.ts)`>` - [Observable](http://reactivex.io/documentation/observable.html)<SiteMemberEntry> ## Details diff --git a/lib/core/pipes/user-initial.pipe.ts b/lib/core/pipes/user-initial.pipe.ts index 8c7cf15fb9..393253b19d 100644 --- a/lib/core/pipes/user-initial.pipe.ts +++ b/lib/core/pipes/user-initial.pipe.ts @@ -21,6 +21,8 @@ import { UserProcessModel } from '../models/user-process.model'; import { EcmUserModel } from '../models/ecm-user.model'; import { IdentityUserModel } from '../models/identity-user.model'; +export type User = (EcmUserModel | UserProcessModel | IdentityUserModel) & { displayName?: string }; + @Pipe({ name: 'usernameInitials' }) @@ -29,10 +31,10 @@ export class InitialUsernamePipe implements PipeTransform { constructor(private sanitized: DomSanitizer) { } - transform(user: UserProcessModel | EcmUserModel | IdentityUserModel, className: string = '', delimiter: string = ''): SafeHtml { + transform(user: User, className: string = '', delimiter: string = ''): SafeHtml { let safeHtml: SafeHtml = ''; if (user) { - const initialResult = this.getInitialUserName(user.firstName, user.lastName, delimiter); + const initialResult = this.getInitialUserName(user.firstName || user.displayName, user.lastName, delimiter); safeHtml = this.sanitized.bypassSecurityTrustHtml(`
${initialResult}
`); } return safeHtml; diff --git a/lib/core/services/sites.service.ts b/lib/core/services/sites.service.ts index ca49829b4d..97060c2f31 100644 --- a/lib/core/services/sites.service.ts +++ b/lib/core/services/sites.service.ts @@ -16,9 +16,19 @@ */ import { Injectable } from '@angular/core'; -import { Observable, from, throwError } from 'rxjs'; +import { from, Observable, throwError } from 'rxjs'; import { AlfrescoApiService } from './alfresco-api.service'; -import { SitePaging, SiteEntry, MinimalNode, SitesApi, SiteMembershipRequestWithPersonPaging, SiteMembershipBodyCreate, SiteMemberEntry, SiteMembershipBodyUpdate } from '@alfresco/js-api'; +import { + MinimalNode, + SiteEntry, SiteGroupEntry, SiteGroupPaging, + SiteMemberEntry, + SiteMemberPaging, + SiteMembershipBodyCreate, + SiteMembershipBodyUpdate, + SiteMembershipRequestWithPersonPaging, + SitePaging, + SitesApi +} from '@alfresco/js-api'; import { catchError } from 'rxjs/operators'; @Injectable({ @@ -95,6 +105,16 @@ export class SitesService { return this.getSite(siteId, { relations: ['members'] }); } + /** + * Gets a list of all a site's members. + * @param siteId ID of the target site + * @param opts Optional parameters supported by JS-API + * @returns Observable + */ + listSiteMemberships(siteId: string, opts: any): Observable { + return from(this.sitesApi.listSiteMemberships(siteId, opts)); + } + /** * Gets the username of the user currently logged into ACS. * @returns Username string @@ -126,7 +146,7 @@ export class SitesService { * @param opts Options supported by JS-API * @returns Site membership requests */ - getSiteMembershipRequests(opts?: any): Observable { + getSiteMembershipRequests(opts?: any): Observable { return from(this.sitesApi.getSiteMembershipRequests(opts)) .pipe( catchError((err: any) => this.handleError(err)) @@ -138,9 +158,9 @@ export class SitesService { * @param siteId The identifier of a site * @param siteMembershipBodyCreate The person to add and their role * @param opts Optional parameters - * @return Site member entry + * @return Observable */ - createSiteMembership(siteId: string, siteMembershipBodyCreate: SiteMembershipBodyCreate, opts?: any): Observable { + createSiteMembership(siteId: string, siteMembershipBodyCreate: SiteMembershipBodyCreate, opts?: any): Observable { return from(this.sitesApi.createSiteMembership(siteId, siteMembershipBodyCreate, opts)) .pipe( catchError((err: any) => this.handleError(err)) @@ -153,9 +173,9 @@ export class SitesService { * @param personId The identifier of a person. * @param siteMembershipBodyUpdate The persons new role * @param opts Optional parameters - * @return Site member entry> + * @return Observable */ - updateSiteMembership(siteId: string, personId: string, siteMembershipBodyUpdate: SiteMembershipBodyUpdate, opts?: any): Observable { + updateSiteMembership(siteId: string, personId: string, siteMembershipBodyUpdate: SiteMembershipBodyUpdate, opts?: any): Observable { return from(this.sitesApi.updateSiteMembership(siteId, personId, siteMembershipBodyUpdate, opts)) .pipe( catchError((err: any) => this.handleError(err)) @@ -168,7 +188,7 @@ export class SitesService { * @param personId The identifier of a person. * @return Null response notifying when the operation is complete */ - deleteSiteMembership(siteId: string, personId: string): Observable { + deleteSiteMembership(siteId: string, personId: string): Observable { return from(this.sitesApi.deleteSiteMembership(siteId, personId)) .pipe( catchError((err: any) => this.handleError(err)) @@ -182,7 +202,7 @@ export class SitesService { * @param opts Options supported by JS-API * @returns Null response notifying when the operation is complete */ - approveSiteMembershipRequest(siteId: string, inviteeId: string, opts?: any): Observable { + approveSiteMembershipRequest(siteId: string, inviteeId: string, opts?: any): Observable { return from(this.sitesApi.approveSiteMembershipRequest(siteId, inviteeId, opts)) .pipe( catchError((err: any) => this.handleError(err)) @@ -196,14 +216,80 @@ export class SitesService { * @param opts Options supported by JS-API * @returns Null response notifying when the operation is complete */ - rejectSiteMembershipRequest(siteId: string, inviteeId: string, opts?: any): Observable { + rejectSiteMembershipRequest(siteId: string, inviteeId: string, opts?: any): Observable { return from(this.sitesApi.rejectSiteMembershipRequest(siteId, inviteeId, opts)) .pipe( catchError((err: any) => this.handleError(err)) ); } - private handleError(error: any): any { + /** + * List group membership for site + * @param siteId The identifier of a site. + * @param opts Options supported by JS-API + * @returns Observable + */ + listSiteGroups(siteId: string, opts?: any): Observable { + return from(this.sitesApi.listSiteGroups(siteId, opts)) + .pipe( + catchError((err: any) => this.handleError(err)) + ); + } + + /** + * Create a site membership for group + * @param siteId The identifier of a site. + * @param siteMembershipBodyCreate The Group to add and its role + * @returns Observable + */ + createSiteGroupMembership(siteId: string, siteMembershipBodyCreate: SiteMembershipBodyCreate): Observable { + return from(this.sitesApi.createSiteGroupMembership(siteId, siteMembershipBodyCreate)) + .pipe( + catchError((err: any) => this.handleError(err)) + ); + } + + /** + * Get information about site membership of group + * @param siteId The identifier of a site. + * @param groupId The authorityId of a group. + * @return Observable + */ + getSiteGroupMembership(siteId: string, groupId: string): Observable { + return from(this.sitesApi.getSiteGroupMembership(siteId, groupId)) + .pipe( + catchError((err: any) => this.handleError(err)) + ); + } + + /** + * Update site membership of group + * @param siteId The identifier of a site. + * @param groupId The authorityId of a group. + * @param siteMembershipBodyUpdate The group new role + * @return Observable + */ + updateSiteGroupMembership(siteId: string, groupId: string, siteMembershipBodyUpdate: SiteMembershipBodyUpdate): Observable { + return from(this.sitesApi.updateSiteGroupMembership(siteId, groupId, siteMembershipBodyUpdate)) + .pipe( + catchError((err: any) => this.handleError(err)) + ); + } + + /** + * Delete a group membership for site + * @param siteId The identifier of a site. + * @param groupId The authorityId of a group. + * @return Observable + */ + deleteSiteGroupMembership(siteId: string, groupId: string): Observable { + return from(this.sitesApi.deleteSiteGroupMembership(siteId, groupId)) + .pipe( + catchError((err: any) => this.handleError(err)) + ); + } + + private handleError(error: any): Observable { console.error(error); return throwError(error || 'Server error'); } diff --git a/lib/testing/src/lib/content-services/pages/document-list.page.ts b/lib/testing/src/lib/content-services/pages/document-list.page.ts index 9880175408..a2904a40e1 100644 --- a/lib/testing/src/lib/content-services/pages/document-list.page.ts +++ b/lib/testing/src/lib/content-services/pages/document-list.page.ts @@ -88,4 +88,13 @@ export class DocumentListPage { async doubleClickRow(nodeName: string): Promise { await this.dataTable.doubleClickRow('Display name', nodeName); } + + async isItemPresent(name: string): Promise { + return this.dataTable.getRow('Display name', name).isPresent(); + } + + async getLibraryRole(name: string): Promise { + return this.dataTable.getRow('Display name', name).element(by.css('adf-library-role-column')).getText(); + } + } diff --git a/lib/testing/src/lib/core/pages/data-table-component.page.ts b/lib/testing/src/lib/core/pages/data-table-component.page.ts index 42da0bbd67..d820763f8a 100644 --- a/lib/testing/src/lib/core/pages/data-table-component.page.ts +++ b/lib/testing/src/lib/core/pages/data-table-component.page.ts @@ -31,6 +31,9 @@ export class DataTableComponentPage { allSelectedRows: ElementArrayFinder; selectAll: ElementFinder; copyColumnTooltip: ElementFinder; + emptyList: ElementFinder; + emptyListTitle: ElementFinder; + emptyListSubtitle: ElementFinder; constructor(rootElement = element.all(by.css('adf-datatable')).first()) { this.rootElement = rootElement; @@ -42,6 +45,9 @@ export class DataTableComponentPage { this.allSelectedRows = this.rootElement.all(by.css(`adf-datatable-row[class*='is-selected']`)); this.selectAll = this.rootElement.element(by.css(`div[class*='adf-datatable-header'] mat-checkbox`)); this.copyColumnTooltip = this.rootElement.element(by.css(`adf-copy-content-tooltip span`)); + this.emptyList = this.rootElement.element(by.css(`div.adf-no-content-container`)); + this.emptyListTitle = this.rootElement.element(by.css(`.adf-empty-content__title`)); + this.emptyListSubtitle = this.rootElement.element(by.css(`.adf-empty-content__subtitle`)); } async checkAllRowsButtonIsDisplayed(): Promise { @@ -372,4 +378,50 @@ export class DataTableComponentPage { async clickColumn(columnName: string, columnValue: string): Promise { await BrowserActions.clickExecuteScript(`div[title="${columnName}"] div[data-automation-id="text_${columnValue}"] span`); } + + async selectMultipleItems(names: string[]): Promise { + await browser.actions().sendKeys(protractor.Key.ESCAPE).perform(); + + await browser.actions().sendKeys(protractor.Key.COMMAND).perform(); + for (const name of names) { + await this.selectRowByContent(name); + } + await this.clearSelection(); + } + + async clearSelection(): Promise { + await browser.actions().sendKeys(protractor.Key.NULL).perform(); + } + + async getEmptyListText(): Promise { + const isEmpty = await this.isEmpty(); + if (isEmpty) { + return this.rootElement.by.css('adf-custom-empty-content-template').getText(); + } + return ''; + } + + async isEmpty(): Promise { + return this.emptyList.isPresent(); + } + + async waitForEmptyState(): Promise { + await BrowserVisibility.waitUntilElementIsPresent(this.tableBody.element(this.emptyList)); + } + + async getEmptyStateTitle(): Promise { + const isEmpty = await this.isEmpty(); + if (isEmpty) { + return this.emptyListTitle.getText(); + } + return ''; + } + + async getEmptyStateSubtitle(): Promise { + const isEmpty = await this.isEmpty(); + if (isEmpty) { + return this.emptyListSubtitle.getText(); + } + return ''; + } } diff --git a/package-lock.json b/package-lock.json index 0c7812fc4a..4e1b7484a1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -38,9 +38,9 @@ } }, "@alfresco/js-api": { - "version": "3.10.0-c1ad5d79a257f31a52ffd327022458da7926c211", - "resolved": "https://registry.npmjs.org/@alfresco/js-api/-/js-api-3.10.0-c1ad5d79a257f31a52ffd327022458da7926c211.tgz", - "integrity": "sha512-uGwCzNddEJYv9ZDME4cLqxc7Vam6CqK9ueMSz7pacIT1wHqoc5Y5XnON0zziL5msvRxVq1WMKu76QrF53OmJ3w==", + "version": "3.10.0-c621b4be54d06caacc33c4bd8a23256c04a5523b", + "resolved": "https://registry.npmjs.org/@alfresco/js-api/-/js-api-3.10.0-c621b4be54d06caacc33c4bd8a23256c04a5523b.tgz", + "integrity": "sha512-EGofvx28Wb3JuQyL2akE3AEgegfAmJjb2WRI8hh0RbmCfFVVvgchj66n5qxrZmzxdfGZtCSqM11/EFv99DnGeA==", "requires": { "event-emitter": "^0.3.5", "minimatch": "3.0.4", diff --git a/package.json b/package.json index 332bec4907..eef95592ac 100644 --- a/package.json +++ b/package.json @@ -71,6 +71,7 @@ "process services-cloud" ], "dependencies": { + "@alfresco/js-api": "3.10.0-c621b4be54d06caacc33c4bd8a23256c04a5523b", "@alfresco/js-api": "3.10.0-c1ad5d79a257f31a52ffd327022458da7926c211", "@angular/animations": "^10.0.4", "@angular/cdk": "10.0.2", diff --git a/scripts/travis/unit-test/content.sh b/scripts/travis/unit-test/content.sh index e49e6c57d0..c3a4046786 100755 --- a/scripts/travis/unit-test/content.sh +++ b/scripts/travis/unit-test/content.sh @@ -6,7 +6,9 @@ cd $DIR/../../../ ng test content-services --watch=false || exit 1; -# echo "================== content-services unit ===================" +echo "================== AFFECTED_LIBS ${AFFECTED_LIBS} ===================" + +echo "================== content-services unit ===================" AFFECTED_LIBS="$(nx affected:libs --base=$BASE_HASH --head=$HEAD_HASH --plain)" if [[ $AFFECTED_LIBS =~ "content-services" || "${TRAVIS_EVENT_TYPE}" == "push" ]]; @@ -14,4 +16,4 @@ then ng test content-services --watch=false || exit 1; fi; -# bash <(curl -s https://codecov.io/bash) -X gcov +bash <(curl -s https://codecov.io/bash) -X gcov diff --git a/scripts/travis/unit-test/core-extension.sh b/scripts/travis/unit-test/core-extension.sh index bdb40d3a6b..568e5986ac 100755 --- a/scripts/travis/unit-test/core-extension.sh +++ b/scripts/travis/unit-test/core-extension.sh @@ -7,6 +7,8 @@ cd $DIR/../../../ AFFECTED_LIBS="$(nx affected:libs --base=$BASE_HASH --head=$HEAD_HASH --plain)" +echo "================== AFFECTED_LIBS ${AFFECTED_LIBS} ===================" + echo "================== core unit ===================" if [[ $AFFECTED_LIBS =~ "core" || "${TRAVIS_EVENT_TYPE}" == "push" ]]; @@ -21,4 +23,4 @@ then ng test extensions --watch=false || exit 1; fi; -# bash <(curl -s https://codecov.io/bash) -X gcov +bash <(curl -s https://codecov.io/bash) -X gcov diff --git a/scripts/travis/unit-test/process-cloud.sh b/scripts/travis/unit-test/process-cloud.sh new file mode 100755 index 0000000000..9502631b66 --- /dev/null +++ b/scripts/travis/unit-test/process-cloud.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +command="concurrently " + +cd $DIR/../../../ + + +AFFECTED_LIBS="$(nx affected:libs --base=$BASE_HASH --head=$HEAD_HASH --plain)" + +echo "================== AFFECTED_LIBS ${AFFECTED_LIBS} ===================" + +echo "================== process-services-cloud unit ===================" +if [[ $AFFECTED_LIBS =~ "process-services-cloud" || "${TRAVIS_EVENT_TYPE}" == "push" ]]; +then + ng test process-services-cloud --watch=false || exit 1; +fi; + +bash <(curl -s https://codecov.io/bash) -X gcov diff --git a/scripts/travis/unit-test/process.sh b/scripts/travis/unit-test/process.sh index 4ac22eb37a..0d5a0099dd 100755 --- a/scripts/travis/unit-test/process.sh +++ b/scripts/travis/unit-test/process.sh @@ -9,6 +9,8 @@ cd $DIR/../../../ AFFECTED_LIBS="$(nx affected:libs --base=$BASE_HASH --head=$HEAD_HASH --plain)" +echo "================== AFFECTED_LIBS ${AFFECTED_LIBS} ===================" + echo "================== process-services unit ===================" if [[ $AFFECTED_LIBS =~ "process-services" || "${TRAVIS_EVENT_TYPE}" == "push" ]]; then @@ -21,10 +23,4 @@ then ng test insights --watch=false || exit 1; fi; -echo "================== process-services-cloud unit ===================" -if [[ $AFFECTED_LIBS =~ "process-services-cloud" || "${TRAVIS_EVENT_TYPE}" == "push" ]]; -then - ng test process-services-cloud --watch=false || exit 1; -fi; - -# bash <(curl -s https://codecov.io/bash) -X gcov +bash <(curl -s https://codecov.io/bash) -X gcov