From 251b6a0ec7f9bd7b718df6b0a8c7e2fdfe83debe Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Mon, 29 May 2023 10:28:26 +0100 Subject: [PATCH] [ACS-5308] cleanup content common module and move to standalone components (#3234) * language picker * location link * logout component * logout: fix tests * toggle shared component * user info component * cleanup common module * migrate generic error to standalone * thumbnail column component * name column component * tags column component * locked by component * cleanup module dependencies * comments tab component * info drawer and details * cleanup infodrawer module * remove useless test * reduce useless imports * info drawer module * context menu component --- app/src/app/app.module.ts | 2 +- karma.conf.js | 2 +- .../aca-content/src/lib/aca-content.module.ts | 15 ++--- .../lib/components/common/common.module.ts | 29 ++++------ .../language-picker.component.ts | 6 ++ .../location-link/location-link.component.ts | 15 +++-- .../common/logout/logout.component.spec.ts | 5 +- .../common/logout/logout.component.ts | 9 ++- .../toggle-shared/toggle-shared.component.ts | 7 +++ .../user-info/user-info.component.spec.ts | 3 +- .../common/user-info/user-info.component.ts | 6 ++ .../context-menu-item.component.spec.ts | 5 +- .../context-menu-item.component.ts | 9 ++- .../context-menu-outside-event.directive.ts | 1 + .../context-menu.component.spec.ts | 3 +- .../context-menu/context-menu.component.ts | 21 ++++++- .../context-menu/context-menu.module.ts | 54 ------------------ .../context-menu/context-menu.service.spec.ts | 18 +++--- .../details/details.component.spec.ts | 50 ++++++++++++---- .../components/details/details.component.ts | 28 ++++++++- .../document-list-custom-components.module.ts | 10 +--- .../name-column/name-column.component.spec.ts | 3 +- .../name-column/name-column.component.ts | 8 ++- .../tags-column/tags-column.component.spec.ts | 57 ------------------- .../tags-column/tags-column.component.ts | 4 +- .../thumbnail-column.component.ts | 5 ++ .../comments-tab.component.spec.ts | 4 +- .../comments-tab/comments-tab.component.ts | 4 ++ .../info-drawer/info.drawer.module.ts | 38 +++++-------- .../library-metadata-form.component.spec.ts | 3 +- .../library-metadata-form.component.ts | 28 ++++++++- .../library-metadata-tab.component.ts | 3 + .../metadata-tab.component.spec.ts | 4 +- .../metadata-tab/metadata-tab.component.ts | 5 +- .../versions-tab/versions-tab.component.ts | 7 +++ .../search/search-results.module.ts | 22 ++++--- .../shared-link-view.module.ts | 2 - .../lib/components/toolbar/toolbar.module.ts | 3 +- .../components/trashcan/trashcan.module.ts | 10 ++-- .../src/lib/folder-rules.module.ts | 6 +- .../aca-preview/src/lib/preview.module.ts | 6 +- .../generic-error/generic-error.component.ts | 4 ++ .../generic-error/generic-error.module.ts | 36 ------------ .../info-drawer/info-drawer.component.spec.ts | 3 +- .../info-drawer/info-drawer.component.ts | 9 ++- .../info-drawer/shared-info-drawer.module.ts | 40 ------------- .../locked-by/locked-by.component.ts | 4 ++ .../components/locked-by/locked-by.module.ts | 36 ------------ .../open-in-app/open-in-app.component.spec.ts | 2 +- projects/aca-shared/src/lib/shared.module.ts | 14 +---- projects/aca-shared/src/public-api.ts | 3 - projects/aca-viewer/src/lib/viewer.module.ts | 4 +- 52 files changed, 291 insertions(+), 384 deletions(-) delete mode 100644 projects/aca-content/src/lib/components/context-menu/context-menu.module.ts delete mode 100644 projects/aca-content/src/lib/components/dl-custom-components/tags-column/tags-column.component.spec.ts delete mode 100644 projects/aca-shared/src/lib/components/generic-error/generic-error.module.ts delete mode 100644 projects/aca-shared/src/lib/components/info-drawer/shared-info-drawer.module.ts delete mode 100644 projects/aca-shared/src/lib/components/locked-by/locked-by.module.ts diff --git a/app/src/app/app.module.ts b/app/src/app/app.module.ts index 87eab3bb6..1253e42c9 100644 --- a/app/src/app/app.module.ts +++ b/app/src/app/app.module.ts @@ -88,7 +88,7 @@ registerLocaleData(localeSv); BrowserModule, TranslateModule.forRoot(), CoreModule.forRoot(), - SharedModule.forRoot(), + SharedModule, CoreExtensionsModule.forRoot(), AppLoginModule, environment.e2e ? NoopAnimationsModule : BrowserAnimationsModule, diff --git a/karma.conf.js b/karma.conf.js index 916090daa..e2c5b9582 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -64,7 +64,7 @@ module.exports = () => { statements: 75, branches: 67, functions: 73, - lines: 75 + lines: 74 } } }, diff --git a/projects/aca-content/src/lib/aca-content.module.ts b/projects/aca-content/src/lib/aca-content.module.ts index 82730db2d..3da5bb1d5 100644 --- a/projects/aca-content/src/lib/aca-content.module.ts +++ b/projects/aca-content/src/lib/aca-content.module.ts @@ -34,7 +34,7 @@ import { LibraryStatusColumnComponent, TrashcanNameColumnComponent } from '@alfresco/adf-content-services'; -import { DocumentBasePageService, ExtensionsDataLoaderGuard, PageLayoutModule, SharedModule } from '@alfresco/aca-shared'; +import { DocumentBasePageService, ExtensionsDataLoaderGuard, PageLayoutModule, SharedModule, GenericErrorComponent } from '@alfresco/aca-shared'; import * as rules from '@alfresco/aca-shared/rules'; import { FilesComponent } from './components/files/files.component'; @@ -47,11 +47,10 @@ import { MaterialModule } from './material.module'; import { CoreExtensionsModule } from './extensions/core.extensions.module'; import { AppInfoDrawerModule } from './components/info-drawer/info.drawer.module'; import { DirectivesModule } from './directives/directives.module'; -import { ContextMenuModule } from './components/context-menu/context-menu.module'; import { ExtensionService, ExtensionsModule } from '@alfresco/adf-extensions'; import { AppToolbarModule } from './components/toolbar/toolbar.module'; import { AppSidenavModule } from './components/sidenav/sidenav.module'; -import { AppCommonModule } from './components/common/common.module'; +import { APP_COMMON_DIRECTIVES } from './components/common/common.module'; import { AppSearchInputModule } from './components/search/search-input.module'; import { DocumentListCustomComponentsModule } from './components/dl-custom-components/document-list-custom-components.module'; import { AppSearchResultsModule } from './components/search/search-results.module'; @@ -93,6 +92,7 @@ import { SidenavComponent } from './components/sidenav/sidenav.component'; import { ContentManagementService } from './services/content-management.service'; import { ShellLayoutComponent, SHELL_NAVBAR_MIN_WIDTH } from '@alfresco/adf-core/shell'; import { UserMenuComponent } from './components/sidenav/user-menu/user-menu.component'; +import { ContextMenuComponent } from './components/context-menu/context-menu.component'; @NgModule({ imports: [ @@ -107,10 +107,10 @@ import { UserMenuComponent } from './components/sidenav/user-menu/user-menu.comp SharedModule, MaterialModule, AppStoreModule, - AppCommonModule, + ...APP_COMMON_DIRECTIVES, PageLayoutModule, DirectivesModule, - ContextMenuModule, + ContextMenuComponent, AppInfoDrawerModule, AppToolbarModule, AppSidenavModule, @@ -121,11 +121,12 @@ import { UserMenuComponent } from './components/sidenav/user-menu/user-menu.comp ViewProfileModule, AppTrashcanModule, AppSharedLinkViewModule, - AcaFolderRulesModule + AcaFolderRulesModule, + GenericErrorComponent, + DetailsComponent ], declarations: [ FilesComponent, - DetailsComponent, LibrariesComponent, FavoriteLibrariesComponent, FavoritesComponent, diff --git a/projects/aca-content/src/lib/components/common/common.module.ts b/projects/aca-content/src/lib/components/common/common.module.ts index 8d6c78444..5d3ccb6d5 100644 --- a/projects/aca-content/src/lib/components/common/common.module.ts +++ b/projects/aca-content/src/lib/components/common/common.module.ts @@ -22,30 +22,25 @@ * from Hyland Software. If not, see . */ -import { CoreModule } from '@alfresco/adf-core'; -import { ExtensionsModule } from '@alfresco/adf-extensions'; -import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; -import { GenericErrorModule } from '@alfresco/aca-shared'; import { LocationLinkComponent } from './location-link/location-link.component'; import { ToggleSharedComponent } from './toggle-shared/toggle-shared.component'; import { LanguagePickerComponent } from './language-picker/language-picker.component'; import { LogoutComponent } from './logout/logout.component'; -import { ContentModule } from '@alfresco/adf-content-services'; import { UserInfoComponent } from './user-info/user-info.component'; -import { RouterModule } from '@angular/router'; +/** + * @deprecated Use `APP_COMMON_DIRECTIVES` instead + */ @NgModule({ - imports: [CommonModule, CoreModule.forChild(), ContentModule.forChild(), ExtensionsModule, GenericErrorModule, RouterModule], - declarations: [LocationLinkComponent, ToggleSharedComponent, LanguagePickerComponent, LogoutComponent, UserInfoComponent], - exports: [ - ExtensionsModule, - LocationLinkComponent, - GenericErrorModule, - ToggleSharedComponent, - LanguagePickerComponent, - LogoutComponent, - UserInfoComponent - ] + imports: [LanguagePickerComponent, LocationLinkComponent, LogoutComponent, ToggleSharedComponent, UserInfoComponent] }) export class AppCommonModule {} + +export const APP_COMMON_DIRECTIVES = [ + LanguagePickerComponent, + LocationLinkComponent, + LogoutComponent, + ToggleSharedComponent, + UserInfoComponent +] as const; diff --git a/projects/aca-content/src/lib/components/common/language-picker/language-picker.component.ts b/projects/aca-content/src/lib/components/common/language-picker/language-picker.component.ts index 87da0e959..ec6464df1 100644 --- a/projects/aca-content/src/lib/components/common/language-picker/language-picker.component.ts +++ b/projects/aca-content/src/lib/components/common/language-picker/language-picker.component.ts @@ -22,9 +22,15 @@ * from Hyland Software. If not, see . */ +import { LanguageMenuModule } from '@alfresco/adf-core'; import { Component } from '@angular/core'; +import { MatIconModule } from '@angular/material/icon'; +import { MatMenuModule } from '@angular/material/menu'; +import { TranslateModule } from '@ngx-translate/core'; @Component({ + standalone: true, + imports: [TranslateModule, MatIconModule, MatMenuModule, LanguageMenuModule], selector: 'aca-language-picker', template: `