Skip to content

Commit

Permalink
[ACS-5645]Implemented changes as per review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Yasa-Nataliya committed Sep 8, 2023
1 parent a557d03 commit ba51004
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('DetailsComponent', () => {
let contentApiService: ContentApiService;
let store: Store;
let node: NodeEntry;
let mockNodeAspectService: jasmine.SpyObj<NodeAspectService>;
let nodeAspectService: NodeAspectService;

const mockStream = new Subject();
const storeMock = {
Expand All @@ -51,7 +51,6 @@ describe('DetailsComponent', () => {
};

beforeEach(() => {
const nodeAspectServiceSpy = jasmine.createSpyObj('NodeAspectService', ['updateNodeAspects']);
TestBed.configureTestingModule({
imports: [AppTestingModule, DetailsComponent],
providers: [
Expand Down Expand Up @@ -80,10 +79,6 @@ describe('DetailsComponent', () => {
onLogout: new Subject<any>(),
isLoggedIn: () => true
}
},
{
provide: NodeAspectService,
useValue: nodeAspectServiceSpy
}
],
schemas: [NO_ERRORS_SCHEMA]
Expand All @@ -92,7 +87,7 @@ describe('DetailsComponent', () => {
fixture = TestBed.createComponent(DetailsComponent);
component = fixture.componentInstance;
contentApiService = TestBed.inject(ContentApiService);
mockNodeAspectService = TestBed.inject(NodeAspectService) as jasmine.SpyObj<NodeAspectService>;
nodeAspectService = TestBed.inject(NodeAspectService);
component.node = { id: 'test-id' } as MinimalNodeEntryEntity;
store = TestBed.inject(Store);

Expand All @@ -111,6 +106,7 @@ describe('DetailsComponent', () => {
}
};
spyOn(contentApiService, 'getNode').and.returnValue(of(node));
spyOn(nodeAspectService, 'updateNodeAspects').and.callThrough();
});

afterEach(() => {
Expand All @@ -137,9 +133,9 @@ describe('DetailsComponent', () => {
expect(store.dispatch).toHaveBeenCalledWith(new SetSelectedNodesAction([node]));
});

it('should call openAspectDialog and updateNodeAspects when the button is clicked', () => {
it('should call updateNodeAspects when the button is clicked', () => {
component.openAspectDialog();
fixture.detectChanges();
expect(mockNodeAspectService.updateNodeAspects).toHaveBeenCalledWith('test-id');
expect(nodeAspectService.updateNodeAspects).toHaveBeenCalledWith('test-id');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/

import { Component, OnInit, ViewEncapsulation, OnDestroy, Input } from '@angular/core';
import { Component, OnInit, ViewEncapsulation, OnDestroy } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { ContentApiService, PageComponent, PageLayoutComponent, ToolbarComponent, isLocked } from '@alfresco/aca-shared';
import { NavigateToPreviousPage, SetSelectedNodesAction, getAppSelection } from '@alfresco/aca-shared/store';
Expand All @@ -38,6 +38,7 @@ import { MetadataTabComponent } from '../info-drawer/metadata-tab/metadata-tab.c
import { CommentsTabComponent } from '../info-drawer/comments-tab/comments-tab.component';
import { NodeActionsService } from '../../services/node-actions.service';
import { NodeEntry } from '@alfresco/js-api';
import { takeUntil } from 'rxjs/operators';

@Component({
standalone: true,
Expand All @@ -61,9 +62,6 @@ import { NodeEntry } from '@alfresco/js-api';
encapsulation: ViewEncapsulation.None
})
export class DetailsComponent extends PageComponent implements OnInit, OnDestroy {
@Input()
readOnly = false;

nodeId: string;
isLoading: boolean;
onDestroy$ = new Subject<boolean>();
Expand Down Expand Up @@ -101,7 +99,7 @@ export class DetailsComponent extends PageComponent implements OnInit, OnDestroy
this.store.select(getAppSelection).subscribe(({ file }) => {
this.selectionState = file;
const isNodeLockedFromStore = this.selection && isLocked(this.selectionState);
this.nodeActionsService.isNodeLocked().subscribe((isNodeLockedFromService) => {
this.nodeActionsService.isNodeLocked$.pipe(takeUntil(this.onDestroy$)).subscribe((isNodeLockedFromService) => {
this.isNodeLocked = isNodeLockedFromStore || isNodeLockedFromService;
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ import { Actions, ofType } from '@ngrx/effects';
[preset]="'custom'"
[node]="node"
[displayAspect]="displayAspect$ | async"
[displayTags]="displayTags"
[displayCategories]="displayCategories"
[displayTags]="true"
[displayCategories]="true"
[(editable)]="editable"
[(editableTags)]="editableTags"
[(editableCategories)]="editableCategories"
Expand All @@ -57,18 +57,9 @@ import { Actions, ofType } from '@ngrx/effects';
})
export class MetadataTabComponent implements OnInit, OnDestroy {
protected onDestroy$ = new Subject<boolean>();

@Input()
node: Node;

/** Display tags in the card **/
@Input()
displayTags = true;

/** Display categories in the card **/
@Input()
displayCategories = true;

displayAspect$: Observable<string>;
canUpdateNode = false;
editable = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

import { AppStore, DownloadNodesAction, EditOfflineAction, SnackbarErrorAction, getAppSelection } from '@alfresco/aca-shared/store';
import { NodeEntry, SharedLinkEntry, Node, NodesApi } from '@alfresco/js-api';
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
import { ChangeDetectorRef, Component, OnInit, ViewEncapsulation } from '@angular/core';
import { Store } from '@ngrx/store';
import { isLocked } from '@alfresco/aca-shared';
import { AlfrescoApiService } from '@alfresco/adf-core';
Expand Down Expand Up @@ -60,7 +60,12 @@ export class ToggleEditOfflineComponent implements OnInit {
nodeTitle = '';
isNodeLocked = false;

constructor(private store: Store<AppStore>, private alfrescoApiService: AlfrescoApiService, private nodeActionsService: NodeActionsService) {
constructor(
private store: Store<AppStore>,
private alfrescoApiService: AlfrescoApiService,
private nodeActionsService: NodeActionsService,
private cdr: ChangeDetectorRef
) {
this.nodesApi = new NodesApi(this.alfrescoApiService.getInstance());
}

Expand All @@ -69,6 +74,7 @@ export class ToggleEditOfflineComponent implements OnInit {
this.selection = file;
this.isNodeLocked = this.selection && isLocked(this.selection);
this.nodeTitle = this.isNodeLocked ? 'APP.ACTIONS.EDIT_OFFLINE_CANCEL' : 'APP.ACTIONS.EDIT_OFFLINE';
this.cdr.detectChanges();
});
}

Expand Down
9 changes: 3 additions & 6 deletions projects/aca-content/src/lib/services/node-actions.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ export class NodeActionsService {
contentMoved: Subject<any> = new Subject<any>();
moveDeletedEntries: any[] = [];
isSitesDestinationAvailable = false;
private isNodeLockedSubject: BehaviorSubject<boolean>;
private isNodeLockedSubject = new BehaviorSubject<boolean>(false);
isNodeLocked$: Observable<any>;

_nodesApi: NodesApi;
get nodesApi(): NodesApi {
Expand All @@ -66,7 +67,7 @@ export class NodeActionsService {
private translation: TranslationService,
private thumbnailService: ThumbnailService
) {
this.isNodeLockedSubject = new BehaviorSubject<boolean>(false);
this.isNodeLocked$ = this.isNodeLockedSubject.asObservable();
}

/**
Expand Down Expand Up @@ -95,10 +96,6 @@ export class NodeActionsService {
this.isNodeLockedSubject.next(isLocked);
}

isNodeLocked(): Observable<boolean> {
return this.isNodeLockedSubject.asObservable();
}

/**
* General method for performing the given operation (copy|move) to multiple nodes
*
Expand Down
6 changes: 1 addition & 5 deletions projects/aca-content/src/lib/ui/variables/variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ $search-chip-icon-color: #757575;
$disabled-chip-background-color: #f5f5f5;
$adf-metadata-property-panel-border-color: rgba(0, 0, 0, 0.12);
$adf-metadata-buttons-background-color: rgba(33, 33, 33, 0.05);
$adf-snackbar-message-background-color: #ba1b1b;
$adf-snackbar-message-color: #f8f8f8;

// CSS Variables
$defaults: (
Expand Down Expand Up @@ -80,9 +78,7 @@ $defaults: (
--theme-search-chip-icon-color: $search-chip-icon-color,
--theme-disabled-chip-background-color: $disabled-chip-background-color,
--adf-metadata-property-panel-border-color: $adf-metadata-property-panel-border-color,
--adf-metadata-buttons-background-color: $adf-metadata-buttons-background-color,
--adf-snackbar-message-background-color: $adf-snackbar-message-background-color,
--adf-snackbar-message-color: $adf-snackbar-message-color
--adf-metadata-buttons-background-color: $adf-metadata-buttons-background-color
);

// propagates SCSS variables into the CSS variables scope
Expand Down

0 comments on commit ba51004

Please sign in to comment.