From 44d594f096fbdfdb1764a509ca399361098c2a9d Mon Sep 17 00:00:00 2001 From: pkundu Date: Sat, 9 Sep 2023 12:43:04 +0530 Subject: [PATCH] [ACS-5551]added null checks --- projects/aca-content/assets/i18n/en.json | 1 + .../components/details/details.component.html | 2 +- .../components/details/details.component.scss | 4 +- .../details/details.component.spec.ts | 6 +-- .../components/details/details.component.ts | 4 +- .../lib/services/node-actions.service.spec.ts | 12 +++--- .../src/lib/services/node-actions.service.ts | 27 ++++++++----- .../aca-content/src/lib/ui/application.scss | 6 +-- .../ui/overrides/adf-style-fixes.theme.scss | 19 +++++++++ .../src/lib/ui/variables/variables.scss | 18 ++++----- .../info-drawer/info-drawer.component.html | 2 +- .../info-drawer/info-drawer.component.spec.ts | 40 +++++++++++++++++++ .../info-drawer/info-drawer.component.ts | 12 +++++- .../page-layout/page-layout.component.scss | 2 +- 14 files changed, 116 insertions(+), 39 deletions(-) diff --git a/projects/aca-content/assets/i18n/en.json b/projects/aca-content/assets/i18n/en.json index bab98e67e3..17e036f2e0 100644 --- a/projects/aca-content/assets/i18n/en.json +++ b/projects/aca-content/assets/i18n/en.json @@ -396,6 +396,7 @@ "TITLE": "Details", "CLOSE": "Close", "DATA_LOADING": "Data is loading", + "ICON": "Node Icon", "TABS": { "PROPERTIES": "Properties", "LIBRARY_PROPERTIES": "About", diff --git a/projects/aca-content/src/lib/components/details/details.component.html b/projects/aca-content/src/lib/components/details/details.component.html index e881ca337c..0a00dd4ee0 100644 --- a/projects/aca-content/src/lib/components/details/details.component.html +++ b/projects/aca-content/src/lib/components/details/details.component.html @@ -9,7 +9,7 @@
- Info Drawer icon + {{ 'APP.INFO_DRAWER.ICON' | translate }} {{ node.name }}
- + diff --git a/projects/aca-shared/src/lib/components/info-drawer/info-drawer.component.spec.ts b/projects/aca-shared/src/lib/components/info-drawer/info-drawer.component.spec.ts index 7d16fadfa8..fe94ae7f7e 100644 --- a/projects/aca-shared/src/lib/components/info-drawer/info-drawer.component.spec.ts +++ b/projects/aca-shared/src/lib/components/info-drawer/info-drawer.component.spec.ts @@ -57,6 +57,38 @@ describe('InfoDrawerComponent', () => { ]) }; + const mockNode = { + isFile: false, + createdByUser: { id: 'admin', displayName: 'Administrator' }, + modifiedAt: new Date('2017-05-24T15:08:55.640Z'), + nodeType: 'cm:content', + content: { + mimeType: 'application/rtf', + mimeTypeName: 'Rich Text Format', + sizeInBytes: 14530, + encoding: 'UTF-8' + }, + parentId: 'd124de26-6ba0-4f40-8d98-4907da2d337a', + createdAt: new Date('2017-05-24T15:08:55.640Z'), + path: { + name: '/Company Home/Guest Home', + isComplete: true, + elements: [ + { + id: '94acfc73-7014-4475-9bd9-93a2162f0f8c', + name: 'Company Home' + }, + { id: 'd124de26-6ba0-4f40-8d98-4907da2d337a', name: 'Guest Home' } + ] + }, + isFolder: true, + modifiedByUser: { id: 'admin', displayName: 'Administrator' }, + name: 'b_txt_file.rtf', + id: '70e1cc6a-6918-468a-b84a-1048093b06fd', + properties: { 'cm:versionLabel': '1.0', 'cm:versionType': 'MAJOR' }, + allowableOperations: ['delete', 'update'] + }; + beforeEach(() => { TestBed.configureTestingModule({ imports: [LibTestingModule, InfoDrawerComponent], @@ -182,4 +214,12 @@ describe('InfoDrawerComponent', () => { } as ContentActionRef ]); }); + + it('should return the icon when getNodeIcon is called', () => { + const expectedIcon = 'assets/images/ft_ic_folder'; + spyOn(component['nodeActionsService'], 'getNodeIcon').and.returnValue(expectedIcon); + fixture.detectChanges(); + const result = component.getNodeIcon(mockNode); + expect(result).toContain(expectedIcon); + }); }); diff --git a/projects/aca-shared/src/lib/components/info-drawer/info-drawer.component.ts b/projects/aca-shared/src/lib/components/info-drawer/info-drawer.component.ts index 70c59e0cb4..8d6cd9e927 100644 --- a/projects/aca-shared/src/lib/components/info-drawer/info-drawer.component.ts +++ b/projects/aca-shared/src/lib/components/info-drawer/info-drawer.component.ts @@ -37,6 +37,7 @@ import { InfoDrawerModule } from '@alfresco/adf-core'; import { TranslateModule } from '@ngx-translate/core'; import { A11yModule } from '@angular/cdk/a11y'; import { ToolbarComponent } from '../toolbar/toolbar.component'; +import { NodeActionsService } from '../../../../../aca-content/src/lib/services/node-actions.service'; @Component({ standalone: true, @@ -64,7 +65,12 @@ export class InfoDrawerComponent implements OnChanges, OnInit, OnDestroy { this.close(); } - constructor(private store: Store, private contentApi: ContentApiService, private extensions: AppExtensionService) {} + constructor( + private store: Store, + private contentApi: ContentApiService, + private extensions: AppExtensionService, + private nodeActionsService: NodeActionsService + ) {} ngOnInit() { this.tabs = this.extensions.getSidebarTabs(); @@ -125,4 +131,8 @@ export class InfoDrawerComponent implements OnChanges, OnInit, OnDestroy { private setDisplayNode(node: any) { this.displayNode = node; } + + getNodeIcon(node: Node): string { + return this.nodeActionsService.getNodeIcon(node); + } } diff --git a/projects/aca-shared/src/lib/components/page-layout/page-layout.component.scss b/projects/aca-shared/src/lib/components/page-layout/page-layout.component.scss index ff881a2cf9..ff8455e474 100644 --- a/projects/aca-shared/src/lib/components/page-layout/page-layout.component.scss +++ b/projects/aca-shared/src/lib/components/page-layout/page-layout.component.scss @@ -38,7 +38,7 @@ .aca-page-layout-content { @include flex-row; - border-top: 1px solid var(--adf-metadata-property-panel-border-color); + border-top: 1px solid var(--theme-metadata-property-panel-border-color); } .aca-page-layout-error {