mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
[ACS-5645] Property Panel Feature (#3477)
* [ACS-5540] changes for edit aspect button * added aspect edit button * [ACS-5540]fixed unit test cases and added unit test cases * [ACS-5540] Modified changes * [ACS-5540] fixed file lock issue * [ACS-5645]Implemented changes as per review comments * [ACS-5540]Modified the test case title * [ACS-5645] changes for aspect icon * [ACS-5645] fixed aspect lock issue in small screen * [ACS-5540] modified the aspect button changes * [ACS-5540] modified the changes * [ACS-5645] added unit test cases * [ACS-5540] removed unwanted code * [ACS-5540] fixed lock-file bug * [ACS-5540] revert the unwanted changes * [ACS-5540] modified changes * [ACS-5540]Implemented the changes as per the review comments * [ACS-5540] added group lock changes * [ACS-5540] added tooltip * [ACS-5540] Implemented the review comments * [ACS-5540] added tooltips * [ACS-5540] Added styles * [ACS-5540]Added focus * [ACS-5551]updated property panel design * [ACS-5551]added null checks * [ACS-5551] update style * [ACS-5540] changes for edit aspect button * added aspect edit button * [ACS-5540]fixed unit test cases and added unit test cases * [ACS-5540] Modified changes * [ACS-5645]Implemented changes as per review comments * [ACS-5645] changes for aspect icon * [ACS-5540] modified the aspect button changes * [ACS-5540] modified the changes * [ACS-5540] revert the unwanted changes * [ACS-5540] added group lock changes * [ACS-5551]updated property panel design * [ACS-5551]added null checks * [ACS-5551] update style * [ACS-5551] name updated * [ACS-5551] unit test fix * [ACS-5551] header issue fixed * [ACS-5645] style updated * [ACS-5645] border updated * [ACS-6117] fixed aspect dispaly issue * [ACS-5645] different node open issu fixed * [ACS-5645] unit test issue fix * [ACS-5645] unit test fix * [ACS-5645] tabs design modify * [ACS-5645] dependency updated * [link-adf:ACS-564 5-property-panel-feature] test linking * "[link-adf:ACS-5645-property-panel-feature]" * [ACS-5645] revert adf linking changes * add adf configs to libs * fix issue with empty paths * try using adf target * [link-adf:ACS-5645-property-panel-feature] fix core mapping * [link-adf:ACS-5645-property-panel-feature] revert target changes * remove useless styles * remove css hacks * cleanup useless properties * remove useless properties * remove useless code * [ACS-5645] added missing code * [ACS-5654] add icon for full screen * [ACS-5654] nodei con methods moved to thumbnail * [ACS-5654] unit test added and code refactor * [ACS-5645] unit test added * [ACS-5645] panel issue fix * [ACS-5645] removed unit test for editable property * [ACS-5645] removed unused unit test * [ACS-5645] unit test updated * [ACS-5645] updated the unit test * Modified the unit test cases for getNodeIcon * Upsteam ADF-6.6.0-7287333895, Js-api-7.5.0-7287333895 version * Fix failing test cases * Fix failing e2e --------- Co-authored-by: Yasa-Nataliya <yasa.nataliya@globallogic.com> Co-authored-by: pkundu <priyanka.kundu@hyland.com> Co-authored-by: Denys Vuika <denys.vuika@gmail.com> Co-authored-by: rbahirsheth <raviraj.bahirsheth@globallogic.com>
This commit is contained in:
@@ -192,6 +192,8 @@ export class ContentServiceExtensionModule {
|
||||
canToggleFavorite: rules.canToggleFavorite,
|
||||
isLibraryManager: rules.isLibraryManager,
|
||||
canEditAspects: rules.canEditAspects,
|
||||
editAspects: rules.editAspects,
|
||||
canShowExpand: rules.canShowExpand,
|
||||
canInfoPreview: rules.canInfoPreview,
|
||||
showInfoSelectionButton: rules.showInfoSelectionButton,
|
||||
|
||||
|
@@ -8,18 +8,21 @@
|
||||
<div class="aca-details-container">
|
||||
<div class="aca-details-title">
|
||||
<div class="aca-details-breadcrumb" role="heading" aria-level="2" *ngIf="node">
|
||||
<span class="aca-details-breadcrumb-library"> {{ node.name }} </span>
|
||||
-
|
||||
<span class="aca-details-breadcrumb-item">{{ 'APP.INFO_DRAWER.TITLE' | translate }}</span>
|
||||
<span class="aca-details-breadcrumb-library">
|
||||
<img class="aca-details-breadcrumb-icon" alt="{{ 'APP.INFO_DRAWER.ICON' | translate }}" src="{{ nodeIcon }}">
|
||||
{{ node.name }} </span>
|
||||
</div>
|
||||
<div class="acs-details-buttons">
|
||||
<aca-toolbar [items]="aspectActions" info-drawer-buttons></aca-toolbar>
|
||||
<button
|
||||
class="aca-close-details-button"
|
||||
mat-icon-button
|
||||
data-automation-id="close-library"
|
||||
title="{{ 'APP.INFO_DRAWER.REDUCE_PANEL' | translate }}"
|
||||
(click)="goBack()">
|
||||
<mat-icon>fullscreen_exit</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
<button
|
||||
class="aca-close-details-button"
|
||||
mat-icon-button
|
||||
data-automation-id="close-library"
|
||||
title="{{ 'APP.INFO_DRAWER.CLOSE' | translate }}"
|
||||
(click)="goBack()">
|
||||
<mat-icon>fullscreen_exit</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<mat-tab-group [selectedIndex]="activeTab" class="aca-details-tabs" animationDuration="0">
|
||||
|
@@ -1,19 +1,18 @@
|
||||
app-details-manager {
|
||||
.aca-close-details-button {
|
||||
margin-right: 15px;
|
||||
margin-top: 2px;
|
||||
outline: none;
|
||||
border-radius: 4px;
|
||||
.acs-details-buttons {
|
||||
display: flex;
|
||||
|
||||
&:focus {
|
||||
background-color: var(--theme-selected-background-color);
|
||||
outline: 2px solid var(--theme-blue-button-color);
|
||||
.aca-close-details-button {
|
||||
margin-right: 15px;
|
||||
margin-top: 12px;
|
||||
outline: none;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
&:focus-visible {
|
||||
outline: 2px solid var(--theme-blue-button-color);
|
||||
border-radius: 4px;
|
||||
&:focus {
|
||||
background-color: var(--theme-selected-background-color);
|
||||
outline: 2px solid var(--theme-blue-button-color);
|
||||
border-radius: 4px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,14 +24,23 @@ app-details-manager {
|
||||
|
||||
.aca-details-tabs {
|
||||
margin-top: 40px;
|
||||
height: calc(100% - 80px);
|
||||
height: calc(100% - 136px);
|
||||
|
||||
.mat-tab-body-wrapper {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
mat-tab-header {
|
||||
text-transform: uppercase;
|
||||
.mat-tab-list {
|
||||
margin-left: 50px;
|
||||
|
||||
.mat-tab-labels {
|
||||
.mat-tab-label {
|
||||
padding: 0 12px;
|
||||
min-width: 95px;
|
||||
letter-spacing: 0.25px;
|
||||
height: 32px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,17 +49,24 @@ app-details-manager {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
color: var(--theme-metadata-property-panel-title-color);
|
||||
text-overflow: ellipsis;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.aca-details-breadcrumb {
|
||||
font-size: 18px;
|
||||
margin-left: 20px;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
|
||||
&-library {
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
&-item {
|
||||
font-weight: 100;
|
||||
&-icon {
|
||||
display: inline-block;
|
||||
vertical-align: text-bottom;
|
||||
}
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { AppTestingModule } from '../../testing/app-testing.module';
|
||||
import { DetailsComponent } from './details.component';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { of, Subject } from 'rxjs';
|
||||
import { BehaviorSubject, of, Subject } from 'rxjs';
|
||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { ContentApiService } from '@alfresco/aca-shared';
|
||||
@@ -34,13 +34,15 @@ import { STORE_INITIAL_APP_DATA, SetSelectedNodesAction, NavigateToFolder } from
|
||||
import { NodeEntry, PathElement } from '@alfresco/js-api';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { AuthenticationService, PageTitleService } from '@alfresco/adf-core';
|
||||
import { BreadcrumbComponent, SearchQueryBuilderService } from '@alfresco/adf-content-services';
|
||||
import { BreadcrumbComponent, ContentService, SearchQueryBuilderService } from '@alfresco/adf-content-services';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { ContentActionRef } from '@alfresco/adf-extensions';
|
||||
|
||||
describe('DetailsComponent', () => {
|
||||
let component: DetailsComponent;
|
||||
let fixture: ComponentFixture<DetailsComponent>;
|
||||
let contentApiService: ContentApiService;
|
||||
let contentService: ContentService;
|
||||
let store: Store;
|
||||
let node: NodeEntry;
|
||||
|
||||
@@ -50,6 +52,15 @@ describe('DetailsComponent', () => {
|
||||
select: () => mockStream
|
||||
};
|
||||
|
||||
const extensionsServiceMock = {
|
||||
getAllowedSidebarActions: jasmine.createSpy('getAllowedSidebarActions')
|
||||
};
|
||||
|
||||
const mockAspectActions: ContentActionRef[] = [];
|
||||
|
||||
const mockAspectActionsSubject$ = new BehaviorSubject(mockAspectActions);
|
||||
extensionsServiceMock.getAllowedSidebarActions.and.returnValue(mockAspectActionsSubject$.asObservable());
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [AppTestingModule, DetailsComponent],
|
||||
@@ -87,6 +98,7 @@ describe('DetailsComponent', () => {
|
||||
fixture = TestBed.createComponent(DetailsComponent);
|
||||
component = fixture.componentInstance;
|
||||
contentApiService = TestBed.inject(ContentApiService);
|
||||
contentService = TestBed.inject(ContentService);
|
||||
store = TestBed.inject(Store);
|
||||
|
||||
node = {
|
||||
@@ -140,4 +152,53 @@ describe('DetailsComponent', () => {
|
||||
fixture.detectChanges();
|
||||
expect(store.dispatch).toHaveBeenCalledWith(new SetSelectedNodesAction([node]));
|
||||
});
|
||||
|
||||
it('should set aspectActions from extensions', async () => {
|
||||
extensionsServiceMock.getAllowedSidebarActions.and.returnValue(of(mockAspectActions));
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable().then(() => {
|
||||
expect(component.aspectActions).toEqual(mockAspectActions);
|
||||
});
|
||||
});
|
||||
|
||||
it('should return the icon when getNodeIcon is called', () => {
|
||||
const expectedIcon = 'assets/images/ft_ic_folder';
|
||||
spyOn(contentService, 'getNodeIcon').and.returnValue(expectedIcon);
|
||||
fixture.detectChanges();
|
||||
component.ngOnInit();
|
||||
expect(contentService.getNodeIcon).toHaveBeenCalled();
|
||||
expect(component.nodeIcon).toContain(expectedIcon);
|
||||
});
|
||||
|
||||
it('should set aspectActions from extension mock', () => {
|
||||
const extensionMock = {
|
||||
getAllowedSidebarActions: () =>
|
||||
of([
|
||||
{
|
||||
id: 'app.sidebar.close',
|
||||
order: 100,
|
||||
title: 'close',
|
||||
icon: 'highlight_off'
|
||||
}
|
||||
])
|
||||
};
|
||||
|
||||
extensionsServiceMock.getAllowedSidebarActions.and.returnValue(of(extensionMock));
|
||||
fixture.detectChanges();
|
||||
fixture
|
||||
.whenStable()
|
||||
.then(() => {
|
||||
expect(component.aspectActions).toEqual([
|
||||
{
|
||||
id: 'app.sidebar.close',
|
||||
order: 100,
|
||||
title: 'close',
|
||||
icon: 'highlight_off'
|
||||
} as ContentActionRef
|
||||
]);
|
||||
})
|
||||
.catch((error) => {
|
||||
fail(`An error occurred: ${error}`);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -27,7 +27,7 @@ import { ActivatedRoute } from '@angular/router';
|
||||
import { ContentApiService, PageComponent, PageLayoutComponent, ToolbarComponent } from '@alfresco/aca-shared';
|
||||
import { NavigateToFolder, NavigateToPreviousPage, SetSelectedNodesAction } from '@alfresco/aca-shared/store';
|
||||
import { Subject } from 'rxjs';
|
||||
import { BreadcrumbModule, PermissionManagerModule } from '@alfresco/adf-content-services';
|
||||
import { BreadcrumbModule, ContentService, PermissionManagerModule } from '@alfresco/adf-content-services';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
@@ -37,6 +37,8 @@ import { MatButtonModule } from '@angular/material/button';
|
||||
import { MetadataTabComponent } from '../info-drawer/metadata-tab/metadata-tab.component';
|
||||
import { CommentsTabComponent } from '../info-drawer/comments-tab/comments-tab.component';
|
||||
import { NodeEntry, PathElement } from '@alfresco/js-api';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
import { ContentActionRef } from '@alfresco/adf-extensions';
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
@@ -64,8 +66,10 @@ export class DetailsComponent extends PageComponent implements OnInit, OnDestroy
|
||||
isLoading: boolean;
|
||||
onDestroy$ = new Subject<boolean>();
|
||||
activeTab = 1;
|
||||
aspectActions: Array<ContentActionRef> = [];
|
||||
nodeIcon: string;
|
||||
|
||||
constructor(private route: ActivatedRoute, private contentApi: ContentApiService) {
|
||||
constructor(private route: ActivatedRoute, private contentApi: ContentApiService, private contentService: ContentService) {
|
||||
super();
|
||||
}
|
||||
|
||||
@@ -84,8 +88,15 @@ export class DetailsComponent extends PageComponent implements OnInit, OnDestroy
|
||||
this.node = node.entry;
|
||||
this.isLoading = false;
|
||||
this.store.dispatch(new SetSelectedNodesAction([{ entry: this.node }]));
|
||||
this.nodeIcon = this.contentService.getNodeIcon(this.node);
|
||||
});
|
||||
});
|
||||
this.extensions
|
||||
.getAllowedSidebarActions()
|
||||
.pipe(takeUntil(this.onDestroy$))
|
||||
.subscribe((aspectActions) => {
|
||||
this.aspectActions = aspectActions;
|
||||
});
|
||||
}
|
||||
|
||||
setActiveTab(tabName: string) {
|
||||
|
@@ -27,24 +27,23 @@ import { Node } from '@alfresco/js-api';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { AppTestingModule } from '../../../testing/app-testing.module';
|
||||
import { AppConfigService } from '@alfresco/adf-core';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { AppState, EditOfflineAction, SetInfoDrawerMetadataAspectAction } from '@alfresco/aca-shared/store';
|
||||
import { EditOfflineAction } from '@alfresco/aca-shared/store';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { AppExtensionService, NodePermissionService } from '@alfresco/aca-shared';
|
||||
import { Actions } from '@ngrx/effects';
|
||||
import { of, Subject } from 'rxjs';
|
||||
import { ContentActionType } from '@alfresco/adf-extensions';
|
||||
import { CategoryService, ContentMetadataCardComponent, TagService } from '@alfresco/adf-content-services';
|
||||
import { CategoryService, ContentMetadataComponent, ContentMetadataService, TagService } from '@alfresco/adf-content-services';
|
||||
|
||||
describe('MetadataTabComponent', () => {
|
||||
let fixture: ComponentFixture<MetadataTabComponent>;
|
||||
let component: MetadataTabComponent;
|
||||
let store: Store<AppState>;
|
||||
let appConfig: AppConfigService;
|
||||
let extensions: AppExtensionService;
|
||||
let nodePermissionService: NodePermissionService;
|
||||
let actions$: Subject<EditOfflineAction>;
|
||||
let appExtensionService: AppExtensionService;
|
||||
let contentMetadataService: ContentMetadataService;
|
||||
|
||||
const presets = {
|
||||
default: {
|
||||
@@ -65,9 +64,11 @@ describe('MetadataTabComponent', () => {
|
||||
});
|
||||
nodePermissionService = TestBed.inject(NodePermissionService);
|
||||
appExtensionService = TestBed.inject(AppExtensionService);
|
||||
contentMetadataService = TestBed.inject(ContentMetadataService);
|
||||
spyOn(nodePermissionService, 'check').and.callFake((source: Node, permissions: string[]) => {
|
||||
return permissions.some((permission) => source.allowableOperations.includes(permission));
|
||||
});
|
||||
spyOn(contentMetadataService, 'getGroupedProperties').and.returnValue(of());
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@@ -99,40 +100,40 @@ describe('MetadataTabComponent', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('canUpdateNode', () => {
|
||||
describe('readOnly', () => {
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(MetadataTabComponent);
|
||||
component = fixture.componentInstance;
|
||||
});
|
||||
|
||||
it('should return true if node is not locked and has update permission', async () => {
|
||||
it('should return false if node is not locked and has update permission', async () => {
|
||||
component.node = {
|
||||
isLocked: false,
|
||||
allowableOperations: ['update']
|
||||
} as Node;
|
||||
component.ngOnInit();
|
||||
expect(component.canUpdateNode).toBe(true);
|
||||
expect(component.readOnly).toBe(false);
|
||||
});
|
||||
|
||||
it('should return false if node is locked', () => {
|
||||
it('should return true if node is locked', () => {
|
||||
component.node = {
|
||||
isLocked: true,
|
||||
allowableOperations: ['update']
|
||||
} as Node;
|
||||
component.ngOnInit();
|
||||
expect(component.canUpdateNode).toBe(false);
|
||||
expect(component.readOnly).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false if node has no update permission', () => {
|
||||
it('should return true if node has no update permission', () => {
|
||||
component.node = {
|
||||
isLocked: false,
|
||||
allowableOperations: ['other']
|
||||
} as Node;
|
||||
component.ngOnInit();
|
||||
expect(component.canUpdateNode).toBe(false);
|
||||
expect(component.readOnly).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false if node has read only property', () => {
|
||||
it('should return true if node has read only property', () => {
|
||||
component.node = {
|
||||
isLocked: false,
|
||||
allowableOperations: ['update'],
|
||||
@@ -141,7 +142,7 @@ describe('MetadataTabComponent', () => {
|
||||
}
|
||||
} as Node;
|
||||
component.ngOnInit();
|
||||
expect(component.canUpdateNode).toBe(false);
|
||||
expect(component.readOnly).toBe(true);
|
||||
});
|
||||
|
||||
describe('set by triggering EditOfflineAction', () => {
|
||||
@@ -160,124 +161,50 @@ describe('MetadataTabComponent', () => {
|
||||
id: component.node.id
|
||||
} as Node
|
||||
});
|
||||
component.canUpdateNode = true;
|
||||
component.readOnly = true;
|
||||
});
|
||||
|
||||
it('should have set true if node is not locked and has update permission', () => {
|
||||
component.canUpdateNode = false;
|
||||
it('should have set false if node is not locked and has update permission', () => {
|
||||
component.readOnly = true;
|
||||
actions$.next(editOfflineAction);
|
||||
expect(component.canUpdateNode).toBeTrue();
|
||||
expect(component.readOnly).toBeFalse();
|
||||
});
|
||||
|
||||
it('should not have set false if changed node has different id than original', () => {
|
||||
editOfflineAction.payload.entry.id = 'some other id';
|
||||
editOfflineAction.payload.entry.isLocked = true;
|
||||
actions$.next(editOfflineAction);
|
||||
expect(component.canUpdateNode).toBeTrue();
|
||||
expect(component.readOnly).toBeTrue();
|
||||
});
|
||||
|
||||
it('should have set false if node is locked', () => {
|
||||
it('should have set true if node is locked', () => {
|
||||
editOfflineAction.payload.entry.isLocked = true;
|
||||
actions$.next(editOfflineAction);
|
||||
expect(component.canUpdateNode).toBeFalse();
|
||||
expect(component.readOnly).toBeTrue();
|
||||
});
|
||||
|
||||
it('should have set false if node has no update permission', () => {
|
||||
it('should have set true if node has no update permission', () => {
|
||||
editOfflineAction.payload.entry.allowableOperations = ['other'];
|
||||
actions$.next(editOfflineAction);
|
||||
expect(component.canUpdateNode).toBeFalse();
|
||||
expect(component.readOnly).toBeTrue();
|
||||
});
|
||||
|
||||
it('should have set false if node has read only property', () => {
|
||||
it('should have set true if node has read only property', () => {
|
||||
editOfflineAction.payload.entry.properties = {
|
||||
'cm:lockType': 'WRITE_LOCK'
|
||||
};
|
||||
actions$.next(editOfflineAction);
|
||||
expect(component.canUpdateNode).toBeFalse();
|
||||
expect(component.readOnly).toBeTrue();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('editable', () => {
|
||||
let editOfflineAction: EditOfflineAction;
|
||||
describe('ContentMetadataComponent', () => {
|
||||
const getContentMetadata = (): ContentMetadataComponent => fixture.debugElement.query(By.directive(ContentMetadataComponent)).componentInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(MetadataTabComponent);
|
||||
component = fixture.componentInstance;
|
||||
component.node = {
|
||||
id: 'some id',
|
||||
allowableOperations: []
|
||||
} as Node;
|
||||
component.ngOnInit();
|
||||
editOfflineAction = new EditOfflineAction({
|
||||
entry: {
|
||||
isLocked: false,
|
||||
allowableOperations: ['update'],
|
||||
id: component.node.id
|
||||
} as Node
|
||||
});
|
||||
component.editable = true;
|
||||
});
|
||||
|
||||
it('should not have set false if node is not locked and has update permission', () => {
|
||||
actions$.next(editOfflineAction);
|
||||
expect(component.editable).toBeTrue();
|
||||
});
|
||||
|
||||
it('should not have set false if changed node has different id than original', () => {
|
||||
editOfflineAction.payload.entry.id = 'some other id';
|
||||
editOfflineAction.payload.entry.isLocked = true;
|
||||
actions$.next(editOfflineAction);
|
||||
expect(component.editable).toBeTrue();
|
||||
});
|
||||
|
||||
it('should have set false if node is locked', () => {
|
||||
editOfflineAction.payload.entry.isLocked = true;
|
||||
actions$.next(editOfflineAction);
|
||||
expect(component.editable).toBeFalse();
|
||||
});
|
||||
|
||||
it('should have set false if node has no update permission', () => {
|
||||
editOfflineAction.payload.entry.allowableOperations = ['other'];
|
||||
actions$.next(editOfflineAction);
|
||||
expect(component.editable).toBeFalse();
|
||||
});
|
||||
|
||||
it('should have set false if node has read only property', () => {
|
||||
editOfflineAction.payload.entry.properties = {
|
||||
'cm:lockType': 'WRITE_LOCK'
|
||||
};
|
||||
actions$.next(editOfflineAction);
|
||||
expect(component.editable).toBeFalse();
|
||||
});
|
||||
});
|
||||
|
||||
describe('ContentMetadataCardComponent', () => {
|
||||
const getContentMetadataCard = (): ContentMetadataCardComponent =>
|
||||
fixture.debugElement.query(By.directive(ContentMetadataCardComponent)).componentInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(MetadataTabComponent);
|
||||
component = fixture.componentInstance;
|
||||
});
|
||||
|
||||
describe('displayAspect', () => {
|
||||
beforeEach(() => {
|
||||
store = TestBed.inject(Store);
|
||||
});
|
||||
|
||||
it('should show pass empty when store is in initial state', () => {
|
||||
expect(getContentMetadataCard().displayAspect).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should update the exif if store got updated', () => {
|
||||
store.dispatch(new SetInfoDrawerMetadataAspectAction('EXIF'));
|
||||
component.displayAspect$.subscribe((aspect) => {
|
||||
expect(aspect).toBe('EXIF');
|
||||
});
|
||||
fixture.detectChanges();
|
||||
expect(getContentMetadataCard().displayAspect).toBe('EXIF');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Tags and categories', () => {
|
||||
@@ -287,7 +214,7 @@ describe('MetadataTabComponent', () => {
|
||||
|
||||
fixture.detectChanges();
|
||||
expect(categoryService.areCategoriesEnabled).toHaveBeenCalled();
|
||||
expect(getContentMetadataCard().displayCategories).toBeTrue();
|
||||
expect(getContentMetadata().displayCategories).toBeTrue();
|
||||
});
|
||||
|
||||
it('should have assigned displayCategories to false if categoryService.areCategoriesEnabled returns false', () => {
|
||||
@@ -296,7 +223,7 @@ describe('MetadataTabComponent', () => {
|
||||
|
||||
fixture.detectChanges();
|
||||
expect(categoryService.areCategoriesEnabled).toHaveBeenCalled();
|
||||
expect(getContentMetadataCard().displayCategories).toBeFalse();
|
||||
expect(getContentMetadata().displayCategories).toBeFalse();
|
||||
});
|
||||
|
||||
it('should have assigned displayTags to true if tagService.areTagsEnabled returns true', () => {
|
||||
@@ -305,7 +232,7 @@ describe('MetadataTabComponent', () => {
|
||||
|
||||
fixture.detectChanges();
|
||||
expect(tagService.areTagsEnabled).toHaveBeenCalled();
|
||||
expect(getContentMetadataCard().displayTags).toBeTrue();
|
||||
expect(getContentMetadata().displayTags).toBeTrue();
|
||||
});
|
||||
|
||||
it('should have assigned displayTags to false if tagService.areTagsEnabled returns false', () => {
|
||||
@@ -314,7 +241,7 @@ describe('MetadataTabComponent', () => {
|
||||
|
||||
fixture.detectChanges();
|
||||
expect(tagService.areTagsEnabled).toHaveBeenCalled();
|
||||
expect(getContentMetadataCard().displayTags).toBeFalse();
|
||||
expect(getContentMetadata().displayTags).toBeFalse();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -25,10 +25,9 @@
|
||||
import { Component, Input, ViewEncapsulation, OnInit, OnDestroy } from '@angular/core';
|
||||
import { Node } from '@alfresco/js-api';
|
||||
import { NodePermissionService, isLocked, AppExtensionService } from '@alfresco/aca-shared';
|
||||
import { AppStore, EditOfflineAction, infoDrawerMetadataAspect, NodeActionTypes } from '@alfresco/aca-shared/store';
|
||||
import { EditOfflineAction, NodeActionTypes } from '@alfresco/aca-shared/store';
|
||||
import { AppConfigService, NotificationService } from '@alfresco/adf-core';
|
||||
import { Observable, Subject } from 'rxjs';
|
||||
import { Store } from '@ngrx/store';
|
||||
import {
|
||||
ContentMetadataModule,
|
||||
ContentMetadataService,
|
||||
@@ -45,17 +44,15 @@ import { Actions, ofType } from '@ngrx/effects';
|
||||
imports: [CommonModule, ContentMetadataModule],
|
||||
selector: 'app-metadata-tab',
|
||||
template: `
|
||||
<adf-content-metadata-card
|
||||
[readOnly]="!canUpdateNode"
|
||||
<adf-content-metadata
|
||||
[readOnly]="readOnly"
|
||||
[preset]="'custom'"
|
||||
[node]="node"
|
||||
[displayAspect]="displayAspect$ | async"
|
||||
[customPanels]="customPanels | async"
|
||||
[(editable)]="editable"
|
||||
[displayCategories]="displayCategories"
|
||||
[displayTags]="displayTags"
|
||||
>
|
||||
</adf-content-metadata-card>
|
||||
</adf-content-metadata>
|
||||
`,
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
host: { class: 'app-metadata-tab' }
|
||||
@@ -68,15 +65,12 @@ export class MetadataTabComponent implements OnInit, OnDestroy {
|
||||
@Input()
|
||||
node: Node;
|
||||
|
||||
displayAspect$: Observable<string>;
|
||||
canUpdateNode = false;
|
||||
editable = false;
|
||||
readOnly = false;
|
||||
customPanels: Observable<ContentMetadataCustomPanel[]>;
|
||||
|
||||
get displayCategories(): boolean {
|
||||
return this._displayCategories;
|
||||
}
|
||||
|
||||
get displayTags(): boolean {
|
||||
return this._displayTags;
|
||||
}
|
||||
@@ -85,7 +79,6 @@ export class MetadataTabComponent implements OnInit, OnDestroy {
|
||||
private permission: NodePermissionService,
|
||||
protected extensions: AppExtensionService,
|
||||
private appConfig: AppConfigService,
|
||||
private store: Store<AppStore>,
|
||||
private notificationService: NotificationService,
|
||||
private contentMetadataService: ContentMetadataService,
|
||||
private actions$: Actions,
|
||||
@@ -95,12 +88,12 @@ export class MetadataTabComponent implements OnInit, OnDestroy {
|
||||
if (this.extensions.contentMetadata) {
|
||||
this.appConfig.config['content-metadata'].presets = this.extensions.contentMetadata.presets;
|
||||
}
|
||||
this.displayAspect$ = this.store.select(infoDrawerMetadataAspect);
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this._displayTags = this.tagService.areTagsEnabled();
|
||||
this._displayCategories = this.categoryService.areCategoriesEnabled();
|
||||
|
||||
this.contentMetadataService.error.pipe(takeUntil(this.onDestroy$)).subscribe((err: { message: string }) => {
|
||||
this.notificationService.showError(err.message);
|
||||
});
|
||||
@@ -113,9 +106,6 @@ export class MetadataTabComponent implements OnInit, OnDestroy {
|
||||
)
|
||||
.subscribe((updatedNode) => {
|
||||
this.checkIfNodeIsUpdatable(updatedNode?.payload.entry);
|
||||
if (!this.canUpdateNode) {
|
||||
this.editable = false;
|
||||
}
|
||||
});
|
||||
this.customPanels = this.extensions.getCustomMetadataPanels({ entry: this.node }).pipe(
|
||||
map((panels) => {
|
||||
@@ -133,6 +123,6 @@ export class MetadataTabComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
private checkIfNodeIsUpdatable(node: Node) {
|
||||
this.canUpdateNode = node && !isLocked({ entry: node }) ? this.permission.check(node, ['update']) : false;
|
||||
this.readOnly = !(node && !isLocked({ entry: node }) ? this.permission.check(node, ['update']) : false);
|
||||
}
|
||||
}
|
||||
|
@@ -29,6 +29,7 @@ import { Store } from '@ngrx/store';
|
||||
import { NodeEntry } from '@alfresco/js-api';
|
||||
import { DownloadNodesAction, EditOfflineAction, SnackbarErrorAction } from '@alfresco/aca-shared/store';
|
||||
import { AppTestingModule } from '../../../testing/app-testing.module';
|
||||
import { AppExtensionService } from '@alfresco/aca-shared';
|
||||
|
||||
describe('ToggleEditOfflineComponent', () => {
|
||||
let fixture: ComponentFixture<ToggleEditOfflineComponent>;
|
||||
@@ -38,6 +39,10 @@ describe('ToggleEditOfflineComponent', () => {
|
||||
let selectSpy: jasmine.Spy;
|
||||
let selection: any;
|
||||
|
||||
const extensionsMock = {
|
||||
updateSidebarActions: jasmine.createSpy('updateSidebarActions')
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [AppTestingModule, ToggleEditOfflineComponent],
|
||||
@@ -48,6 +53,10 @@ describe('ToggleEditOfflineComponent', () => {
|
||||
select: () => {},
|
||||
dispatch: () => {}
|
||||
}
|
||||
},
|
||||
{
|
||||
provide: AppExtensionService,
|
||||
useValue: extensionsMock
|
||||
}
|
||||
]
|
||||
});
|
||||
@@ -133,4 +142,14 @@ describe('ToggleEditOfflineComponent', () => {
|
||||
})
|
||||
]);
|
||||
});
|
||||
|
||||
it('should call updateSidebarActions on click', async () => {
|
||||
selectSpy.and.returnValue(of(selection));
|
||||
fixture.detectChanges();
|
||||
|
||||
await component.onClick();
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(extensionsMock.updateSidebarActions).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
@@ -33,7 +33,7 @@ import {
|
||||
import { NodeEntry, SharedLinkEntry, Node, NodesApi } from '@alfresco/js-api';
|
||||
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { isLocked } from '@alfresco/aca-shared';
|
||||
import { AppExtensionService, isLocked } from '@alfresco/aca-shared';
|
||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
@@ -59,7 +59,7 @@ export class ToggleEditOfflineComponent implements OnInit {
|
||||
nodeTitle = '';
|
||||
isNodeLocked = false;
|
||||
|
||||
constructor(private store: Store<AppStore>, private alfrescoApiService: AlfrescoApiService) {
|
||||
constructor(private store: Store<AppStore>, private alfrescoApiService: AlfrescoApiService, private extensions: AppExtensionService) {
|
||||
this.nodesApi = new NodesApi(this.alfrescoApiService.getInstance());
|
||||
}
|
||||
|
||||
@@ -73,6 +73,7 @@ export class ToggleEditOfflineComponent implements OnInit {
|
||||
|
||||
async onClick() {
|
||||
await this.toggleLock(this.selection);
|
||||
this.extensions.updateSidebarActions();
|
||||
}
|
||||
|
||||
private async toggleLock(node: NodeEntry | SharedLinkEntry) {
|
||||
|
@@ -107,6 +107,7 @@ describe('NodeActionsService', () => {
|
||||
service = TestBed.inject(NodeActionsService);
|
||||
apiService = TestBed.inject(AlfrescoApiService);
|
||||
dialog = TestBed.inject(MatDialog);
|
||||
|
||||
apiService.reset();
|
||||
|
||||
nodesApi = service['nodesApi'];
|
||||
|
@@ -25,7 +25,7 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { Observable, Subject, of, zip, from } from 'rxjs';
|
||||
import { AlfrescoApiService, TranslationService, ThumbnailService } from '@alfresco/adf-core';
|
||||
import { AlfrescoApiService, ThumbnailService, TranslationService } from '@alfresco/adf-core';
|
||||
import {
|
||||
DocumentListService,
|
||||
ContentNodeSelectorComponent,
|
||||
|
@@ -389,7 +389,7 @@ describe('NodeEffects', () => {
|
||||
});
|
||||
|
||||
it('should manage permissions from the active selection', () => {
|
||||
spyOn(store, 'select').and.returnValue(of({ isEmpty: false, first: { entry: { id: 'fileId' } } }));
|
||||
spyOn(store, 'select').and.returnValue(of({ isEmpty: false, last: { entry: { id: 'fileId' } } }));
|
||||
spyOn(router, 'navigate').and.stub();
|
||||
store.dispatch(new ManagePermissionsAction(null));
|
||||
|
||||
|
@@ -293,7 +293,7 @@ export class NodeEffects {
|
||||
.subscribe((selection) => {
|
||||
if (selection && !selection.isEmpty) {
|
||||
const route = 'personal-files/details';
|
||||
this.store.dispatch(new NavigateRouteAction([route, selection.first.entry.id, 'permissions']));
|
||||
this.store.dispatch(new NavigateRouteAction([route, selection.last.entry.id, 'permissions']));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -321,7 +321,7 @@ export class NodeEffects {
|
||||
.subscribe((selection) => {
|
||||
if (selection && !selection.isEmpty) {
|
||||
const route = 'personal-files/details';
|
||||
this.router.navigate([route, selection.first.entry.id], {
|
||||
this.router.navigate([route, selection.last.entry.id], {
|
||||
queryParams: {
|
||||
location: this.router.url
|
||||
}
|
||||
|
@@ -49,10 +49,11 @@ ng-component {
|
||||
|
||||
.aca-sidebar {
|
||||
display: block;
|
||||
height: 100%;
|
||||
overflow-y: scroll;
|
||||
max-width: 350px;
|
||||
width: 350px;
|
||||
max-width: 368px;
|
||||
width: 368px;
|
||||
margin-bottom: 65px;
|
||||
border-top: 1px solid var(--theme-metadata-property-panel-border-color);
|
||||
border-bottom: 1px solid var(--theme-metadata-property-panel-border-color);
|
||||
}
|
||||
|
||||
.aca-page-title {
|
||||
|
@@ -156,8 +156,8 @@
|
||||
}
|
||||
|
||||
.mat-expansion-panel .mat-expansion-panel-header {
|
||||
border: 2px solid transparent;
|
||||
box-sizing: border-box;
|
||||
border: 2px solid transparent;
|
||||
|
||||
.mat-button-base.mat-button {
|
||||
outline: none;
|
||||
|
Reference in New Issue
Block a user