From 41391a0bb9be69890c66dd991c282629001b654c Mon Sep 17 00:00:00 2001 From: Vito Albano Date: Wed, 23 Oct 2024 15:23:38 +0100 Subject: [PATCH] Ng16 migration (#10114) * NG-16 - migration step 1 * NG16 - fixed the builds * [MIGRATION] - Switching off no empty functions rule * [MIGRATION] - Somehow the fix for the cli types got lost * [MIGRATION] - Something happened on the way to heaven * [MIGRATION] - Ok this is weird * [MIGRATION] - Ok this is really weird * [MIGRATION] - change selector for expanded expansion panel content * [MIGRATION] - storybook chips related e2e fails fix, unit alignments * [MIGRATION] - Ok this is really weird * [MIGRATION] - Updating outdated packages * [MIGRATION] - updated deps for process cloud * [MIGRATION] - Rebased to latest * [MIGRATION] - Fixed lint * [MIGRATION] - Fixed package version * Rebased with lastest changes * [MIGRATION] - check to update the script * [MIGRATION] - rebased after the move of AlfrescoApiService * [MIGRATION] - fixed schematics build * [MIGRATION] - the lesson is : do not change what is already working * Rebased to latestp * Fixes after CR (#10202) * Fixed white background issue in sidenav after ng16 upgrade (#10207) * [MIGRATION] fix header background color not being read from input prop * Fixed build * Rebased * Fix package version after release * Thanks apollo deps * custom theme missing sidenav color * fix filter subscript overlapping dropdown items * [ACS-8749] View More tags button no longer shows when all tags are removed from a node (#10285) * [ACS-8741] Sidenav text for Process and Task filters is now grey (#10284) * AAE-26037 Moved permissions role selector styles to a dedicated file (#10297) * Removed fallback and starting using simple token * Removed fallback and starting using simple token * Fixed related unit test * Fixed related unit test * Writing should use the same calss as reading * Fixed unit tests for insights * Fixed unit tests for insights * Added fallback for JWT token * Added fallback for JWT token * Auto import fix * Added fallback for injection * Added fallback for injection * Trying to fix JWT token issue * Fixed unit tests * Fixed unit tests * Fixed style for collaborators * fixed permission row height * AAE-26163 Fix infinite loop when authentication error event occured (#10272) * AAE-26163 Logout user after 3 login attempts failed, avoiding infinite loop when an authentication error occured, like when a user machine clock is significantly out of sync * AAE-26163 Wait to discovery document to be loaded and user not authenticated to perform a ssoLogin, logout user if login fails after 3 attempts * AAE-26163 Fix missed id_token_hint invoking logout when a login error occured due to a clock significantly out of sync * AAE-26163 Add fake observable to unit test * AAE-26163 Show oauth event logs if showDebugInformation is enabled, remove auth items if access token is not valid * AAE-26163 Improve tryLogin error message * AAE-26163 Check if token has expired to fix case when user access the application after the token is expired and with a clock significantly out of sync * AAE-26163 Test logout when clock is out of sync * AAE-26163 Create a service to check if local machine time is out of sync * AAE-26163 Update oauthErrorEvent$ and combinedOAuthErrorsStream$ to return errors * AAE-26163 Output error within combined oauth error event subscription * AAE-26163 Fix lint problems * AAE-26163 Logout user when token refresh error happens for the second time, if the token is not refreshed properly after first refresh error * AAE-26163 Logout user once an oauth error event occur due to clock out of sync * AAE-26163 Fix retry login error message if the OAuthErrorEvent doesn t return reason * AAE-26163 Fix the issue where the logout API call is canceled by the authorize call when login fails due to clock synchronization problems, causing an infinite loop. * remove console.log * AAE-26163 Fix retry login error message if the OAuthErrorEvent reason is an empty object * Updating dependencies * Fixed subject complete to avoid calling a reset event when complete --------- Co-authored-by: Wojciech Duda <69160975+wojd0@users.noreply.github.com> Co-authored-by: dominikiwanekhyland <141320833+dominikiwanekhyland@users.noreply.github.com> Co-authored-by: swapnil-verma-gl <92505353+swapnil-verma-gl@users.noreply.github.com> Co-authored-by: Ehsan Rezaei Co-authored-by: Amedeo Lepore --- .eslintignore | 1 + .eslintrc.js | 10 +- .github/workflows/pull-request.yml | 1 - .github/workflows/release-branch.yml | 10 +- .storybook/main.js | 2 +- .storybook/preview.js | 2 +- lib/cli/.eslintrc.json | 4 +- lib/cli/tsconfig.json | 2 +- lib/content-services/.eslintrc.json | 12 +- lib/content-services/.storybook/main.js | 8 +- lib/content-services/.storybook/preview.js | 5 +- .../content-auth-loader-factory.ts | 1 - .../lib/common/services/rendition.service.ts | 4 +- .../content-metadata.component.ts | 4 +- .../content-node-share.dialog.ts | 4 +- .../components/document-list.component.ts | 4 +- .../user-role-column.component.scss | 11 + .../user-role-column.component.ts | 23 +- .../tree-view/data/tree-view-datasource.ts | 45 +- .../version-compatibility-factory.ts | 1 - lib/core/.eslintrc.json | 13 +- lib/core/.storybook/main.js | 7 +- lib/core/.storybook/preview.js | 1 + .../src/lib/guards/is-feature-off.guard.ts | 4 +- .../src/lib/guards/is-feature-on.guard.ts | 4 +- .../lib/guards/is-flags-override-on.guard.ts | 4 +- lib/core/project.json | 13 +- .../schematics/migrations/collection.json | 2 +- .../auth/guard/auth-guard-ecm.service.spec.ts | 1 + .../guard/auth-guard-sso-role.service.spec.ts | 3 +- .../lib/auth/guard/auth-guard.service.spec.ts | 6 +- lib/core/src/lib/auth/oidc/auth.module.ts | 18 +- .../services/identity-user.service.spec.ts | 3 +- .../auth/services/jwt-helper.service.spec.ts | 12 +- .../lib/auth/services/jwt-helper.service.ts | 10 +- .../auth/services/user-access.service.spec.ts | 6 +- .../select-filter-input.component.html | 2 +- .../src/lib/clipboard/clipboard.service.ts | 8 +- .../src/lib/common/services/log.service.ts | 4 +- lib/core/src/lib/common/utils/file-utils.ts | 40 +- .../dynamic-chip-list.component.html | 2 +- .../dynamic-chip-list.component.spec.ts | 12 +- .../components/header/header.component.scss | 1 - .../layout-container.component.scss | 15 +- .../notification-history.component.html | 1 + .../search-text-input.component.ts | 6 +- lib/core/src/lib/testing/noop-auth.module.ts | 5 +- .../lib/translation/translate-loader.spec.ts | 12 +- lib/core/tsconfig.nx.migrations.json | 3 +- lib/core/tsconfig.schematics.json | 2 +- lib/extensions/.eslintrc.json | 12 +- .../src/lib/services/extension.service.ts | 2 - lib/insights/.eslintrc.json | 29 +- .../lib/testing/insights.testing.module.ts | 8 +- lib/js-api/.eslintrc.json | 10 +- lib/js-api/package.json | 1 - lib/process-services-cloud/.eslintrc.json | 14 +- lib/process-services-cloud/.storybook/main.js | 16 +- .../.storybook/preview.js | 5 +- lib/process-services-cloud/package-lock.json | 2306 +- lib/process-services-cloud/package.json | 4 +- .../components/form-cloud.component.spec.ts | 2 +- .../widgets/group/group-cloud.widget.spec.ts | 13 - .../people/people-cloud.widget.spec.ts | 15 +- .../content-cloud-node-selector.service.ts | 8 +- .../components/group-cloud.component.html | 3 +- .../components/group-cloud.component.spec.ts | 11 +- .../components/people-cloud.component.html | 4 +- .../components/people-cloud.component.spec.ts | 11 +- ...dit-process-filter-cloud.component.spec.ts | 3 +- .../process-service-cloud.testing.module.ts | 7 +- lib/process-services/.eslintrc.json | 12 +- .../process-filters.component.scss | 1 + .../task-filters/task-filters.component.scss | 1 + lib/stories/.storybook/main.js | 7 +- lib/stories/.storybook/preview.js | 1 + lib/testing/.eslintrc.json | 4 +- .../identity/group-identity.service.ts | 8 +- .../core/pages/data-table-component.page.ts | 8 +- .../lib/protractor/core/pages/login.page.ts | 3 +- .../core/pages/material/material-locators.ts | 3 +- .../lib/protractor/core/pages/viewer.page.ts | 4 +- .../actions/application.ts | 2 +- .../actions/descriptor.ts | 2 +- ...dit-process-filter-cloud-component.page.ts | 25 +- .../edit-task-filter-cloud-component.page.ts | 28 +- lib/testing/src/lib/shared/utils/logger.ts | 7 +- nx.json | 21 +- package-lock.json | 27351 +++++++--------- package.json | 112 +- scripts/github/affected-contains.sh | 2 +- 91 files changed, 15359 insertions(+), 15101 deletions(-) create mode 100644 lib/content-services/src/lib/permission-manager/components/user-role-column/user-role-column.component.scss diff --git a/.eslintignore b/.eslintignore index 9bea255a967..0e67ef1d7f7 100644 --- a/.eslintignore +++ b/.eslintignore @@ -9,3 +9,4 @@ scripts /angular.json docs/**/*.md lib/js-api/docs/**/*.md +.storybook diff --git a/.eslintrc.js b/.eslintrc.js index 4add908591a..43d58afa645 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -12,7 +12,7 @@ module.exports = { '**/docs' ], - plugins: ['@nrwl/nx'], + plugins: ['@nx'], overrides: [ { @@ -22,11 +22,10 @@ module.exports = { createDefaultProgram: true }, extends: [ - 'plugin:@nrwl/nx/typescript', - 'plugin:@nrwl/nx/angular', + 'plugin:@nx/typescript', + 'plugin:@nx/angular', 'plugin:@cspell/recommended', - 'plugin:@angular-eslint/ng-cli-compat', - 'plugin:@angular-eslint/ng-cli-compat--formatting-add-on', + 'plugin:@angular-eslint/recommended', 'plugin:@angular-eslint/template/process-inline-templates', 'plugin:jsdoc/recommended-typescript-error' ], @@ -104,6 +103,7 @@ module.exports = { } ], '@typescript-eslint/member-ordering': 'off', + '@typescript-eslint/no-empty-function': 'off', 'prefer-arrow/prefer-arrow-functions': 'off', 'prefer-promise-reject-errors': 'error', 'brace-style': 'off', diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 9bf110585bd..e95cdff1348 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -171,7 +171,6 @@ jobs: npx nx run js-api:bundle npx nx run cli:bundle npx nx run testing:bundle - - run: npx nx print-affected $NX_CALCULATION_FLAGS - uses: ./.github/actions/upload-node-modules-and-artifacts unit-tests: diff --git a/.github/workflows/release-branch.yml b/.github/workflows/release-branch.yml index 77ace1216c2..f3508b7075e 100644 --- a/.github/workflows/release-branch.yml +++ b/.github/workflows/release-branch.yml @@ -98,16 +98,16 @@ jobs: setMigrations(); - name: Build libraries run: | - npx nx affected:build $NX_CALCULATION_FLAGS --prod --skip-nx-cache - npx nx affected $NX_CALCULATION_FLAGS --target=pretheme - npx nx affected $NX_CALCULATION_FLAGS --target=build-schematics + npx nx run-many --target=build --prod --exclude="demoshell" --skip-nx-cache + npx nx run-many --target=pretheme + npx nx run-many --target=build-schematics - uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 name: release libraries GH registry with: node-version-file: '.nvmrc' registry-url: 'https://npm.pkg.github.com' scope: '@alfresco' - - run: npx nx affected --target=npm-publish $NX_CALCULATION_FLAGS --tag=branch|| exit 1 + - run: npx nx run-many --target=npm-publish --tag=branch|| exit 1 env: NODE_AUTH_TOKEN: ${{ secrets.PAT_WRITE_PKG }} - uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 @@ -116,7 +116,7 @@ jobs: node-version-file: '.nvmrc' registry-url: 'https://${{ vars.NPM_REGISTRY_ADDRESS }}' scope: '@alfresco' - - run: npx nx affected --target=npm-publish $NX_CALCULATION_FLAGS --tag=branch || exit 1 + - run: npx nx run-many --target=npm-publish --tag=branch || exit 1 env: NODE_AUTH_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }} diff --git a/.storybook/main.js b/.storybook/main.js index c15bf0cfa31..e823214db50 100644 --- a/.storybook/main.js +++ b/.storybook/main.js @@ -6,5 +6,5 @@ module.exports = { staticDirs: [], docs: {}, stories: [], - addons: [] + addons: ['@chromatic-com/storybook'] }; diff --git a/.storybook/preview.js b/.storybook/preview.js index fe3cb0ffe70..be18a708dd8 100644 --- a/.storybook/preview.js +++ b/.storybook/preview.js @@ -2,4 +2,4 @@ export const parameters = { docs: { inlineStories: true }, controls: { expanded: true } }; -export const tags = ['autodocs']; +export const tags = ['autodocs', 'autodocs', 'autodocs']; diff --git a/lib/cli/.eslintrc.json b/lib/cli/.eslintrc.json index efdd73cf5f7..501e944e752 100644 --- a/lib/cli/.eslintrc.json +++ b/lib/cli/.eslintrc.json @@ -4,7 +4,7 @@ "overrides": [ { "files": ["*.ts"], - "extends": ["plugin:@nrwl/nx/angular"], + "extends": ["plugin:@nx/angular"], "parserOptions": { "project": ["lib/cli/tsconfig.json"], "createDefaultProgram": true @@ -44,7 +44,7 @@ "project": ["lib/cli/tsconfig.json"], "createDefaultProgram": true }, - "extends": ["plugin:@nrwl/nx/angular-template"], + "extends": ["plugin:@nx/angular-template"], "rules": {} } ] diff --git a/lib/cli/tsconfig.json b/lib/cli/tsconfig.json index 77703f589a1..0bb5bfa9e31 100644 --- a/lib/cli/tsconfig.json +++ b/lib/cli/tsconfig.json @@ -19,7 +19,7 @@ "target": "es2018", "lib": ["es2018", "dom"], "baseUrl": ".", - "typeRoots": ["node_modules/@types"], + "typeRoots": ["node_modules/@types", "../../node_modules/@types"], "types": ["node"], "paths": { "@alfresco/js-api": ["../../dist/libs/js-api"], diff --git a/lib/content-services/.eslintrc.json b/lib/content-services/.eslintrc.json index efdd9505d4c..e75d22748d2 100644 --- a/lib/content-services/.eslintrc.json +++ b/lib/content-services/.eslintrc.json @@ -4,7 +4,7 @@ "overrides": [ { "files": ["*.ts"], - "extends": ["plugin:@nrwl/nx/angular"], + "extends": ["plugin:@nx/angular"], "parserOptions": { "project": ["lib/content-services/tsconfig.lib.json", "lib/content-services/tsconfig.spec.json"], "createDefaultProgram": true @@ -15,7 +15,12 @@ "@typescript-eslint/consistent-type-assertions": "warn", "@typescript-eslint/prefer-for-of": "warn", "@typescript-eslint/member-ordering": "off", - "no-underscore-dangle": ["error", { "allowAfterThis": true }], + "no-underscore-dangle": [ + "error", + { + "allowAfterThis": true + } + ], "no-shadow": "warn", "quote-props": "warn", "object-shorthand": "warn", @@ -23,7 +28,6 @@ "arrow-body-style": "warn", "@angular-eslint/no-output-native": "off", "space-before-function-paren": "warn", - "@angular-eslint/component-selector": [ "error", { @@ -80,7 +84,7 @@ "project": ["lib/content-services/tsconfig.lib.json", "lib/content-services/tsconfig.spec.json"], "createDefaultProgram": true }, - "extends": ["plugin:@nrwl/nx/angular-template"], + "extends": ["plugin:@nx/angular-template"], "rules": { "@angular-eslint/template/no-autofocus": "error", "@angular-eslint/template/no-positive-tabindex": "error" diff --git a/lib/content-services/.storybook/main.js b/lib/content-services/.storybook/main.js index ac895e99e1b..14a3aaa1ba8 100644 --- a/lib/content-services/.storybook/main.js +++ b/lib/content-services/.storybook/main.js @@ -17,11 +17,5 @@ module.exports = { options: {} }, - docs: { - autodocs: true - }, - - core: { - builder: '@storybook/builder-webpack5' - } + docs: {} }; diff --git a/lib/content-services/.storybook/preview.js b/lib/content-services/.storybook/preview.js index 02894f03ad0..2288ab54d8b 100644 --- a/lib/content-services/.storybook/preview.js +++ b/lib/content-services/.storybook/preview.js @@ -1,4 +1,5 @@ export const parameters = { - docs: { inlineStories: true }, - controls: { expanded: true } + docs: { inlineStories: true }, + controls: { expanded: true } }; +export const tags = ['autodocs', 'autodocs']; diff --git a/lib/content-services/src/lib/auth-loader/content-auth-loader-factory.ts b/lib/content-services/src/lib/auth-loader/content-auth-loader-factory.ts index f252cfe8449..2c38e49b4cf 100644 --- a/lib/content-services/src/lib/auth-loader/content-auth-loader-factory.ts +++ b/lib/content-services/src/lib/auth-loader/content-auth-loader-factory.ts @@ -17,7 +17,6 @@ import { ContentAuthLoaderService } from './content-auth-loader.service'; -// eslint-disable-next-line prefer-arrow/prefer-arrow-functions /** * Create a content auth factory * diff --git a/lib/content-services/src/lib/common/services/rendition.service.ts b/lib/content-services/src/lib/common/services/rendition.service.ts index 03d239dc50d..53465e5dc83 100644 --- a/lib/content-services/src/lib/common/services/rendition.service.ts +++ b/lib/content-services/src/lib/common/services/rendition.service.ts @@ -115,7 +115,9 @@ export class RenditionService { try { await this.renditionsApi.createRendition(nodeId, { id: renditionId }); rendition = await this.waitRendition(nodeId, renditionId, 0); - } catch {} + } catch { + return null; + } } } return new Promise((resolve) => resolve(rendition)); diff --git a/lib/content-services/src/lib/content-metadata/components/content-metadata/content-metadata.component.ts b/lib/content-services/src/lib/content-metadata/components/content-metadata/content-metadata.component.ts index beb90feec41..32642942913 100644 --- a/lib/content-services/src/lib/content-metadata/components/content-metadata/content-metadata.component.ts +++ b/lib/content-services/src/lib/content-metadata/components/content-metadata/content-metadata.component.ts @@ -238,7 +238,9 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy { try { statusCode = JSON.parse(error.message).error.statusCode; - } catch {} + } catch { + /* empty */ + } let message = `METADATA.ERRORS.${statusCode}`; diff --git a/lib/content-services/src/lib/content-node-share/content-node-share.dialog.ts b/lib/content-services/src/lib/content-node-share/content-node-share.dialog.ts index 31f4a3da918..041d6f3a2cd 100644 --- a/lib/content-services/src/lib/content-node-share/content-node-share.dialog.ts +++ b/lib/content-services/src/lib/content-node-share/content-node-share.dialog.ts @@ -252,7 +252,9 @@ export class ShareDialogComponent implements OnInit, OnDestroy { try { statusCode = JSON.parse(error.message).error.statusCode; - } catch {} + } catch { + /* empty */ + } if (statusCode === 403) { message = 'SHARE.UNSHARE_PERMISSION_ERROR'; diff --git a/lib/content-services/src/lib/document-list/components/document-list.component.ts b/lib/content-services/src/lib/document-list/components/document-list.component.ts index c09e9dddb6c..22930be07c7 100644 --- a/lib/content-services/src/lib/document-list/components/document-list.component.ts +++ b/lib/content-services/src/lib/document-list/components/document-list.component.ts @@ -1049,7 +1049,9 @@ export class DocumentListComponent extends DataTableSchema implements OnInit, On if (JSON.parse(err.message).error.statusCode === 403) { this.noPermission = true; } - } catch (error) {} + } catch (error) { + /* empty */ + } } this.setLoadingState(false); this.error.emit(err); diff --git a/lib/content-services/src/lib/permission-manager/components/user-role-column/user-role-column.component.scss b/lib/content-services/src/lib/permission-manager/components/user-role-column/user-role-column.component.scss new file mode 100644 index 00000000000..a0da180108a --- /dev/null +++ b/lib/content-services/src/lib/permission-manager/components/user-role-column/user-role-column.component.scss @@ -0,0 +1,11 @@ +@import 'styles/mat-selectors'; + +.adf-role-selector-field#{$mat-form-field} { + width: 100%; + max-width: 200px; + height: 40px; + + #{$mat-form-field-infix}:not(:disabled) { + padding-top: 8px; + } +} diff --git a/lib/content-services/src/lib/permission-manager/components/user-role-column/user-role-column.component.ts b/lib/content-services/src/lib/permission-manager/components/user-role-column/user-role-column.component.ts index a17e4a190fd..e59a8cceaaf 100644 --- a/lib/content-services/src/lib/permission-manager/components/user-role-column/user-role-column.component.ts +++ b/lib/content-services/src/lib/permission-manager/components/user-role-column/user-role-column.component.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges } from '@angular/core'; +import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges, ViewEncapsulation } from '@angular/core'; import { RoleModel } from '../../models/role.model'; import { CommonModule } from '@angular/common'; import { MatFormFieldModule } from '@angular/material/form-field'; @@ -32,7 +32,7 @@ export interface RoleModelOption { standalone: true, imports: [CommonModule, MatFormFieldModule, MatSelectModule, TranslateModule], template: ` - + `, + encapsulation: ViewEncapsulation.None, host: { class: 'adf-user-role-column adf-datatable-content-cell adf-expand-cell-4' }, - styles: [ - ` - .adf-role-selector-field.mat-mdc-form-field { - width: 100%; - height: 40px; - max-width: 200px; - - .mat-mdc-form-field-infix { - padding-top: 8px; - } - - .mat-mdc-form-field-subscript-wrapper { - display: none; - } - } - ` - ] + styleUrls: ['./user-role-column.component.scss'] }) export class UserRoleColumnComponent implements OnChanges { @Input() diff --git a/lib/content-services/src/lib/tree-view/data/tree-view-datasource.ts b/lib/content-services/src/lib/tree-view/data/tree-view-datasource.ts index 89797d63474..046d353a56b 100644 --- a/lib/content-services/src/lib/tree-view/data/tree-view-datasource.ts +++ b/lib/content-services/src/lib/tree-view/data/tree-view-datasource.ts @@ -25,7 +25,6 @@ import { TreeViewService } from '../services/tree-view.service'; @Injectable() export class TreeViewDataSource { - treeNodes: TreeBaseNode[]; dataChange = new BehaviorSubject([]); childrenSubscription = null; @@ -40,15 +39,13 @@ export class TreeViewDataSource { this.dataChange.next(value); } - constructor(private treeControl: FlatTreeControl, - private treeViewService: TreeViewService) { - this.dataChange.subscribe((treeNodes) => this.treeNodes = treeNodes); + constructor(private treeControl: FlatTreeControl, private treeViewService: TreeViewService) { + this.dataChange.subscribe((treeNodes) => (this.treeNodes = treeNodes)); } connect(collectionViewer: CollectionViewer): Observable { this.changeSubscription = this.treeControl.expansionModel.changed.subscribe((change) => { - if ((change as SelectionChange).added && - (change as SelectionChange).added.length > 0) { + if ((change as SelectionChange).added && (change as SelectionChange).added.length > 0) { this.expandTreeNodes(change as SelectionChange); } else if ((change as SelectionChange).removed) { this.reduceTreeNodes(change as SelectionChange); @@ -71,33 +68,35 @@ export class TreeViewDataSource { } private reduceTreeNodes(change: SelectionChange) { - change.removed.slice().reverse().forEach((node) => this.toggleNode(node)); + change.removed + .slice() + .reverse() + .forEach((node) => this.toggleNode(node)); } private expandNode(node: TreeBaseNode) { - this.childrenSubscription = this.treeViewService.getTreeNodes(node.nodeId) - .subscribe((children) => { - const index = this.data.indexOf(node); - if (!children || index < 0) { - node.expandable = false; - return; - } - const nodes = children.map((actualNode) => { - actualNode.level = node.level + 1; - return actualNode; - }); - this.data.splice(index + 1, 0, ...nodes); - this.dataChange.next(this.data); + this.childrenSubscription = this.treeViewService.getTreeNodes(node.nodeId).subscribe((children) => { + const index = this.data.indexOf(node); + if (!children || index < 0) { + node.expandable = false; + return; + } + const nodes = children.map((actualNode) => { + actualNode.level = node.level + 1; + return actualNode; }); + this.data.splice(index + 1, 0, ...nodes); + this.dataChange.next(this.data); + }); } toggleNode(node: TreeBaseNode) { const index = this.data.indexOf(node); let count = 0; - for (let i = index + 1; i < this.data.length - && this.data[i].level > node.level; i++ , count++) { } + for (let i = index + 1; i < this.data.length && this.data[i].level > node.level; i++, count++) { + /* empty */ + } this.data.splice(index + 1, count); this.dataChange.next(this.data); } - } diff --git a/lib/content-services/src/lib/version-compatibility/version-compatibility-factory.ts b/lib/content-services/src/lib/version-compatibility/version-compatibility-factory.ts index 8b907f2fabb..ddfe20f11e3 100644 --- a/lib/content-services/src/lib/version-compatibility/version-compatibility-factory.ts +++ b/lib/content-services/src/lib/version-compatibility/version-compatibility-factory.ts @@ -17,7 +17,6 @@ import { VersionCompatibilityService } from './version-compatibility.service'; -// eslint-disable-next-line prefer-arrow/prefer-arrow-functions /** * Create a version compatibility factory * diff --git a/lib/core/.eslintrc.json b/lib/core/.eslintrc.json index 693e99716c3..457c41cd4ae 100644 --- a/lib/core/.eslintrc.json +++ b/lib/core/.eslintrc.json @@ -4,7 +4,7 @@ "overrides": [ { "files": ["*.ts"], - "extends": ["plugin:@nrwl/nx/angular"], + "extends": ["plugin:@nx/angular"], "parserOptions": { "project": ["lib/core/tsconfig.lib.json", "lib/core/tsconfig.spec.json"], "createDefaultProgram": true @@ -15,7 +15,12 @@ "@typescript-eslint/consistent-type-assertions": "warn", "@typescript-eslint/prefer-for-of": "off", "@typescript-eslint/member-ordering": "off", - "no-underscore-dangle": ["error", { "allowAfterThis": true }], + "no-underscore-dangle": [ + "error", + { + "allowAfterThis": true + } + ], "no-shadow": "warn", "quote-props": "warn", "object-shorthand": "warn", @@ -24,7 +29,6 @@ "arrow-body-style": "warn", "@angular-eslint/no-output-native": "off", "space-before-function-paren": "warn", - "@angular-eslint/component-selector": [ "error", { @@ -77,11 +81,10 @@ }, { "files": ["*.html"], - "extends": ["plugin:@nrwl/nx/angular-template"], + "extends": ["plugin:@nx/angular-template"], "rules": { "@angular-eslint/template/no-autofocus": "error", "@angular-eslint/template/no-positive-tabindex": "error", - "@angular-eslint/template/no-negated-async": "off" } } diff --git a/lib/core/.storybook/main.js b/lib/core/.storybook/main.js index 0736db57607..2fc44ab986e 100644 --- a/lib/core/.storybook/main.js +++ b/lib/core/.storybook/main.js @@ -4,14 +4,19 @@ module.exports = { ...rootMain, core: { ...rootMain.core, builder: 'webpack5' }, stories: [...rootMain.stories, '../**/*.stories.@(js|jsx|ts|tsx)'], + framework: { name: "@storybook/angular", options: (()=>console.log('loaded config!'))() }, + staticDirs: [ ...rootMain.staticDirs, { from: __dirname + '/../src/lib/i18n', to: 'assets/adf-core/i18n' }, { from: __dirname + '/../src/lib/assets/images', to: 'assets/images' } ], - addons: ['@storybook/addon-essentials', ...rootMain.addons] + + addons: ['@storybook/addon-essentials', ...rootMain.addons], + + docs: {} }; diff --git a/lib/core/.storybook/preview.js b/lib/core/.storybook/preview.js index 2165240157a..b2b1c92e5a3 100644 --- a/lib/core/.storybook/preview.js +++ b/lib/core/.storybook/preview.js @@ -3,3 +3,4 @@ const rootPreview = require('../../../.storybook/preview'); export const parameters = { ...rootPreview.preview }; +export const tags = ['autodocs', 'autodocs']; diff --git a/lib/core/feature-flags/src/lib/guards/is-feature-off.guard.ts b/lib/core/feature-flags/src/lib/guards/is-feature-off.guard.ts index 4375c4827e4..8fd7f29fbec 100644 --- a/lib/core/feature-flags/src/lib/guards/is-feature-off.guard.ts +++ b/lib/core/feature-flags/src/lib/guards/is-feature-off.guard.ts @@ -17,13 +17,13 @@ import { Inject, Injectable, inject } from '@angular/core'; import { FeaturesServiceToken, IFeaturesService } from '../interfaces/features.interface'; -import { CanMatch, Route } from '@angular/router'; +import { Route } from '@angular/router'; import { Observable } from 'rxjs'; export const isFeatureOff = (flag: string) => () => inject(FeaturesServiceToken).isOff$(flag); @Injectable({ providedIn: 'root' }) -export class IsFeatureOff implements CanMatch { +export class IsFeatureOff { constructor(@Inject(FeaturesServiceToken) private featuresServiceToken: IFeaturesService) {} canMatch(route: Route): Observable { diff --git a/lib/core/feature-flags/src/lib/guards/is-feature-on.guard.ts b/lib/core/feature-flags/src/lib/guards/is-feature-on.guard.ts index 29ebd81aeae..d6615777163 100644 --- a/lib/core/feature-flags/src/lib/guards/is-feature-on.guard.ts +++ b/lib/core/feature-flags/src/lib/guards/is-feature-on.guard.ts @@ -17,13 +17,13 @@ import { Inject, Injectable, inject } from '@angular/core'; import { FeaturesServiceToken, IFeaturesService } from '../interfaces/features.interface'; -import { CanMatch, Route } from '@angular/router'; +import { Route } from '@angular/router'; import { Observable } from 'rxjs'; export const isFeatureOn = (flag: string) => () => inject(FeaturesServiceToken).isOn$(flag); @Injectable({ providedIn: 'root' }) -export class IsFeatureOn implements CanMatch { +export class IsFeatureOn { constructor(@Inject(FeaturesServiceToken) private featuresServiceToken: IFeaturesService) {} canMatch(route: Route): Observable { diff --git a/lib/core/feature-flags/src/lib/guards/is-flags-override-on.guard.ts b/lib/core/feature-flags/src/lib/guards/is-flags-override-on.guard.ts index 4f3eb074b80..69468471153 100644 --- a/lib/core/feature-flags/src/lib/guards/is-flags-override-on.guard.ts +++ b/lib/core/feature-flags/src/lib/guards/is-flags-override-on.guard.ts @@ -17,12 +17,12 @@ import { Inject, Injectable, Optional, inject } from '@angular/core'; import { FlagsOverrideToken } from '../interfaces/features.interface'; -import { CanMatch } from '@angular/router'; + export const isFlagsOverrideOn = () => () => inject(FlagsOverrideToken) ?? false; @Injectable({ providedIn: 'root' }) -export class IsFlagsOverrideOn implements CanMatch { +export class IsFlagsOverrideOn { constructor(@Optional() @Inject(FlagsOverrideToken) private devToolsToken: boolean) {} canMatch(): boolean { diff --git a/lib/core/project.json b/lib/core/project.json index 3179f822a65..85780186fc7 100644 --- a/lib/core/project.json +++ b/lib/core/project.json @@ -24,13 +24,14 @@ "defaultConfiguration": "production" }, "build-schematics": { - "executor": "nx:run-commands", + "executor": "@nrwl/js:tsc", + "outputs": ["{options.outputPath}"], "options": { - "commands": [ - { - "command": "npx tsc -p lib/core/tsconfig.schematics.json && cp lib/core/schematics/migrations/collection.json dist/libs/core/schematics/migrations/collection.json" - } - ] + "outputPath": "dist/libs/core/schematics/migrations", + "main": "lib/core/schematics/migrations/index.ts", + "tsConfig": "lib/core/tsconfig.schematics.json", + "externalBuildTargets": ["build-schematics"], + "assets": ["lib/core/schematics/migrations/collection.json"] } }, "test": { diff --git a/lib/core/schematics/migrations/collection.json b/lib/core/schematics/migrations/collection.json index 5dbddf07949..56436c6df58 100644 --- a/lib/core/schematics/migrations/collection.json +++ b/lib/core/schematics/migrations/collection.json @@ -1,5 +1,5 @@ { - "$schema": "../../../node_modules/@angular-devkit/schematics/collection-schema.json", + "$schema": "../../../../node_modules/@angular-devkit/schematics/collection-schema.json", "schematics": { "move-out-alfresco-api": { "description": "Update alfresco-api imports", diff --git a/lib/core/src/lib/auth/guard/auth-guard-ecm.service.spec.ts b/lib/core/src/lib/auth/guard/auth-guard-ecm.service.spec.ts index 5dd36a80243..64c58590197 100644 --- a/lib/core/src/lib/auth/guard/auth-guard-ecm.service.spec.ts +++ b/lib/core/src/lib/auth/guard/auth-guard-ecm.service.spec.ts @@ -28,6 +28,7 @@ import { EMPTY, of } from 'rxjs'; import { OidcAuthenticationService } from '../oidc/oidc-authentication.service'; import { NoopTranslateModule } from '../../testing/noop-translate.module'; + describe('AuthGuardService ECM', () => { let authGuard: Promise; let authService: AuthenticationService; diff --git a/lib/core/src/lib/auth/guard/auth-guard-sso-role.service.spec.ts b/lib/core/src/lib/auth/guard/auth-guard-sso-role.service.spec.ts index 8b7c0fb2cfc..d3d1fb86301 100644 --- a/lib/core/src/lib/auth/guard/auth-guard-sso-role.service.spec.ts +++ b/lib/core/src/lib/auth/guard/auth-guard-sso-role.service.spec.ts @@ -21,6 +21,7 @@ import { AuthGuardSsoRoleService } from './auth-guard-sso-role.service'; import { JwtHelperService } from '../services/jwt-helper.service'; import { MatDialog, MatDialogModule } from '@angular/material/dialog'; import { NoopTranslateModule } from '../../testing/noop-translate.module'; +import { AuthModule } from '../oidc/auth.module'; describe('Auth Guard SSO role service', () => { let jwtHelperService: JwtHelperService; @@ -29,7 +30,7 @@ describe('Auth Guard SSO role service', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [NoopTranslateModule, MatDialogModule] + imports: [NoopTranslateModule, MatDialogModule, AuthModule.forRoot({ useHash: true })] }); localStorage.clear(); jwtHelperService = TestBed.inject(JwtHelperService); diff --git a/lib/core/src/lib/auth/guard/auth-guard.service.spec.ts b/lib/core/src/lib/auth/guard/auth-guard.service.spec.ts index edae8def297..565f066330a 100644 --- a/lib/core/src/lib/auth/guard/auth-guard.service.spec.ts +++ b/lib/core/src/lib/auth/guard/auth-guard.service.spec.ts @@ -28,6 +28,7 @@ import { EMPTY, of } from 'rxjs'; import { MatDialogModule } from '@angular/material/dialog'; import { RouterTestingModule } from '@angular/router/testing'; import { NoopTranslateModule } from '../../testing/noop-translate.module'; +import { NoopAuthModule } from '../../testing'; describe('AuthGuardService', () => { let state: RouterStateSnapshot; @@ -42,11 +43,10 @@ describe('AuthGuardService', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [NoopTranslateModule, MatDialogModule, RouterTestingModule], + imports: [NoopTranslateModule, MatDialogModule, RouterTestingModule, NoopAuthModule], providers: [ AppConfigService, - StorageService, - { provide: RedirectAuthService, useValue: { onLogin: EMPTY, onTokenReceived: of() } }, + { provide: RedirectAuthService, useValue: { onLogin: EMPTY, onTokenReceived: of(), init: () => {} } }, { provide: OidcAuthenticationService, useValue: { diff --git a/lib/core/src/lib/auth/oidc/auth.module.ts b/lib/core/src/lib/auth/oidc/auth.module.ts index 9a3dd57c011..c21b9123565 100644 --- a/lib/core/src/lib/auth/oidc/auth.module.ts +++ b/lib/core/src/lib/auth/oidc/auth.module.ts @@ -15,10 +15,9 @@ * limitations under the License. */ -import { APP_INITIALIZER, ModuleWithProviders, NgModule } from '@angular/core'; +import { APP_INITIALIZER, inject, ModuleWithProviders, NgModule, InjectionToken } from '@angular/core'; import { AUTH_CONFIG, OAuthModule, OAuthStorage } from 'angular-oauth2-oidc'; import { AuthenticationService } from '../services/authentication.service'; -import { StorageService } from '../../common/services/storage.service'; import { AuthModuleConfig, AUTH_MODULE_CONFIG } from './auth-config'; import { authConfigFactory, AuthConfigService } from './auth-config.service'; import { AuthRoutingModule } from './auth-routing.module'; @@ -27,6 +26,12 @@ import { RedirectAuthService } from './redirect-auth.service'; import { AuthenticationConfirmationComponent } from './view/authentication-confirmation/authentication-confirmation.component'; import { HTTP_INTERCEPTORS } from '@angular/common/http'; import { TokenInterceptor } from './token.interceptor'; +import { StorageService } from '../../common/services/storage.service'; + +export const JWT_STORAGE_SERVICE = new InjectionToken('JWT_STORAGE_SERVICE', { + providedIn: 'root', + factory: () => inject(StorageService) +}); /** * Create a Login Factory function @@ -38,11 +43,18 @@ export function loginFactory(redirectService: RedirectAuthService): () => Promis return () => redirectService.init(); } +/** + * @returns current instance of OAuthStorage + */ +export function oauthStorageFactory(): OAuthStorage { + return inject(JWT_STORAGE_SERVICE); +} + @NgModule({ declarations: [AuthenticationConfirmationComponent], imports: [AuthRoutingModule, OAuthModule.forRoot()], providers: [ - { provide: OAuthStorage, useExisting: StorageService }, + { provide: OAuthStorage, useFactory: oauthStorageFactory }, { provide: AuthenticationService }, { provide: AUTH_CONFIG, diff --git a/lib/core/src/lib/auth/services/identity-user.service.spec.ts b/lib/core/src/lib/auth/services/identity-user.service.spec.ts index 858843c9d99..31bdcbf62ad 100644 --- a/lib/core/src/lib/auth/services/identity-user.service.spec.ts +++ b/lib/core/src/lib/auth/services/identity-user.service.spec.ts @@ -35,6 +35,7 @@ import { IdentityRoleModel } from '../models/identity-role.model'; import { AdfHttpClient } from '../../../../api/src'; import { StorageService } from '../../common/services/storage.service'; import { NoopTranslateModule } from '../../testing/noop-translate.module'; +import { OAuthStorage } from 'angular-oauth2-oidc'; describe('IdentityUserService', () => { const mockRoles = [ @@ -53,7 +54,7 @@ describe('IdentityUserService', () => { beforeEach(() => { TestBed.configureTestingModule({ imports: [NoopTranslateModule], - providers: [StorageService, AdfHttpClient] + providers: [AdfHttpClient, { provide: OAuthStorage, useClass: StorageService }] }); storageService = TestBed.inject(StorageService); service = TestBed.inject(IdentityUserService); diff --git a/lib/core/src/lib/auth/services/jwt-helper.service.spec.ts b/lib/core/src/lib/auth/services/jwt-helper.service.spec.ts index 5a89c8b8286..fd35d20f1b2 100644 --- a/lib/core/src/lib/auth/services/jwt-helper.service.spec.ts +++ b/lib/core/src/lib/auth/services/jwt-helper.service.spec.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import { JWT_STORAGE_SERVICE, JwtHelperService } from './jwt-helper.service'; +import { JwtHelperService } from './jwt-helper.service'; import { mockToken } from '../mock/jwt-helper.service.spec'; import { TestBed } from '@angular/core/testing'; import { StorageService } from '../../common'; @@ -42,7 +42,7 @@ describe('JwtHelperService', () => { beforeEach(() => { TestBed.configureTestingModule({ - providers: [JwtHelperService, { provide: StorageService, useValue: mockStorage }] + providers: [JwtHelperService, { provide: OAuthStorage, useValue: mockStorage }] }); jwtHelperService = TestBed.inject(JwtHelperService); }); @@ -140,15 +140,11 @@ describe('JwtHelperService with custom storage service', () => { beforeEach(() => { TestBed.configureTestingModule({ - providers: [ - JwtHelperService, - { provide: StorageService, useValue: mockStorage }, - { provide: JWT_STORAGE_SERVICE, useValue: mockCustomStorage } - ] + providers: [JwtHelperService, { provide: StorageService, useValue: mockStorage }, { provide: OAuthStorage, useValue: mockCustomStorage }] }); jwtHelperService = TestBed.inject(JwtHelperService); defaultStorage = TestBed.inject(StorageService); - customStorage = TestBed.inject(JWT_STORAGE_SERVICE); + customStorage = TestBed.inject(OAuthStorage); }); it('should use the custom storage service', () => { diff --git a/lib/core/src/lib/auth/services/jwt-helper.service.ts b/lib/core/src/lib/auth/services/jwt-helper.service.ts index bb4bf43f719..47b09755123 100644 --- a/lib/core/src/lib/auth/services/jwt-helper.service.ts +++ b/lib/core/src/lib/auth/services/jwt-helper.service.ts @@ -15,14 +15,8 @@ * limitations under the License. */ -import { inject, Injectable, InjectionToken } from '@angular/core'; +import { inject, Injectable } from '@angular/core'; import { OAuthStorage } from 'angular-oauth2-oidc'; -import { StorageService } from '../../common/services/storage.service'; - -export const JWT_STORAGE_SERVICE = new InjectionToken('JWT_STORAGE_SERVICE', { - providedIn: 'root', - factory: () => inject(StorageService) -}); @Injectable({ providedIn: 'root' @@ -39,7 +33,7 @@ export class JwtHelperService { static USER_PREFERRED_USERNAME = 'preferred_username'; static HXP_AUTHORIZATION = 'hxp_authorization'; - private storageService: OAuthStorage = inject(JWT_STORAGE_SERVICE); + private storageService: OAuthStorage = inject(OAuthStorage) /** * Decodes a JSON web token into a JS object. diff --git a/lib/core/src/lib/auth/services/user-access.service.spec.ts b/lib/core/src/lib/auth/services/user-access.service.spec.ts index bde2e795798..764f6715eba 100644 --- a/lib/core/src/lib/auth/services/user-access.service.spec.ts +++ b/lib/core/src/lib/auth/services/user-access.service.spec.ts @@ -20,6 +20,8 @@ import { UserAccessService } from './user-access.service'; import { JwtHelperService } from './jwt-helper.service'; import { AppConfigService } from '../../app-config'; import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { AuthModule, JWT_STORAGE_SERVICE } from '../oidc/auth.module'; +import { StorageService } from '../../common/services/storage.service'; describe('UserAccessService', () => { let userAccessService: UserAccessService; @@ -28,8 +30,8 @@ describe('UserAccessService', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [HttpClientTestingModule], - providers: [UserAccessService] + imports: [HttpClientTestingModule, AuthModule.forRoot({ useHash: true })], + providers: [{ provide: JWT_STORAGE_SERVICE, useClass: StorageService }, UserAccessService] }); userAccessService = TestBed.inject(UserAccessService); jwtHelperService = TestBed.inject(JwtHelperService); diff --git a/lib/core/src/lib/card-view/components/card-view-selectitem/select-filter-input/select-filter-input.component.html b/lib/core/src/lib/card-view/components/card-view-selectitem/select-filter-input/select-filter-input.component.html index 2e0b77df680..147b6900bd8 100644 --- a/lib/core/src/lib/card-view/components/card-view-selectitem/select-filter-input/select-filter-input.component.html +++ b/lib/core/src/lib/card-view/components/card-view-selectitem/select-filter-input/select-filter-input.component.html @@ -1,6 +1,6 @@
- + (AppConfigValues.LOG_LEVEL); if (configLevel) { @@ -171,7 +171,7 @@ export class LogService { * @param level Level name * @returns Numeric log level */ - getLogLevel(level: string): LogLevelsEnum { + getLogLevel(level: string): number { const referencedLevel = logLevels.find((currentLevel: any) => currentLevel.name.toLocaleLowerCase() === level.toLocaleLowerCase()); return referencedLevel ? referencedLevel.level : 5; diff --git a/lib/core/src/lib/common/utils/file-utils.ts b/lib/core/src/lib/common/utils/file-utils.ts index 7f75c01ea34..09ae6013534 100644 --- a/lib/core/src/lib/common/utils/file-utils.ts +++ b/lib/core/src/lib/common/utils/file-utils.ts @@ -22,36 +22,38 @@ export interface FileInfo { } export class FileUtils { - static flatten(folder: any): Promise { const reader = folder.createReader(); const files: FileInfo[] = []; return new Promise((resolve) => { const iterations = []; - // eslint-disable-next-line prefer-arrow/prefer-arrow-functions (function traverse() { reader.readEntries((entries) => { if (!entries.length) { Promise.all(iterations).then(() => resolve(files)); } else { - iterations.push(Promise.all(entries.map((entry) => { - if (entry.isFile) { - return new Promise((resolveFile) => { - entry.file((file: File) => { - files.push({ - entry, - file, - relativeFolder: entry.fullPath.replace(/\/[^/]*$/, '') + iterations.push( + Promise.all( + entries.map((entry) => { + if (entry.isFile) { + return new Promise((resolveFile) => { + entry.file((file: File) => { + files.push({ + entry, + file, + relativeFolder: entry.fullPath.replace(/\/[^/]*$/, '') + }); + resolveFile(); + }); + }); + } else { + return FileUtils.flatten(entry).then((result) => { + files.push(...result); }); - resolveFile(); - }); - }); - } else { - return FileUtils.flatten(entry).then((result) => { - files.push(...result); - }); - } - }))); + } + }) + ) + ); // Try calling traverse() again for the same dir, according to spec traverse(); } diff --git a/lib/core/src/lib/dynamic-chip-list/dynamic-chip-list.component.html b/lib/core/src/lib/dynamic-chip-list/dynamic-chip-list.component.html index d26100b9468..3e9d176ca4e 100644 --- a/lib/core/src/lib/dynamic-chip-list/dynamic-chip-list.component.html +++ b/lib/core/src/lib/dynamic-chip-list/dynamic-chip-list.component.html @@ -26,7 +26,7 @@