[ADF-5183] Upgrade to Angular 10 (#1506)

* upgrade preparation fixes

* remove fdescribe

* update browserlist config

* ng8

* ngrx 8

* ng9

* ngrx 9

* remove entryComponents

* unit tests

* ng 10

* latest ADF

* fix unit tests

* fix lint

* update deps and travis

* code fixes

* upgrade webdriver

* cleanup libs

* fix test

* update test

* Use browserTarget as target for lite-serve

* Use the update webdriver with CI condition

* Use version console.log('load', path

* Fix path sh

* Try to use remote env

* Add the . to export variabled

* Use hardcoded chrome version

* Remove the run remote

* Avoid to use the escape

* Skip flaky e2e and raise issue ACA-3615

* SKip failing e2e

* Skip flaky e2e and raise issue ACA-3615

* Fix close app toolbar menu and preconditions + tests of  mark-favorite.test.ts  Personal Files section

* Fix mark-favorite tests

* Fix ext-header test

* Fix new-menu tests

* Fix lint

* no message

* Fix viewer tests

Co-authored-by: maurizio vitale <maurizio.vitale@alfresco.com>
Co-authored-by: Cristina Jalba <cristina.jalba@ness.com>
This commit is contained in:
Denys Vuika 2020-07-09 09:37:06 +01:00 committed by GitHub
parent 4ac1b8d7dd
commit 2854c17cd9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
139 changed files with 11641 additions and 7776 deletions

17
.browserslistrc Normal file
View File

@ -0,0 +1,17 @@
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
# For additional information regarding the format and rule options, please see:
# https://github.com/browserslist/browserslist#queries
# For the full list of supported browsers by the Angular framework, please see:
# https://angular.io/guide/browser-support
# You can see what browsers were selected by your queries by running:
# npx browserslist
last 1 Chrome version
last 1 Firefox version
last 2 Edge major versions
last 2 Safari major version
last 2 iOS major versions
Firefox ESR
not IE 9-11 # For IE 9-11 support, remove 'not'.

View File

@ -1,7 +1,8 @@
dist: trusty
dist: bionic
sudo: required
services:
- docker
- xvfb
addons:
chrome: stable
language: node_js
@ -21,8 +22,6 @@ branches:
before_install:
- sudo /etc/init.d/postgresql stop
- npm install -g npm@latest
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- sleep 3
- . ./scripts/ci/job_hooks/before_install.sh
@ -74,37 +73,37 @@ jobs:
- stage: e2e
name: Test Suite appNavigation&search
before_script:
- ./scripts/ci/job_hooks/before_e2e.sh "$S3_DBP_FOLDER/alfresco-content-app.tar.bz2" "./dist/app"
- ./scripts/ci/job_hooks/before_e2e.sh "$S3_DBP_FOLDER/alfresco-content-app.tar.bz2" "./dist/app" "-a"
- ./start.sh
script: ng run app-e2e:e2elite --suite "authentication,listViews,navigation,application,pagination,search"
after_script: ./start.sh -d
- name: Test Suite actionsAvailable
before_script:
- ./scripts/ci/job_hooks/before_e2e.sh "$S3_DBP_FOLDER/alfresco-content-app.tar.bz2" "./dist/app"
- ./scripts/ci/job_hooks/before_e2e.sh "$S3_DBP_FOLDER/alfresco-content-app.tar.bz2" "./dist/app" "-a"
- ./start.sh
script: ng run app-e2e:e2elite --suite "actionsAvailable"
after_script: ./start.sh -d
- name: Test Suite addRemoveContent
before_script:
- ./scripts/ci/job_hooks/before_e2e.sh "$S3_DBP_FOLDER/alfresco-content-app.tar.bz2" "./dist/app"
- ./scripts/ci/job_hooks/before_e2e.sh "$S3_DBP_FOLDER/alfresco-content-app.tar.bz2" "./dist/app" "-a"
- ./start.sh
script: ng run app-e2e:e2elite --suite "addRemoveContent"
after_script: ./start.sh -d
- name: Test Suite manageContent
before_script:
- ./scripts/ci/job_hooks/before_e2e.sh "$S3_DBP_FOLDER/alfresco-content-app.tar.bz2" "./dist/app"
- ./scripts/ci/job_hooks/before_e2e.sh "$S3_DBP_FOLDER/alfresco-content-app.tar.bz2" "./dist/app" "-a"
- ./start.sh
script: ng run app-e2e:e2elite --suite "manageContent"
after_script: ./start.sh -d
- name: Test Suite sharingContent&markFavorite
before_script:
- ./scripts/ci/job_hooks/before_e2e.sh "$S3_DBP_FOLDER/alfresco-content-app.tar.bz2" "./dist/app"
- ./scripts/ci/job_hooks/before_e2e.sh "$S3_DBP_FOLDER/alfresco-content-app.tar.bz2" "./dist/app" "-a"
- ./start.sh
script: ng run app-e2e:e2elite --suite "sharingContent"
after_script: ./start.sh -d
- name: Test Suite viewContent&metadata&extensions
before_script:
- ./scripts/ci/job_hooks/before_e2e.sh "$S3_DBP_FOLDER/alfresco-content-app.tar.bz2" "./dist/app"
- ./scripts/ci/job_hooks/before_e2e.sh "$S3_DBP_FOLDER/alfresco-content-app.tar.bz2" "./dist/app" "-a"
- ./start.sh
script: ng run app-e2e:e2elite --suite "viewer,infoDrawer,extensions"
after_script: ./start.sh -d

View File

@ -11,6 +11,7 @@
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"aot": true,
"outputPath": "dist/app",
"index": "src/index.html",
"main": "src/main.ts",
@ -85,8 +86,7 @@
"node_modules/pdfjs-dist/build/pdf.js",
"node_modules/pdfjs-dist/web/pdf_viewer.js",
"node_modules/moment/min/moment.min.js"
],
"es5BrowserSupport": true
]
},
"configurations": {
"production": {
@ -117,10 +117,20 @@
"name": "vendor",
"maximumWarning": "10mb",
"maximumError": "15mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb"
}
]
},
"e2e": {
"budgets": [
{
"type": "anyComponentStyle",
"maximumWarning": "6kb"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
@ -160,7 +170,7 @@
"builder": "@angular-custom-builders/lite-serve:dist-serve",
"options": {
"publicHost": "http://localhost:4200",
"outputPath": "dist/app"
"browserTarget": "app:build"
}
},
"extract-i18n": {
@ -285,7 +295,12 @@
"tsConfig": "projects/adf-office-services-ext/tsconfig.lib.json",
"project": "projects/adf-office-services-ext/ng-package.json"
}
},
, "configurations": {
"production": {
"tsConfig": "projects/adf-office-services-ext/tsconfig.lib.prod.json"
}
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
@ -320,7 +335,12 @@
"tsConfig": "projects/aca-shared/tsconfig.lib.json",
"project": "projects/aca-shared/ng-package.json"
}
},
, "configurations": {
"production": {
"tsConfig": "projects/aca-shared/tsconfig.lib.prod.json"
}
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
@ -354,7 +374,7 @@
"schematics": {
"@schematics/angular:component": {
"prefix": "aca",
"styleext": "scss"
"style": "scss"
},
"@schematics/angular:directive": {
"prefix": "aca"

View File

@ -51,7 +51,6 @@
"polyfill",
"polyfills",
"jsonp",
"hammerjs",
"pdfjs",
"xpath",
"tooltip",

View File

@ -54,7 +54,6 @@ import { EXTENSION_DATA_LOADERS } from '@alfresco/aca-shared';
@NgModule({
imports: [...],
declarations: [...],
entryComponents: [...],
providers: [
...
{

View File

@ -39,18 +39,6 @@ Angular CLI automatically configures Typescript path mappings for the project, s
### Register dynamic components
Update `my-extension.module.ts` and put all the content you plan to use at runtime dynamically to the `entryComponents` section of the module.
```typescript
@NgModule({
imports: [],
declarations: [MyExtensionComponent],
exports: [MyExtensionComponent],
entryComponents: [MyExtensionComponent]
})
export class MyExtensionModule {}
```
Now we need to register `MyExtensionComponent` as an extension component.
Update the code as in the next example:

View File

@ -18,8 +18,7 @@ import { ExtensionsModule, ExtensionService } from '@alfresco/adf-extensions';
@NgModule({
imports: [ ExtensionsModule ]
declarations: [ MyComponent1, MyLayout ],
entryComponents: [ MyComponent1, MyLayout ]
declarations: [ MyComponent1, MyLayout ]
})
export class MyExtensionModule {
@ -42,8 +41,5 @@ export class MyExtensionModule {
}
```
**Note:** According to Angular rules, all components that are created dynamically at runtime
need to be registered within the `entryComponents` section of the NgModule.
The Registration API is not limited to the custom content only.
You can replace any existing entries by replacing the values from your module.

View File

@ -139,24 +139,6 @@ Please read more details on Dialog components here: [Dialog Overview](https://ma
ng g component dialogs/my-extension-dialog --module=app
```
According to Angular rules, the component needs to also be registered within the `entryComponents` section of the module.
Update the `src/app/app.module.ts` file according to the example below:
```ts
@NgModule({
imports: [...],
declarations: [
...,
MyExtensionDialogComponent
],
entryComponents: [
...,
MyExtensionDialogComponent
]
})
```
Update `my-extension-dialog.component.ts`:
```ts

View File

@ -236,6 +236,4 @@ Navigation items or group of navigation items can be conditional render based on
For more informations about rules checkout [Rules](../extending/rules.md) section.
Note that components must be declared as entryComponents under the app module.
For more information about the content of a custom page see [Document List Layout](/features/document-list-layout) section.

View File

@ -40,18 +40,6 @@ Angular CLI は、プロジェクトの Typescript パスマッピングを自
### 動的コンポーネントを登録する
`my-extension.module.ts` を更新し、実行時に動的に使用する予定のすべてのコンテンツをモジュールの `entryComponents` セクションに配置します。
```typescript
@NgModule({
imports: [],
declarations: [MyExtensionComponent],
exports: [MyExtensionComponent],
entryComponents: [MyExtensionComponent]
})
export class MyExtensionModule {}
```
ここで、`MyExtensionComponent` を拡張コンポーネントとして登録する必要があります。
次の例のようにコードを更新します:

View File

@ -19,8 +19,7 @@ import { ExtensionsModule, ExtensionService } from '@alfresco/adf-extensions';
@NgModule({
imports: [ ExtensionsModule ]
declarations: [ MyComponent1, MyLayout ],
entryComponents: [ MyComponent1, MyLayout ]
declarations: [ MyComponent1, MyLayout ]
})
export class MyExtensionModule {
@ -43,8 +42,5 @@ export class MyExtensionModule {
}
```
**注:** Angular のルールによれば、実行時に動的に作成されるすべてのコンポーネントは、
NgModule の `entryComponents` セクション内に登録する必要があります。
Registration API は、カスタムコンテンツのみに限定されません。
モジュールの値を置き換えることにより、既存のエントリを置き換えることができます。

View File

@ -140,24 +140,6 @@ node: 10
ng g component dialogs/my-extension-dialog --module=app
```
Angular ルールに従って、コンポーネントはモジュールの `entryComponents` セクション内にも登録する必要があります。
以下の例に従って `src/app/app.module.ts` ファイルを更新します:
```ts
@NgModule({
imports: [...],
declarations: [
...,
MyExtensionDialogComponent
],
entryComponents: [
...,
MyExtensionDialogComponent
]
})
```
`my-extension-dialog.component.ts` を更新します:
```ts

View File

@ -209,6 +209,4 @@ export class CustomPage {
]
```
コンポーネントは app モジュールの下で entryComponents として宣言する必要があることに注意してください。
カスタムページのコンテンツの詳細については、[ドキュメントリストのレイアウト](/ja/features/document-list-layout) セクションを参照してください。

View File

@ -15,8 +15,6 @@ nav: ja
ng g component dialogs/my-extension-dialog --module=app
```
Angular ルールに従って、コンポーネントはモジュールの `entryComponents` セクション内にも登録する必要があります。
以下の例に従って `src/app/app.module.ts` ファイルを更新します:
```ts
@ -25,10 +23,6 @@ Angular ルールに従って、コンポーネントはモジュールの `entr
declarations: [
...,
MyExtensionDialogComponent
],
entryComponents: [
...,
MyExtensionDialogComponent
]
})
```

View File

@ -14,24 +14,6 @@ Please read more details on Dialog components here: [Dialog Overview](https://ma
ng g component dialogs/my-extension-dialog --module=app
```
According to Angular rules, the component needs to also be registered within the `entryComponents` section of the module.
Update the `src/app/app.module.ts` file according to the example below:
```ts
@NgModule({
imports: [...],
declarations: [
...,
MyExtensionDialogComponent
],
entryComponents: [
...,
MyExtensionDialogComponent
]
})
```
Update `my-extension-dialog.component.ts`:
```ts

View File

@ -23,7 +23,7 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { BrowsingPage, SearchResultsPage, Utils } from '@alfresco/aca-testing-shared';
import { BrowsingPage, SearchResultsPage } from '@alfresco/aca-testing-shared';
import * as testData from './test-data';
import * as testUtil from '../test-util';
@ -39,14 +39,6 @@ export function viewerTests(parentName?: string) {
await page.clickPersonalFiles();
});
beforeEach(async () => {
await Utils.pressEscape();
});
afterEach(async () => {
await page.closeOpenDialogs();
});
describe('file opened from Personal Files', () => {
beforeAll(async () => {

View File

@ -117,7 +117,6 @@ export async function checkViewerActions(item: string, expectedToolbarPrimary: s
const actualMoreActions = await viewerToolbar.menu.getMenuItems();
expect(actualMoreActions).toEqual(expectedToolbarMore);
await toolbar.closeMoreMenu();
await Utils.pressEscape();
}

View File

@ -100,13 +100,15 @@ describe('Mark items as favorites', () => {
fileSearchFav4Id = (await apis.user.nodes.createFile(fileSearchFav4, parentId)).entry.id;
folderSearchId = (await apis.user.nodes.createFolder(folderSearch, parentId)).entry.id;
const currentFavoritesFiles = (await apis.user.favorites.getFavorites()).list.pagination.totalItems;
await apis.user.favorites.addFavoritesByIds('file', [ fileFavUIId, fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id ]);
await apis.user.favorites.addFavoritesByIds('file', [ fileSearchFav1Id, fileSearchFav2Id, fileSearchFav3Id, fileSearchFav4Id ]);
await apis.user.favorites.waitForApi({ expect: 9 });
await apis.user.favorites.waitForApi({ expect: currentFavoritesFiles + 9 });
const currentSharedFiles = (await apis.user.shared.getSharedLinks()).list.pagination.totalItems;
await apis.user.shared.shareFilesByIds([ fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id ]);
await apis.user.shared.shareFilesByIds([ fileNotFav1Id, fileNotFav2Id, fileNotFav3Id, fileNotFav4Id ]);
await apis.user.shared.waitForApi({ expect: 8 });
await apis.user.shared.waitForApi({ expect: currentSharedFiles + 8 });
await loginPage.loginWith(username);
done();
@ -135,7 +137,6 @@ describe('Mark items as favorites', () => {
});
beforeEach(async (done) => {
await Utils.pressEscape();
await page.clickPersonalFilesAndWait();
await dataTable.doubleClickOnRowByName(parent);
done();
@ -146,6 +147,7 @@ describe('Mark items as favorites', () => {
await toolbar.openMoreMenu();
expect(await toolbar.menu.getItemIconText('Favorite')).toEqual('star_border');
await toolbar.closeMoreMenu();
});
it('[C217187] Favorite action has empty star icon for multiple selection of items when some are not favorite', async () => {
@ -153,6 +155,7 @@ describe('Mark items as favorites', () => {
await toolbar.openMoreMenu();
expect(await toolbar.menu.getItemIconText('Favorite')).toEqual('star_border');
await toolbar.closeMoreMenu();
});
it('[C217188] Favorite action has full star icon for items marked as favorite', async () => {
@ -160,6 +163,7 @@ describe('Mark items as favorites', () => {
await toolbar.openMoreMenu();
expect(await toolbar.menu.getItemIconText('Remove Favorite')).toEqual('star');
await toolbar.closeMoreMenu();
});
it('[C217189] favorite a file', async () => {
@ -211,9 +215,10 @@ describe('Mark items as favorites', () => {
describe('on Recent Files', () => {
afterAll(async (done) => {
try {
const currentFavoritesFiles = (await apis.user.favorites.getFavorites()).list.pagination.totalItems;
await apis.user.favorites.addFavoritesByIds('file', [ fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id ]);
await apis.user.favorites.removeFavoritesByIds([ fileNotFav1Id, fileNotFav2Id, fileNotFav3Id, fileNotFav4Id ]);
await apis.user.favorites.waitForApi({ expect: 10 });
await apis.user.favorites.waitForApi({ expect: currentFavoritesFiles - 1 });
} catch (error) {
}
done();
@ -360,6 +365,7 @@ describe('Mark items as favorites', () => {
await toolbar.openMoreMenu();
expect(await toolbar.menu.getItemIconText('Remove Favorite')).toEqual('star');
await toolbar.closeMoreMenu();
});
});
@ -373,11 +379,6 @@ describe('Mark items as favorites', () => {
done();
});
beforeEach(async (done) => {
await Utils.pressEscape();
done();
});
afterAll(async done => {
await page.header.expandSideNav();
await page.clickPersonalFiles();

View File

@ -65,7 +65,7 @@ describe('New menu', () => {
});
afterEach(async (done) => {
await Utils.pressEscape();
await sidenav.closeNewMenu();
done();
});
@ -98,7 +98,7 @@ describe('New menu', () => {
expect(await menu.isCreateFolderFromTemplateEnabled()).toBe(true, 'Create folder from template is not enabled');
});
it('[C280397] Actions in File Libraries - user without enough permissions', async () => {
xit('[C280397] Actions in File Libraries - user without enough permissions', async () => {
await page.goToMyLibrariesAndWait();
await dataTable.doubleClickOnRowByName(siteAdmin);
await sidenav.openNewMenu();
@ -113,7 +113,7 @@ describe('New menu', () => {
expect(await menu.isCreateFolderFromTemplateEnabled()).toBe(false, 'Create folder from template is not disabled');
});
it('[C216342] Enabled actions tooltips', async () => {
xit('[C216342] Enabled actions tooltips', async () => {
await page.clickPersonalFiles();
await sidenav.openNewMenu();

View File

@ -67,8 +67,8 @@ describe('Extensions - Info Drawer', () => {
done();
});
beforeEach(async (done) => {
await Utils.pressEscape();
afterEach(async (done) => {
await header.closeMoreMenu();
done();
});

View File

@ -10,8 +10,12 @@
"jasminewd2",
"node"
],
"skipLibCheck": true,
"paths": {
"@alfresco/aca-testing-shared": ["../projects/aca-testing-shared"]
}
}
},
"exclude": [
"node_modules"
]
}

View File

@ -1,6 +1,6 @@
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
process.env.CHROME_BIN = require('puppeteer').executablePath();
// process.env.CHROME_BIN = require('puppeteer').executablePath();
module.exports = function(config) {
config.set({
@ -14,7 +14,6 @@ module.exports = function(config) {
require('@angular-devkit/build-angular/plugins/karma')
],
files: [
{ pattern: './node_modules/hammerjs/hammer.js', watched: false },
{
pattern:
'./node_modules/@angular/material/prebuilt-themes/indigo-pink.css',
@ -61,7 +60,7 @@ module.exports = function(config) {
base: 'Chrome',
flags: [
'--no-sandbox',
'--headless',
// '--headless',
'--disable-gpu',
'--remote-debugging-port=9222'
]

18053
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -4,6 +4,7 @@
"commit": "",
"license": "LGPL-3.0",
"scripts": {
"postinstall": "ngcc",
"ng": "ng",
"start": "npm run validate-config && ng serve --open",
"start:prod": "npm run validate-config && node --max-old-space-size=8192 node_modules/@angular/cli/bin/ng serve --prod --open",
@ -20,7 +21,7 @@
"update-webdriver": "./scripts/update-webdriver.sh",
"e2e.typecheck": "tsc -p ./e2e/tsconfig.e2e.typecheck.json",
"e2e": "npm run update-webdriver && protractor --baseUrl=${TEST_BASE_URL:-http://localhost:8080/content-app} $SUITE",
"e2e.local": "protractor --baseUrl=http://localhost:4200 $SUITE",
"e2e.local": "npm run update-webdriver && protractor --baseUrl=http://localhost:4200",
"wait:app": "wait-on http://${HOST_IP:-localhost}:${HOST_PORT:-8080}/alfresco/ -t 1000000",
"start:docker": "./start.sh",
"stop:docker": "./start.sh -d",
@ -31,92 +32,83 @@
},
"private": true,
"dependencies": {
"@alfresco/adf-content-services": "3.9.0",
"@alfresco/adf-core": "3.9.0",
"@alfresco/adf-extensions": "3.9.0",
"@alfresco/js-api": "3.9.0",
"@angular-custom-builders/lite-serve": "0.0.2",
"@angular/animations": "7.2.15",
"@angular/cdk": "^7.3.7",
"@angular/common": "7.2.15",
"@angular/compiler": "7.2.15",
"@angular/core": "7.2.15",
"@angular/flex-layout": "^7.0.0-beta.24",
"@angular/forms": "7.2.15",
"@angular/material": "^7.3.7",
"@angular/material-moment-adapter": "^7.3.7",
"@angular/platform-browser": "7.2.15",
"@angular/platform-browser-dynamic": "7.2.15",
"@angular/router": "7.2.15",
"@mat-datetimepicker/core": "3.1.0",
"@mat-datetimepicker/moment": "3.1.0",
"@ngrx/effects": "^7.4.0",
"@ngrx/router-store": "^7.4.0",
"@ngrx/store": "^7.4.0",
"@ngrx/store-devtools": "^7.4.0",
"@ngx-translate/core": "^11.0.1",
"@alfresco/adf-content-services": "3.10.0-6001ff801e211e8385966d2f2b773e59b4667dd9",
"@alfresco/adf-core": "3.10.0-6001ff801e211e8385966d2f2b773e59b4667dd9",
"@alfresco/adf-extensions": "3.10.0-6001ff801e211e8385966d2f2b773e59b4667dd9",
"@alfresco/js-api": "3.10.0-1deb4e85760f96f550a7d6d894e4002ecd4a4c18",
"@angular-custom-builders/lite-serve": "0.2.0",
"@angular/animations": "10.0.2",
"@angular/cdk": "^10.0.1",
"@angular/common": "10.0.2",
"@angular/compiler": "10.0.2",
"@angular/core": "10.0.2",
"@angular/flex-layout": "^10.0.0-beta.32",
"@angular/forms": "10.0.2",
"@angular/material": "^10.0.1",
"@angular/material-moment-adapter": "^10.0.1",
"@angular/platform-browser": "10.0.2",
"@angular/platform-browser-dynamic": "10.0.2",
"@angular/router": "10.0.2",
"@mat-datetimepicker/core": "4.1.0",
"@mat-datetimepicker/moment": "4.1.0",
"@ngrx/effects": "^9.2.0",
"@ngrx/router-store": "^9.2.0",
"@ngrx/store": "^9.2.0",
"@ngrx/store-devtools": "^9.2.0",
"@ngx-translate/core": "^13.0.0",
"browser-sync": "^2.26.7",
"core-js": "^2.5.7",
"hammerjs": "2.0.8",
"minimatch-browser": "^1.0.0",
"moment": "^2.24.0",
"moment": "^2.27.0",
"moment-es6": "1.0.0",
"pdfjs-dist": "2.3.200",
"rxjs": "^6.5.5",
"tsickle": "0.34.0",
"zone.js": "0.8.29"
"rxjs": "^6.6.0",
"tslib": "^2.0.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@alfresco/adf-cli": "3.9.0",
"@alfresco/adf-testing": "3.9.0",
"@angular-devkit/build-angular": "~0.13.9",
"@angular-devkit/build-ng-packagr": "^0.13.10",
"@angular/cli": "^7.3.9",
"@angular/compiler-cli": "7.2.15",
"@angular/language-service": "7.2.15",
"@types/jasmine": "3.5.10",
"@alfresco/adf-cli": "3.10.0-6001ff801e211e8385966d2f2b773e59b4667dd9",
"@alfresco/adf-testing": "3.10.0-6001ff801e211e8385966d2f2b773e59b4667dd9",
"@angular-devkit/build-angular": "~0.1000.1",
"@angular-devkit/build-ng-packagr": "~0.1000.1",
"@angular/cli": "^10.0.1",
"@angular/compiler-cli": "10.0.2",
"@angular/language-service": "10.0.2",
"@types/jasmine": "3.5.11",
"@types/jasminewd2": "^2.0.8",
"@types/node": "^13.11.0",
"@types/node": "^14.0.14",
"@types/selenium-webdriver": "^4.0.9",
"adf-tslint-rules": "0.0.7",
"ajv-cli": "^3.1.0",
"chrome-remote-interface": "^0.26.1",
"codelyzer": "^5.2.2",
"codelyzer": "^6.0.0",
"commander": "^5.0.0",
"cpr": "^3.0.1",
"cspell": "^4.0.55",
"dotenv": "^8.2.0",
"husky": "^4.2.3",
"jasmine-core": "~2.8.0",
"jasmine-reporters": "^2.2.1",
"jasmine-spec-reporter": "~4.2.1",
"jasminewd2": "^2.2.0",
"karma": "^4.4.1",
"karma": "^5.1.0",
"karma-chrome-launcher": "^3.1.0",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^2.0.4",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"lint-staged": "^10.1.2",
"ng-packagr": "^4.7.1",
"node-sass": "^4.14.1",
"karma-coverage-istanbul-reporter": "^3.0.3",
"karma-jasmine": "^3.3.1",
"karma-jasmine-html-reporter": "^1.5.4",
"lint-staged": "^10.2.11",
"ng-packagr": "^10.0.0",
"node-stream-zip": "^1.9.1",
"prettier": "^1.17.1",
"protractor": "5.4.2",
"protractor": "^7.0.0",
"protractor-screenshoter-plugin": "0.10.3",
"puppeteer": "2.1.1",
"rxjs-tslint": "^0.1.8",
"rxjs-tslint-rules": "^4.30.1",
"selenium-webdriver": "4.0.0-alpha.1",
"selenium-webdriver": "^4.0.0-alpha.7",
"ts-node": "^8.0.3",
"tsconfig-paths": "3.9.0",
"tsickle": ">=0.34.0",
"tslib": "^1.11.1",
"tslint": "^5.20.1",
"tslint-config-prettier": "^1.18.0",
"tslint-plugin-prettier": "^2.3.0",
"typescript": "3.2.4",
"wait-on": "^4.0.1",
"typescript": "3.9.6",
"wait-on": "^5.0.1",
"webdriver-manager": "12.1.7"
},
"lint-staged": {
@ -131,6 +123,6 @@
}
},
"config": {
"chromeDriver": "80.0.3987.0"
"chromeDriver": "83.0.4103.116"
}
}

View File

@ -375,9 +375,9 @@ export function isWriteLocked(context: RuleContext): boolean {
export function isUserWriteLockOwner(context: RuleContext): boolean {
return (
isWriteLocked(context) &&
(context.selection.file.entry.properties['cm:lockOwner'] &&
context.selection.file.entry.properties['cm:lockOwner'].id ===
context.profile.id)
context.selection.file.entry.properties['cm:lockOwner'] &&
context.selection.file.entry.properties['cm:lockOwner'].id ===
context.profile.id
);
}

View File

@ -74,8 +74,8 @@ describe('InfoDrawerComponent', () => {
fixture = TestBed.createComponent(InfoDrawerComponent);
component = fixture.componentInstance;
appExtensionService = TestBed.get(AppExtensionService);
contentApiService = TestBed.get(ContentApiService);
appExtensionService = TestBed.inject(AppExtensionService);
contentApiService = TestBed.inject(ContentApiService);
tab = { title: 'tab1' };
spyOn(appExtensionService, 'getSidebarTabs').and.returnValue([tab]);

View File

@ -28,7 +28,7 @@ import { CommonModule } from '@angular/common';
import { InfoDrawerComponent } from './info-drawer.component';
import { InfoDrawerModule, ToolbarModule } from '@alfresco/adf-core';
import { ExtensionsModule } from '@alfresco/adf-extensions';
import { MatProgressBarModule } from '@angular/material';
import { MatProgressBarModule } from '@angular/material/progress-bar';
import { SharedToolbarModule } from '../tool-bar/shared-toolbar.module';
@NgModule({

View File

@ -38,12 +38,13 @@ describe('ContextActionsDirective', () => {
directive = new ContextActionsDirective(storeMock);
});
it('should not render context menu when `enabled` property is false', () => {
it('should not render context menu when `enabled` property is false', fakeAsync(() => {
spyOn(directive, 'execute').and.stub();
directive.enabled = false;
directive.onContextMenuEvent(new MouseEvent('contextmenu'));
expect(storeMock.dispatch).not.toHaveBeenCalled();
});
expect(directive.execute).not.toHaveBeenCalled();
}));
it('should call service to render context menu', fakeAsync(() => {
const el = document.createElement('div');

View File

@ -65,10 +65,7 @@ export class ContextActionsDirective implements OnInit, OnDestroy {
ngOnInit() {
this.execute$
.pipe(
debounceTime(300),
takeUntil(this.onDestroy$)
)
.pipe(debounceTime(300), takeUntil(this.onDestroy$))
.subscribe((event: MouseEvent) => {
this.store.dispatch(new ContextMenu(event));
});

View File

@ -58,8 +58,8 @@ describe('PaginationDirective', () => {
]
});
preferences = TestBed.get(UserPreferencesService);
config = TestBed.get(AppConfigService);
preferences = TestBed.inject(UserPreferencesService);
config = TestBed.inject(AppConfigService);
fixture = TestBed.createComponent(PaginationComponent);
pagination = fixture.componentInstance;
directive = new PaginationDirective(pagination, preferences, config);

View File

@ -34,7 +34,7 @@ describe('AppRouteReuseStrategy', () => {
providers: [AppRouteReuseStrategy]
});
appRouteReuse = TestBed.get(AppRouteReuseStrategy);
appRouteReuse = TestBed.inject(AppRouteReuseStrategy);
});
it('should allow detach if route is configured to be reused', () => {

View File

@ -28,7 +28,7 @@ import {
DetachedRouteHandle,
ActivatedRouteSnapshot
} from '@angular/router';
import { ComponentRef } from '@angular/core';
import { ComponentRef, Injectable } from '@angular/core';
interface RouteData {
reuse: boolean;
@ -39,6 +39,7 @@ interface RouteInfo {
data: RouteData;
}
@Injectable()
export class AppRouteReuseStrategy implements RouteReuseStrategy {
private routeCache = new Map<string, RouteInfo>();

View File

@ -54,11 +54,11 @@ describe('AppExtensionService', () => {
imports: [LibTestingModule]
});
appConfigService = TestBed.get(AppConfigService);
store = TestBed.get(Store);
service = TestBed.get(AppExtensionService);
extensions = TestBed.get(ExtensionService);
components = TestBed.get(ComponentRegisterService);
appConfigService = TestBed.inject(AppConfigService);
store = TestBed.inject(Store);
service = TestBed.inject(AppExtensionService);
extensions = TestBed.inject(ExtensionService);
components = TestBed.inject(ComponentRegisterService);
});
const applyConfig = (config: ExtensionConfig) => {

View File

@ -54,10 +54,10 @@ describe('AppService', () => {
]
});
routeReuse = TestBed.get(AppRouteReuseStrategy);
auth = TestBed.get(AuthenticationService);
appConfig = TestBed.get(AppConfigService);
searchQueryBuilderService = TestBed.get(SearchQueryBuilderService);
routeReuse = TestBed.inject(AppRouteReuseStrategy);
auth = TestBed.inject(AuthenticationService);
appConfig = TestBed.inject(AppConfigService);
searchQueryBuilderService = TestBed.inject(SearchQueryBuilderService);
spyOn(routeReuse, 'resetCache').and.stub();

View File

@ -34,7 +34,7 @@ import { ContextActionsModule } from './directives/contextmenu/contextmenu.modul
exports: [ContextActionsModule]
})
export class SharedModule {
static forRoot(): ModuleWithProviders {
static forRoot(): ModuleWithProviders<SharedModule> {
return {
ngModule: SharedModule,
providers: [ContentApiService, NodePermissionService, AppService]

View File

@ -33,15 +33,8 @@ export const getHeaderColor = createSelector(
state => state.headerColor
);
export const getAppName = createSelector(
selectApp,
state => state.appName
);
export const getLogoPath = createSelector(
selectApp,
state => state.logoPath
);
export const getAppName = createSelector(selectApp, state => state.appName);
export const getLogoPath = createSelector(selectApp, state => state.logoPath);
export const getHeaderImagePath = createSelector(
selectApp,
@ -53,10 +46,7 @@ export const getLanguagePickerState = createSelector(
state => state.languagePicker
);
export const getUserProfile = createSelector(
selectApp,
state => state.user
);
export const getUserProfile = createSelector(selectApp, state => state.user);
export const getCurrentFolder = createSelector(
selectApp,
@ -68,10 +58,7 @@ export const getAppSelection = createSelector(
state => state.selection
);
export const getSharedUrl = createSelector(
selectApp,
state => state.sharedUrl
);
export const getSharedUrl = createSelector(selectApp, state => state.sharedUrl);
export const getNavigationState = createSelector(
selectApp,
@ -103,10 +90,7 @@ export const isQuickShareEnabled = createSelector(
info => info.status.isQuickShareEnabled
);
export const isAdmin = createSelector(
selectApp,
state => state.user.isAdmin
);
export const isAdmin = createSelector(selectApp, state => state.user.isAdmin);
export const getSideNavState = createSelector(
getAppSelection,

View File

@ -25,7 +25,6 @@
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
import 'core-js/es7/reflect';
import 'zone.js/dist/zone';
import 'zone.js/dist/zone-testing';
import { getTestBed } from '@angular/core/testing';

View File

@ -18,7 +18,6 @@
}
},
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"skipTemplateCodegen": true,
"strictMetadataEmit": true,
"fullTemplateTypeCheck": true,

View File

@ -0,0 +1,6 @@
{
"extends": "./tsconfig.lib.json",
"angularCompilerOptions": {
"enableIvy": false
}
}

View File

@ -30,6 +30,7 @@ import { Menu } from '../menu/menu';
import { Toolbar } from './../toolbar/toolbar';
import { SearchInput } from '../search/search-input';
import { waitElement } from '../../utilities/utils';
import { BrowserActions } from '@alfresco/adf-testing';
export class Header extends Component {
logoLink = this.byCss('.app-menu__title');
@ -50,6 +51,11 @@ export class Header extends Component {
await this.menu.waitForMenuToOpen();
}
async closeMoreMenu(): Promise<void> {
await BrowserActions.click(this.moreActions);
await this.menu.waitForMenuToClose();
}
async isSignOutDisplayed(): Promise<boolean> {
return this.userInfo.menu.isMenuItemPresent('Sign out');
}

View File

@ -24,7 +24,7 @@
*/
import { ElementFinder, by, element, browser } from 'protractor';
import { Logger } from '@alfresco/adf-testing';
import { Logger, BrowserActions } from '@alfresco/adf-testing';
import { SIDEBAR_LABELS, BROWSER_WAIT_TIMEOUT } from '../../configs';
import { Menu } from '../menu/menu';
import { Component } from '../component';
@ -79,6 +79,13 @@ export class Sidenav extends Component {
await this.menu.waitForMenuToOpen();
}
async closeNewMenu(): Promise<void> {
await BrowserActions.click(
element(by.css('button[data-automation-id="create-button"] span span'))
);
await this.menu.waitForMenuToClose();
}
async openCreateFolderDialog(): Promise<void> {
await this.openNewMenu();
await this.menu.createFolderAction.click();

View File

@ -92,7 +92,16 @@ export class Toolbar extends Component {
await this.menu.waitForMenuToOpen();
}
async closeMoreMenu() {
async closeMoreMenu(): Promise<void> {
await this.isButtonPresent('More Actions');
const moreMenu = this.getButtonByTitleAttribute('More Actions');
await BrowserActions.click(moreMenu);
await this.menu.waitForMenuToClose();
}
async closeMoreMenuEscape() {
await Utils.pressEscape();
}

View File

@ -53,7 +53,7 @@ export abstract class Page {
}
async load(relativeUrl: string = '') {
const hash = USE_HASH_STRATEGY ? '/#' : '';
const hash = USE_HASH_STRATEGY ? '#' : '';
const path = `${browser.baseUrl}${hash}${this.url}${relativeUrl}`;
return browser.get(path);
}

View File

@ -147,9 +147,9 @@ export class AdminActions {
// folder links are deleted automatically when original folder is deleted
// Software Engineering Project is the default folder template coming from ACS, should not be deleted
const nodesToDelete = (await this.adminApi.nodes.getNodeChildren(
spaceTemplatesNodeId
)).list.entries
const nodesToDelete = (
await this.adminApi.nodes.getNodeChildren(spaceTemplatesNodeId)
).list.entries
.filter(
node =>
node.entry.nodeType !== 'app:folderlink' &&

View File

@ -69,14 +69,12 @@ export function flattenNodeContentTree(
if (folders) {
const foldersData: NodeBodyCreate[] = folders
.map(
(folder: string | NodeContentTree): NodeBodyCreate[] => {
const folderData: NodeContentTree =
typeof folder === 'string' ? { name: folder } : folder;
.map((folder: string | NodeContentTree): NodeBodyCreate[] => {
const folderData: NodeContentTree =
typeof folder === 'string' ? { name: folder } : folder;
return flattenNodeContentTree(folderData, relativePath);
}
)
return flattenNodeContentTree(folderData, relativePath);
})
.reduce(
(nodesData: NodeBodyCreate[], folderData: NodeBodyCreate[]) =>
nodesData.concat(folderData),

View File

@ -328,9 +328,9 @@ export class SitesApi extends RepoApi {
async hasMembershipRequest(siteId: string) {
try {
await this.apiAuth();
const requests = (await this.sitesApi.getSiteMembershipRequests(
'-me-'
)).list.entries.map(e => e.entry.id);
const requests = (
await this.sitesApi.getSiteMembershipRequests('-me-')
).list.entries.map(e => e.entry.id);
return requests.includes(siteId);
} catch (error) {
this.handleError(

View File

@ -179,9 +179,7 @@ export class Utils {
static async setSessionStorageFromConfig(
configFileName: string
): Promise<void> {
const configFile = `${
browser.params.e2eRootPath
}/resources/extensibility-configs/${configFileName}`;
const configFile = `${browser.params.e2eRootPath}/resources/extensibility-configs/${configFileName}`;
const fileContent = JSON.stringify(
fs.readFileSync(configFile, { encoding: 'utf8' })
);

View File

@ -18,7 +18,6 @@
]
},
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"skipTemplateCodegen": true,
"strictMetadataEmit": true,
"fullTemplateTypeCheck": true,

View File

@ -25,7 +25,6 @@
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
import 'core-js/es7/reflect';
import 'zone.js/dist/zone';
import 'zone.js/dist/zone-testing';
import { getTestBed } from '@angular/core/testing';

View File

@ -18,7 +18,6 @@
]
},
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"skipTemplateCodegen": true,
"strictMetadataEmit": true,
"fullTemplateTypeCheck": true,

View File

@ -0,0 +1,6 @@
{
"extends": "./tsconfig.lib.json",
"angularCompilerOptions": {
"enableIvy": false
}
}

View File

@ -3,9 +3,9 @@
const path = require('path');
const { SpecReporter } = require('jasmine-spec-reporter');
const jasmineReporters = require('jasmine-reporters');
const CDP = require('chrome-remote-interface');
const fs = require('fs');
require('dotenv').config();
const projectRoot = path.resolve(__dirname);
const downloadFolder = `${projectRoot}/e2e-downloads`;
@ -108,7 +108,7 @@ exports.config = {
capabilities: {
browserName: 'chrome',
chromeOptions: {
binary: require('puppeteer').executablePath(),
// binary: require('puppeteer').executablePath(),
prefs: {
credentials_enable_service: false,
download: {
@ -186,17 +186,6 @@ exports.config = {
})
);
jasmine.getEnv().addReporter(
new jasmineReporters.JUnitXmlReporter({
consolidateAll: true,
savePath: `${projectRoot}/e2e-output/junit-report`,
filePrefix: 'results.xml',
useDotNotation: false,
useFullTestName: false,
reportFailedUrl: true
})
);
rmDir(downloadFolder);
CDP()

View File

@ -49,6 +49,6 @@ fs.readFile(program.config, (err, appConfigString) => {
}
});
let appConfigReplacedJson = JSON.stringify(appConfig);
let appConfigReplacedJson = JSON.stringify(appConfig, null, 4);
fs.writeFileSync(program.config, appConfigReplacedJson);
});

View File

@ -2,8 +2,15 @@
FROM=$1;
TO=$2;
PARAMS=$3;
echo "Download artefact from S3 $FROM"
./scripts/ci/utils/artifact-from-s3.sh -a "$FROM" -o "$TO"
node "./scripts/app-config-replace.js" --config="$TO/app.config.json" -a
echo "Download artefact done"
npm run update-webdriver
echo "Replace app.config with options $PARAMS"
node "./scripts/app-config-replace.js" --config="$TO/app.config.json" $PARAMS
echo "Replace app.config done"
echo "Update update-webdriver"
npm run update-webdriver

View File

@ -27,6 +27,4 @@ fi
echo "BASE_HASH: $BASE_HASH"
echo "S3 DBP destination: $S3_DBP_FOLDER"
export DISPLAY=:99.0
sh -e /etc/init.d/xvfb start
sleep 3 # give xvfb some time to start

View File

@ -24,5 +24,8 @@ fi
test ! -d $OUTPUT && mkdir -p $OUTPUT
aws s3 cp $ARTIFACT ./s3-artifact.tmp
tar -xvf ./s3-artifact.tmp -C $OUTPUT
echo 'artifact download done'
tar -xvf ./s3-artifact.tmp -C $OUTPUT >&/dev/null
echo 'tar the artifact done'
rm ./s3-artifact.tmp
echo 'remove tmp file'

View File

@ -3,8 +3,8 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [ "$CI" = "true" ]; then
echo "Updating wedriver-manager with chromedriver: $npm_package_config_chromeDriver."
webdriver-manager update --gecko=false --versions.chrome=$npm_package_config_chromeDriver
./node_modules/protractor/bin/webdriver-manager update --gecko=false --versions.chrome=83.0.4103.116
else
echo "Updating wedriver-manager with latest chromedriver, be sure to use evergreen Chrome."
webdriver-manager update --gecko=false
./node_modules/protractor/bin/webdriver-manager update --gecko=false
fi

View File

@ -56,14 +56,14 @@ describe('AppComponent', () => {
}
};
beforeAll(() => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
RouterTestingModule.withRoutes([{ path: 'fake-path', children: [] }])
]
});
router = TestBed.get(Router);
router = TestBed.inject(Router);
component = new AppComponent(
null,
@ -80,9 +80,7 @@ describe('AppComponent', () => {
null,
storageMock
);
});
beforeEach(() => {
storeMock.dispatch = jasmine.createSpy('dispatch');
});
@ -144,6 +142,7 @@ describe('AppComponent', () => {
describe('Routing Configuration', () => {
it('Should extension route be included as child of the defined parent path', () => {
component.mapExtensionRoutes(mockRoutesWithParentRoute);
expect(router.config[0]).toEqual({
path: 'fake-path',
children: [

View File

@ -23,7 +23,7 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { BrowserModule } from '@angular/platform-browser';
import { BrowserModule, HammerModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { RouterModule, RouteReuseStrategy } from '@angular/router';
import {
@ -37,10 +37,7 @@ import {
AppConfigService,
DebugAppConfigService
} from '@alfresco/adf-core';
import {
LibraryDialogComponent,
ContentModule
} from '@alfresco/adf-content-services';
import { ContentModule } from '@alfresco/adf-content-services';
import { AppRouteReuseStrategy, SharedModule } from '@alfresco/aca-shared';
import { AppComponent } from './app.component';
@ -50,7 +47,6 @@ import { FilesComponent } from './components/files/files.component';
import { LibrariesComponent } from './components/libraries/libraries.component';
import { FavoriteLibrariesComponent } from './components/favorite-libraries/favorite-libraries.component';
import { NodeVersionsDialogComponent } from './dialogs/node-versions/node-versions.dialog';
import { CurrentUserComponent } from './components/current-user/current-user.component';
import { AppStoreModule } from './store/app-store.module';
import { MaterialModule } from './material.module';
@ -130,7 +126,7 @@ registerLocaleData(localeSv);
SharedModule.forRoot(),
AppStoreModule,
CoreExtensionsModule.forRoot(),
ExtensionsModule,
ExtensionsModule.forRoot(),
AppExtensionsModule,
AppLoginModule,
AppCommonModule,
@ -147,7 +143,8 @@ registerLocaleData(localeSv);
AppSearchInputModule,
AppSearchResultsModule,
AppHeaderModule,
AppNodeVersionModule
AppNodeVersionModule,
HammerModule
],
declarations: [
AppComponent,
@ -172,12 +169,6 @@ registerLocaleData(localeSv);
}
}
],
entryComponents: [
NodeVersionsDialogComponent,
LibraryDialogComponent,
CreateFromTemplateDialogComponent,
CurrentUserComponent
],
bootstrap: [AppComponent]
})
export class AppModule {}

View File

@ -51,12 +51,17 @@ export const APP_ROUTES: Routes = [
},
{
path: 'settings',
loadChildren: './components/settings/settings.module#AppSettingsModule'
loadChildren: () =>
import('./components/settings/settings.module').then(
m => m.AppSettingsModule
)
},
{
path: 'preview/s/:id',
loadChildren:
'./components/shared-link-view/shared-link-view.module#AppSharedLinkViewModule'
loadChildren: () =>
import('./components/shared-link-view/shared-link-view.module').then(
m => m.AppSharedLinkViewModule
)
},
{
path: 'view',
@ -68,7 +73,10 @@ export const APP_ROUTES: Routes = [
children: [
{
path: '',
loadChildren: './components/viewer/viewer.module#AppViewerModule'
loadChildren: () =>
import('./components/viewer/viewer.module').then(
m => m.AppViewerModule
)
}
]
}
@ -99,7 +107,10 @@ export const APP_ROUTES: Routes = [
// deprecated, backwards compatibility with ACA 1.8
{
path: 'preview/:nodeId',
loadChildren: './components/preview/preview.module#PreviewModule',
loadChildren: () =>
import('./components/preview/preview.module').then(
m => m.PreviewModule
),
data: {
navigateSource: 'personal-files'
}
@ -113,8 +124,10 @@ export const APP_ROUTES: Routes = [
data: {
navigateSource: 'personal-files'
},
loadChildren:
'./components/viewer/viewer.module#AppViewerModule'
loadChildren: () =>
import('./components/viewer/viewer.module').then(
m => m.AppViewerModule
)
}
]
}
@ -134,7 +147,10 @@ export const APP_ROUTES: Routes = [
// deprecated, backwards compatibility with ACA 1.8
{
path: 'preview/:nodeId',
loadChildren: './components/preview/preview.module#PreviewModule',
loadChildren: () =>
import('./components/preview/preview.module').then(
m => m.PreviewModule
),
data: {
navigateSource: 'personal-files'
}
@ -142,7 +158,10 @@ export const APP_ROUTES: Routes = [
// deprecated, backwards compatibility with ACA 1.8
{
path: ':folderId/preview/:nodeId',
loadChildren: './components/preview/preview.module#PreviewModule',
loadChildren: () =>
import('./components/preview/preview.module').then(
m => m.PreviewModule
),
data: {
navigateSource: 'personal-files'
}
@ -156,8 +175,10 @@ export const APP_ROUTES: Routes = [
data: {
navigateSource: 'personal-files'
},
loadChildren:
'./components/viewer/viewer.module#AppViewerModule'
loadChildren: () =>
import('./components/viewer/viewer.module').then(
m => m.AppViewerModule
)
}
]
}
@ -190,7 +211,10 @@ export const APP_ROUTES: Routes = [
// deprecated, backwards compatibility with ACA 1.8
{
path: 'preview/:nodeId',
loadChildren: './components/preview/preview.module#PreviewModule',
loadChildren: () =>
import('./components/preview/preview.module').then(
m => m.PreviewModule
),
data: {
navigateSource: 'libraries'
}
@ -204,8 +228,10 @@ export const APP_ROUTES: Routes = [
data: {
navigateSource: 'libraries'
},
loadChildren:
'./components/viewer/viewer.module#AppViewerModule'
loadChildren: () =>
import('./components/viewer/viewer.module').then(
m => m.AppViewerModule
)
}
]
}
@ -249,8 +275,10 @@ export const APP_ROUTES: Routes = [
data: {
navigateSource: 'libraries'
},
loadChildren:
'./components/viewer/viewer.module#AppViewerModule'
loadChildren: () =>
import('./components/viewer/viewer.module').then(
m => m.AppViewerModule
)
}
]
}
@ -275,7 +303,10 @@ export const APP_ROUTES: Routes = [
// deprecated, backwards compatibility with ACA 1.8
{
path: 'preview/:nodeId',
loadChildren: './components/preview/preview.module#PreviewModule',
loadChildren: () =>
import('./components/preview/preview.module').then(
m => m.PreviewModule
),
data: {
navigateSource: 'favorites'
}
@ -289,8 +320,10 @@ export const APP_ROUTES: Routes = [
data: {
navigateSource: 'favorites'
},
loadChildren:
'./components/viewer/viewer.module#AppViewerModule'
loadChildren: () =>
import('./components/viewer/viewer.module').then(
m => m.AppViewerModule
)
}
]
}
@ -314,7 +347,10 @@ export const APP_ROUTES: Routes = [
// deprecated, backwards compatibility with ACA 1.8
{
path: 'preview/:nodeId',
loadChildren: './components/preview/preview.module#PreviewModule',
loadChildren: () =>
import('./components/preview/preview.module').then(
m => m.PreviewModule
),
data: {
navigateSource: 'recent-files'
}
@ -328,8 +364,10 @@ export const APP_ROUTES: Routes = [
data: {
navigateSource: 'recent-files'
},
loadChildren:
'./components/viewer/viewer.module#AppViewerModule'
loadChildren: () =>
import('./components/viewer/viewer.module').then(
m => m.AppViewerModule
)
}
]
}
@ -351,7 +389,10 @@ export const APP_ROUTES: Routes = [
// deprecated, backwards compatibility with ACA 1.8
{
path: 'preview/:nodeId',
loadChildren: './components/preview/preview.module#PreviewModule',
loadChildren: () =>
import('./components/preview/preview.module').then(
m => m.PreviewModule
),
data: {
navigateSource: 'shared'
}
@ -365,8 +406,10 @@ export const APP_ROUTES: Routes = [
data: {
navigateSource: 'shared'
},
loadChildren:
'./components/viewer/viewer.module#AppViewerModule'
loadChildren: () =>
import('./components/viewer/viewer.module').then(
m => m.AppViewerModule
)
}
]
}
@ -376,11 +419,15 @@ export const APP_ROUTES: Routes = [
},
{
path: 'trashcan',
loadChildren: './components/trashcan/trashcan.module#AppTrashcanModule'
loadChildren: () =>
import('./components/trashcan/trashcan.module').then(
m => m.AppTrashcanModule
)
},
{
path: 'about',
loadChildren: './components/about/about.module#AboutModule'
loadChildren: () =>
import('./components/about/about.module').then(m => m.AboutModule)
},
{
path: 'search',
@ -395,7 +442,10 @@ export const APP_ROUTES: Routes = [
// deprecated, backwards compatibility with ACA 1.8
{
path: 'preview/:nodeId',
loadChildren: './components/preview/preview.module#PreviewModule',
loadChildren: () =>
import('./components/preview/preview.module').then(
m => m.PreviewModule
),
data: {
navigateSource: 'search'
}
@ -409,8 +459,10 @@ export const APP_ROUTES: Routes = [
data: {
navigateSource: 'search'
},
loadChildren:
'./components/viewer/viewer.module#AppViewerModule'
loadChildren: () =>
import('./components/viewer/viewer.module').then(
m => m.AppViewerModule
)
}
]
}
@ -435,8 +487,10 @@ export const APP_ROUTES: Routes = [
data: {
navigateSource: 'search'
},
loadChildren:
'./components/viewer/viewer.module#AppViewerModule'
loadChildren: () =>
import('./components/viewer/viewer.module').then(
m => m.AppViewerModule
)
}
]
}

View File

@ -53,12 +53,6 @@ import { LogoutComponent } from './logout/logout.component';
ToggleSharedComponent,
LanguagePickerComponent,
LogoutComponent
],
entryComponents: [
LocationLinkComponent,
ToggleSharedComponent,
LanguagePickerComponent,
LogoutComponent
]
})
export class AppCommonModule {}

View File

@ -56,7 +56,7 @@ describe('LogoutComponent', () => {
]
});
store = TestBed.get(Store);
store = TestBed.inject(Store);
fixture = TestBed.createComponent(LogoutComponent);
component = fixture.componentInstance;
fixture.detectChanges();

View File

@ -54,7 +54,7 @@ describe('ContextMenuComponent', () => {
fixture = TestBed.createComponent(ContextMenuItemComponent);
component = fixture.componentInstance;
extensionsService = TestBed.get(AppExtensionService);
extensionsService = TestBed.inject(AppExtensionService);
contextItem = {
type: 'button',

View File

@ -87,8 +87,8 @@ describe('ContextMenuComponent', () => {
fixture = TestBed.createComponent(ContextMenuComponent);
component = fixture.componentInstance;
contextMenuOverlayRef = TestBed.get(ContextMenuOverlayRef);
extensionsService = TestBed.get(AppExtensionService);
contextMenuOverlayRef = TestBed.inject(ContextMenuOverlayRef);
extensionsService = TestBed.inject(AppExtensionService);
spyOn(extensionsService, 'getAllowedContextMenuActions').and.returnValue([
contextItem

View File

@ -59,7 +59,6 @@ import { ContextActionsModule } from '@alfresco/aca-shared';
ContextMenuComponent,
ContextMenuItemComponent,
ContextActionsModule
],
entryComponents: [ContextMenuComponent]
]
})
export class ContextMenuModule {}

View File

@ -62,9 +62,9 @@ describe('ContextMenuService', () => {
]
});
injector = TestBed.get(Injector);
overlay = TestBed.get(Overlay);
userPreferencesService = TestBed.get(UserPreferencesService);
injector = TestBed.inject(Injector);
overlay = TestBed.inject(Overlay);
userPreferencesService = TestBed.inject(UserPreferencesService);
});
it('should create a custom overlay', () => {

View File

@ -61,8 +61,8 @@ describe('CurrentUserComponent', () => {
});
fixture = TestBed.createComponent(CurrentUserComponent);
appExtensionService = TestBed.get(AppExtensionService);
store = TestBed.get(Store);
appExtensionService = TestBed.inject(AppExtensionService);
store = TestBed.inject(Store);
component = fixture.componentInstance;
});

View File

@ -54,7 +54,7 @@ describe('UserMenuItemComponent', () => {
});
fixture = TestBed.createComponent(UserMenuItemComponent);
appExtensionService = TestBed.get(AppExtensionService);
appExtensionService = TestBed.inject(AppExtensionService);
component = fixture.componentInstance;
});

View File

@ -40,7 +40,6 @@ import { CoreModule } from '@alfresco/adf-core';
LockedByModule
],
declarations: [CustomNameColumnComponent],
exports: [CustomNameColumnComponent],
entryComponents: [CustomNameColumnComponent]
exports: [CustomNameColumnComponent]
})
export class DocumentListCustomComponentsModule {}

View File

@ -83,12 +83,12 @@ describe('FavoriteLibrariesComponent', () => {
fixture = TestBed.createComponent(FavoriteLibrariesComponent);
component = fixture.componentInstance;
alfrescoApi = TestBed.get(AlfrescoApiService);
contentApiService = TestBed.get(ContentApiService);
userPreference = TestBed.get(UserPreferencesService);
contentManagementService = TestBed.get(ContentManagementService);
alfrescoApi = TestBed.inject(AlfrescoApiService);
contentApiService = TestBed.inject(ContentApiService);
userPreference = TestBed.inject(UserPreferencesService);
contentManagementService = TestBed.inject(ContentManagementService);
alfrescoApi.reset();
router = TestBed.get(Router);
router = TestBed.inject(Router);
spyOn(contentApiService, 'getNode').and.returnValue(
of({ entry: { id: 'libraryId' } } as NodeEntry)
@ -116,7 +116,9 @@ describe('FavoriteLibrariesComponent', () => {
expect(contentApiService.getFavoriteLibraries).toHaveBeenCalledWith(
'-me-',
{ maxItems: userPreference.paginationSize }
{
maxItems: userPreference.paginationSize
}
);
});

View File

@ -101,15 +101,15 @@ describe('FavoritesComponent', () => {
fixture = TestBed.createComponent(FavoritesComponent);
component = fixture.componentInstance;
alfrescoApi = TestBed.get(AlfrescoApiService);
alfrescoApi = TestBed.inject(AlfrescoApiService);
alfrescoApi.reset();
spyOn(alfrescoApi.favoritesApi, 'getFavorites').and.returnValue(
Promise.resolve(page)
);
contentApi = TestBed.get(ContentApiService);
uploadService = TestBed.get(UploadService);
router = TestBed.get(Router);
contentApi = TestBed.inject(ContentApiService);
uploadService = TestBed.inject(UploadService);
router = TestBed.inject(Router);
});
describe('Node navigation', () => {

View File

@ -35,7 +35,9 @@ import {
NodeFavoriteDirective,
DataTableComponent,
UploadService,
AppConfigPipe
AppConfigPipe,
AlfrescoApiService,
AlfrescoApiServiceMock
} from '@alfresco/adf-core';
import { DocumentListComponent } from '@alfresco/adf-content-services';
import { NodeActionsService } from '../../services/node-actions.service';
@ -51,7 +53,7 @@ describe('FilesComponent', () => {
let uploadService: UploadService;
let nodeActionsService: NodeActionsService;
let contentApi: ContentApiService;
let router = {
let router: any = {
url: '',
navigate: jasmine.createSpy('navigate')
};
@ -67,6 +69,7 @@ describe('FilesComponent', () => {
AppConfigPipe
],
providers: [
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
{
provide: Router,
useValue: router
@ -85,18 +88,22 @@ describe('FilesComponent', () => {
fixture = TestBed.createComponent(FilesComponent);
component = fixture.componentInstance;
uploadService = TestBed.get(UploadService);
router = TestBed.get(Router);
nodeActionsService = TestBed.get(NodeActionsService);
contentApi = TestBed.get(ContentApiService);
uploadService = TestBed.inject(UploadService);
router = TestBed.inject(Router);
nodeActionsService = TestBed.inject(NodeActionsService);
contentApi = TestBed.inject(ContentApiService);
});
beforeEach(() => {
node = { id: 'node-id', isFolder: true };
spyOn(component.documentList, 'loadFolder').and.callFake(() => {});
});
describe('Current page is valid', () => {
beforeEach(() => {
fixture.detectChanges();
spyOn(component.documentList, 'loadFolder').and.callFake(() => {});
});
it('should be a valid current page', fakeAsync(() => {
spyOn(contentApi, 'getNode').and.returnValue(throwError(null));
@ -111,24 +118,29 @@ describe('FilesComponent', () => {
spyOn(contentApi, 'getNode').and.returnValue(of({ entry: node }));
component.ngOnInit();
tick();
fixture.detectChanges();
tick();
expect(component.isValidPath).toBe(true);
}));
});
describe('OnInit', () => {
beforeEach(() => {
router.navigate['calls'].reset();
});
it('should set current node', () => {
spyOn(contentApi, 'getNode').and.returnValue(of({ entry: node }));
fixture.detectChanges();
expect(component.node).toBe(node);
});
it('if should navigate to parent if node is not a folder', () => {
node.isFolder = false;
node.parentId = 'parent-id';
spyOn(contentApi, 'getNode').and.returnValue(of({ entry: node }));
it('should navigate to parent if node is not a folder', () => {
const nodeEntry = { isFolder: false, parentId: 'parent-id' };
spyOn(contentApi, 'getNode').and.returnValue(
of({ entry: nodeEntry } as any)
);
fixture.detectChanges();

View File

@ -64,7 +64,6 @@ export function components() {
SharedInfoDrawerModule
],
declarations: [...components()],
exports: [...components(), SharedInfoDrawerModule],
entryComponents: [...components()]
exports: [...components(), SharedInfoDrawerModule]
})
export class AppInfoDrawerModule {}

View File

@ -57,7 +57,7 @@ describe('LibraryMetadataFormComponent', () => {
fixture = TestBed.createComponent(LibraryMetadataFormComponent);
component = fixture.componentInstance;
alfrescoApiService = TestBed.get(AlfrescoApiService);
alfrescoApiService = TestBed.inject(AlfrescoApiService);
});
afterEach(() => {

View File

@ -55,8 +55,8 @@ describe('MetadataTabComponent', () => {
describe('content-metadata configuration', () => {
beforeEach(() => {
appConfig = TestBed.get(AppConfigService);
extensions = TestBed.get(AppExtensionService);
appConfig = TestBed.inject(AppConfigService);
extensions = TestBed.inject(AppExtensionService);
});
it('should remain unchanged when metadata extension is missing', () => {
@ -136,7 +136,7 @@ describe('MetadataTabComponent', () => {
describe('displayAspect', () => {
beforeEach(() => {
fixture = TestBed.createComponent(MetadataTabComponent);
store = TestBed.get(Store);
store = TestBed.inject(Store);
component = fixture.componentInstance;
});

View File

@ -14,7 +14,7 @@
role="heading"
aria-level="1"
*ngIf="!hideSidenav"
(toggleClicked)="layout.toggleMenu($event)"
(toggleClicked)="layout.toggleMenu()"
[expandedSidenav]="!isMenuMinimized()"
>
</app-header>

View File

@ -73,10 +73,10 @@ describe('AppLayoutComponent', () => {
fixture = TestBed.createComponent(AppLayoutComponent);
component = fixture.componentInstance;
appConfig = TestBed.get(AppConfigService);
store = TestBed.get(Store);
router = TestBed.get(Router);
userPreference = TestBed.get(UserPreferencesService);
appConfig = TestBed.inject(AppConfigService);
store = TestBed.inject(Store);
router = TestBed.inject(Router);
userPreference = TestBed.inject(UserPreferencesService);
});
beforeEach(() => {

View File

@ -55,7 +55,7 @@ import { Directionality } from '@angular/cdk/bidi';
host: { class: 'app-layout' }
})
export class AppLayoutComponent implements OnInit, OnDestroy {
@ViewChild('layout')
@ViewChild('layout', { static: true })
layout: SidenavLayoutComponent;
onDestroy$: Subject<boolean> = new Subject<boolean>();

View File

@ -70,9 +70,9 @@ describe('LibrariesComponent', () => {
fixture = TestBed.createComponent(LibrariesComponent);
component = fixture.componentInstance;
alfrescoApi = TestBed.get(AlfrescoApiService);
alfrescoApi = TestBed.inject(AlfrescoApiService);
alfrescoApi.reset();
router = TestBed.get(Router);
router = TestBed.inject(Router);
spyOn(alfrescoApi.sitesApi, 'getSites').and.returnValue(
Promise.resolve(page)

View File

@ -50,8 +50,6 @@ import { NgModule } from '@angular/core';
MatInputModule
],
exports: [AppNodeVersionFormComponent],
declarations: [AppNodeVersionFormComponent],
providers: [],
entryComponents: [AppNodeVersionFormComponent]
declarations: [AppNodeVersionFormComponent]
})
export class AppNodeVersionModule {}

View File

@ -69,7 +69,7 @@ describe('PageComponent', () => {
providers: [ContentManagementService, AppExtensionService]
});
store = TestBed.get(Store);
store = TestBed.inject(Store);
fixture = TestBed.createComponent(TestComponent);
component = fixture.componentInstance;
});

View File

@ -34,7 +34,8 @@ import {
OnInit,
OnChanges,
ViewChild,
SimpleChanges
SimpleChanges,
Directive
} from '@angular/core';
import { Store } from '@ngrx/store';
import {
@ -60,6 +61,8 @@ import {
} from '@alfresco/aca-shared/store';
import { isLocked, isLibrary, AppExtensionService } from '@alfresco/aca-shared';
/* tslint:disable:directive-class-suffix */
@Directive()
export abstract class PageComponent implements OnInit, OnDestroy, OnChanges {
onDestroy$: Subject<boolean> = new Subject<boolean>();

View File

@ -40,7 +40,7 @@ import { NodePermissionsDialogComponent } from '../permission-dialog/node-permis
templateUrl: './permission-manager.component.html'
})
export class PermissionsManagerComponent implements OnInit {
@ViewChild('permissionList')
@ViewChild('permissionList', { static: true })
permissionList: PermissionListComponent;
@Input()

View File

@ -33,7 +33,6 @@ import { PermissionsManagerComponent } from './permission-manager/permission-man
@NgModule({
imports: [CommonModule, CoreModule.forChild(), ContentModule.forChild()],
declarations: [PermissionsManagerComponent, NodePermissionsDialogComponent],
exports: [PermissionsManagerComponent, NodePermissionsDialogComponent],
entryComponents: [NodePermissionsDialogComponent]
exports: [PermissionsManagerComponent, NodePermissionsDialogComponent]
})
export class AppPermissionsModule {}

View File

@ -80,14 +80,14 @@ describe('PreviewComponent', () => {
fixture = TestBed.createComponent(PreviewComponent);
component = fixture.componentInstance;
router = TestBed.get(Router);
route = TestBed.get(ActivatedRoute);
preferences = TestBed.get(UserPreferencesService);
contentApi = TestBed.get(ContentApiService);
uploadService = TestBed.get(UploadService);
alfrescoApiService = TestBed.get(AlfrescoApiService);
contentManagementService = TestBed.get(ContentManagementService);
store = TestBed.get(Store);
router = TestBed.inject(Router);
route = TestBed.inject(ActivatedRoute);
preferences = TestBed.inject(UserPreferencesService);
contentApi = TestBed.inject(ContentApiService);
uploadService = TestBed.inject(UploadService);
alfrescoApiService = TestBed.inject(AlfrescoApiService);
contentManagementService = TestBed.inject(ContentManagementService);
store = TestBed.inject(Store);
});
it('should extract the property path root', () => {

View File

@ -84,8 +84,8 @@ describe('RecentFilesComponent', () => {
fixture = TestBed.createComponent(RecentFilesComponent);
component = fixture.componentInstance;
alfrescoApi = TestBed.get(AlfrescoApiService);
uploadService = TestBed.get(UploadService);
alfrescoApi = TestBed.inject(AlfrescoApiService);
uploadService = TestBed.inject(UploadService);
alfrescoApi.reset();
spyOn(alfrescoApi.peopleApi, 'getPerson').and.returnValue(

View File

@ -64,7 +64,7 @@ export class SearchInputControlComponent implements OnDestroy {
@Output()
searchChange: EventEmitter<string> = new EventEmitter();
@ViewChild('searchInput')
@ViewChild('searchInput', { static: true })
searchInput: ElementRef;
searchTerm = '';

View File

@ -59,9 +59,9 @@ describe('SearchInputComponent', () => {
})
.compileComponents()
.then(() => {
actions$ = TestBed.get(Actions);
actions$ = TestBed.inject(Actions);
fixture = TestBed.createComponent(SearchInputComponent);
content = TestBed.get(ContentManagementService);
content = TestBed.inject(ContentManagementService);
component = fixture.componentInstance;
fixture.detectChanges();
});

View File

@ -91,10 +91,10 @@ export class SearchInputComponent implements OnInit, OnDestroy {
}
];
@ViewChild('searchInputControl')
@ViewChild('searchInputControl', { static: true })
searchInputControl: SearchInputControlComponent;
@ViewChild(MatMenuTrigger)
@ViewChild(MatMenuTrigger, { static: true })
trigger: MatMenuTrigger;
constructor(

View File

@ -42,7 +42,7 @@ describe('SearchLibrariesQueryBuilderService', () => {
imports: [AppTestingModule]
});
apiService = TestBed.get(AlfrescoApiService);
apiService = TestBed.inject(AlfrescoApiService);
apiService.reset();
queriesApi = apiService.getInstance().core.queriesApi;
builder = new SearchLibrariesQueryBuilderService(apiService);

View File

@ -93,12 +93,12 @@ describe('SearchComponent', () => {
]
});
config = TestBed.get(AppConfigService);
store = TestBed.get(Store);
queryBuilder = TestBed.get(SearchQueryBuilderService);
alfrescoApi = TestBed.get(AlfrescoApiService);
translate = TestBed.get(TranslationService);
router = TestBed.get(Router);
config = TestBed.inject(AppConfigService);
store = TestBed.inject(Store);
queryBuilder = TestBed.inject(SearchQueryBuilderService);
alfrescoApi = TestBed.inject(AlfrescoApiService);
translate = TestBed.inject(TranslationService);
router = TestBed.inject(Router);
fixture = TestBed.createComponent(SearchResultsComponent);
component = fixture.componentInstance;

View File

@ -54,7 +54,7 @@ import { AppExtensionService } from '@alfresco/aca-shared';
styleUrls: ['./search-results.component.scss']
})
export class SearchResultsComponent extends PageComponent implements OnInit {
@ViewChild('searchFilter')
@ViewChild('searchFilter', { static: true })
searchFilter: SearchFilterComponent;
showFacetFilter$: Observable<boolean>;

View File

@ -62,8 +62,8 @@ describe('SettingsComponent', () => {
fixture = TestBed.createComponent(SettingsComponent);
component = fixture.componentInstance;
storage = TestBed.get(StorageService);
appExtensions = TestBed.get(AppExtensionService);
storage = TestBed.inject(StorageService);
appExtensions = TestBed.inject(AppExtensionService);
stringParam = {
key: 'key',

View File

@ -32,6 +32,7 @@ import {
import { NO_ERRORS_SCHEMA } from '@angular/core';
import {
AlfrescoApiService,
AlfrescoApiServiceMock,
NodeFavoriteDirective,
DataTableComponent,
AppConfigPipe,
@ -74,6 +75,7 @@ describe('SharedFilesComponent', () => {
AppConfigPipe
],
providers: [
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
{
provide: Router,
useValue: mockRouter
@ -83,11 +85,11 @@ describe('SharedFilesComponent', () => {
});
fixture = TestBed.createComponent(SharedFilesComponent);
uploadService = TestBed.get(UploadService);
contentManagementService = TestBed.get(ContentManagementService);
uploadService = TestBed.inject(UploadService);
contentManagementService = TestBed.inject(ContentManagementService);
component = fixture.componentInstance;
alfrescoApi = TestBed.get(AlfrescoApiService);
alfrescoApi = TestBed.inject(AlfrescoApiService);
alfrescoApi.reset();
spyOn(alfrescoApi.sharedLinksApi, 'findSharedLinks').and.returnValue(

View File

@ -78,8 +78,8 @@ describe('SharedLinkViewComponent', () => {
fixture = TestBed.createComponent(SharedLinkViewComponent);
component = fixture.componentInstance;
alfrescoApiService = TestBed.get(AlfrescoApiService);
appExtensionService = TestBed.get(AppExtensionService);
alfrescoApiService = TestBed.inject(AlfrescoApiService);
appExtensionService = TestBed.inject(AppExtensionService);
spyGetSharedLink = spyOn(
alfrescoApiService.sharedLinksApi,

View File

@ -52,7 +52,7 @@ describe('ButtonMenuComponent', () => {
fixture = TestBed.createComponent(ButtonMenuComponent);
component = fixture.componentInstance;
router = TestBed.get(Router);
router = TestBed.inject(Router);
spyOn(router, 'navigate');
});

View File

@ -52,7 +52,7 @@ describe('ExpandMenuComponent', () => {
fixture = TestBed.createComponent(ExpandMenuComponent);
component = fixture.componentInstance;
router = TestBed.get(Router);
router = TestBed.inject(Router);
spyOn(router, 'navigate');
});

View File

@ -26,6 +26,7 @@
import { Directive, Input, HostListener } from '@angular/core';
import { PRIMARY_OUTLET, Router } from '@angular/router';
import { Store } from '@ngrx/store';
import { AppStore } from '@alfresco/aca-shared/store';
@Directive({
/* tslint:disable-next-line */
@ -47,7 +48,7 @@ export class ActionDirective {
}
}
constructor(private router: Router, private store: Store<any>) {}
constructor(private router: Router, private store: Store<AppStore>) {}
private getNavigationCommands(url: string): any[] {
const urlTree = this.router.parseUrl(url);

View File

@ -74,7 +74,7 @@ describe('ActionDirective', () => {
});
fixture = TestBed.createComponent(TestComponent);
router = TestBed.get(Router);
router = TestBed.inject(Router);
});
it('should add active route class name', () => {

View File

@ -31,7 +31,8 @@ import {
Renderer2,
ContentChildren,
QueryList,
AfterContentInit
AfterContentInit,
Optional
} from '@angular/core';
import { Router, NavigationEnd } from '@angular/router';
import { filter, takeUntil } from 'rxjs/operators';
@ -53,7 +54,8 @@ export class ActiveLinkDirective implements OnInit, AfterContentInit {
constructor(
private router: Router,
private element: ElementRef,
private renderer: Renderer2
private renderer: Renderer2,
@Optional() private action?: ActionDirective
) {}
ngOnInit() {
@ -68,21 +70,27 @@ export class ActiveLinkDirective implements OnInit, AfterContentInit {
}
private update(url: string) {
if (this.action) {
const itemUrl = this.resolveUrl(this.action);
this.render(url, itemUrl);
}
this.links.map(item => {
const itemUrl = this.resolveUrl(item);
if (url && url.substring(1).startsWith(itemUrl)) {
this.isLinkActive = true;
this.renderer.addClass(this.element.nativeElement, this.acaActiveLink);
} else {
this.isLinkActive = false;
this.renderer.removeClass(
this.element.nativeElement,
this.acaActiveLink
);
}
this.render(url, itemUrl);
});
}
private render(routerUrl: string, actionUrl: string) {
if (routerUrl && routerUrl.substring(1).startsWith(actionUrl)) {
this.isLinkActive = true;
this.renderer.addClass(this.element.nativeElement, this.acaActiveLink);
} else {
this.isLinkActive = false;
this.renderer.removeClass(this.element.nativeElement, this.acaActiveLink);
}
}
ngAfterContentInit() {
this.links.changes.subscribe(() => this.update(this.router.url));
this.update(this.router.url);
@ -90,7 +98,7 @@ export class ActiveLinkDirective implements OnInit, AfterContentInit {
private resolveUrl(item): string {
return (
(item.action && (item.action.click && item.action.click.payload)) ||
(item.action && item.action.click && item.action.click.payload) ||
item.action.route
);
}

Some files were not shown because too many files have changed in this diff Show More