Skip to content

Commit

Permalink
[ACS-6252] support disabling the tags and categories feature in the a…
Browse files Browse the repository at this point in the history
…pplications (#9106)

* ACS-6252 Added rules field to SearchCategory interface

* ACS-6252 Hide aspects related with tags and categories if tags and categories features  are disabled

* ACS-6252 Return from services information if tags and categories are disabled

* ACS-6252 Unit tests for changes in AspectListDialogComponent

* ACS-6252 Unit tests for changes for AspectListComponent

* ACS-6252 Unit tests for DialogAspectListService

* ACS-6252 Unit tests for changes for TagService and CategoryService

* ACS-6252 Updated documentation for changes

* ACS-6252 Fixed imports formatting

* ACS-6252 Fix after rebasing

* ACS-6252 Addressed PR comments

* ACS-6252 Excluded e2es
  • Loading branch information
AleksanderSklorz authored Nov 28, 2023
1 parent 979bf3a commit 7793aba
Show file tree
Hide file tree
Showing 18 changed files with 337 additions and 154 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface AspectListDialogComponentData {
overTableMessage: string;
select: Subject<string[]>;
nodeId?: string;
excludedAspects?: string[];
}
```

Expand All @@ -41,6 +42,7 @@ The properties are described in the table below:
| overTableMessage | `string` | "" | Text that will be showed on the top of the aspect list table |
| select | [`Subject<Node>`](https://github.com/Alfresco/alfresco-js-api/blob/develop/src/api/content-rest-api/docs/Node.md) | | Event emitted with the current node selection when the dialog closes |
| nodeId | `string` | "" | Identifier of a node to apply aspects to. |
| excludedAspects | `string[]` | undefined | List of aspects' ids which should not be displayed. |

If you don't want to manage the dialog yourself then it is easier to use the
[Aspect List component](aspect-list.component.md), or the
Expand Down
1 change: 1 addition & 0 deletions docs/content-services/components/aspect-list.component.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ The aspect are filtered via the app.config.json in this way :
| Name | Type | Default value | Description |
| ---- | ---- | ------------- | ----------- |
| nodeId | `string` | "" | Node Id of the node that we want to update |
| excludedAspects | `string[]` | undefined | List of aspects' ids which should not be displayed. |

### Events

Expand Down
3 changes: 3 additions & 0 deletions docs/content-services/services/category.service.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ Manages categories in Content Services.
- _nodeId:_ `string` - The identifier of a node.
- _categoryLinkBodyCreate:_ [`CategoryLinkBody[]`](https://github.com/Alfresco/alfresco-js-api/blob/master/src/api/content-rest-api/docs/CategoryLinkBody.md) - Categories that node will be linked to.
- **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`CategoryPaging`]((https://github.com/Alfresco/alfresco-js-api/blob/master/src/api/content-rest-api/docs/CategoryPaging.md))` | `[`CategoryEntry`](https://github.com/Alfresco/alfresco-js-api/blob/master/src/api/content-rest-api/docs/CategoryEntry.md)`>` - Categories that node has been linked to.
- **areCategoriesEnabled**():`boolean`<br/>
Checks if categories plugin is enabled.
- **Returns** `boolean` - true if categories plugin is enabled, false otherwise.

## Details

Expand Down
3 changes: 3 additions & 0 deletions docs/content-services/services/tag.service.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ Manages tags in Content Services.
- _tagId:_ `string` - The identifier of a tag.
- _tagBody:_ `TagBody` - The updated tag.
- **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`TagEntry`](https://github.com/Alfresco/alfresco-js-api/blob/master/src/alfresco-core-rest-api/docs/TagEntry.md)`>` - Updated tag.
- **areTagsEnabled**():`boolean`<br/>
Checks if tags plugin is enabled.
- **Returns** `boolean` - true if tags plugin is enabled, false otherwise.

## Details

Expand Down
3 changes: 3 additions & 0 deletions docs/user-guide/search-configuration-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,9 @@ export interface SearchCategory {
selector: string;
settings: SearchWidgetSettings;
};
rules?: {
visible: string;
};
}
```

Expand Down
7 changes: 6 additions & 1 deletion e2e/protractor.excludes.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,10 @@
"C279971": "https://alfresco.atlassian.net/browse/ACS-6233",
"C279972": "https://alfresco.atlassian.net/browse/ACS-6233",
"C260181": "https://alfresco.atlassian.net/browse/ACS-6233",
"C297692": "https://alfresco.atlassian.net/browse/ACS-6244"
"C297692": "https://alfresco.atlassian.net/browse/ACS-6244",
"C260418": "https://alfresco.atlassian.net/browse/ACS-6425",
"C268070": "https://alfresco.atlassian.net/browse/ACS-6425",
"C272812": "https://alfresco.atlassian.net/browse/ACS-6425",
"C274704": "https://alfresco.atlassian.net/browse/ACS-6425",
"C311425": "https://alfresco.atlassian.net/browse/ACS-6425"
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ export interface AspectListDialogComponentData {
overTableMessage: string;
select: Subject<string[]>;
nodeId?: string;
excludedAspects?: string[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ <h1 class="adf-aspect-list-dialog-title">{{title | translate}}</h1>
{{'ADF-ASPECT-LIST.DIALOG.SELECTED' | translate}}</p>
</div>
<mat-dialog-content class="adf-aspect-dialog-content">
<adf-aspect-list #aspectList (valueChanged)="onValueChanged($event)" [nodeId]="currentNodeId">
<adf-aspect-list #aspectList (valueChanged)="onValueChanged($event)" [nodeId]="currentNodeId" [excludedAspects]="data.excludedAspects">
</adf-aspect-list>
</mat-dialog-content>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import { AspectListService } from './services/aspect-list.service';
import { delay } from 'rxjs/operators';
import { AspectEntry, Node } from '@alfresco/js-api';
import { NodesApiService } from '../common/services/nodes-api.service';
import { By } from '@angular/platform-browser';
import { AspectListComponent } from './aspect-list.component';

const aspectListMock: AspectEntry[] = [
{
Expand Down Expand Up @@ -103,35 +105,35 @@ describe('AspectListDialogComponent', () => {
keyCode: 27
} as KeyboardEventInit);

describe('Without passing node id', () => {
beforeEach(async () => {
data = {
title: 'Title',
description: 'Description that can be longer or shorter',
overTableMessage: 'Over here',
select: new Subject<string[]>()
};

TestBed.configureTestingModule({
imports: [TranslateModule.forRoot(), ContentTestingModule, MatDialogModule],
providers: [
{ provide: MAT_DIALOG_DATA, useValue: data },
{
provide: MatDialogRef,
useValue: {
keydownEvents: () => of(event),
backdropClick: () => of(null),
close: jasmine.createSpy('close')
}
beforeEach(async () => {
data = {
title: 'Title',
description: 'Description that can be longer or shorter',
overTableMessage: 'Over here',
select: new Subject<string[]>(),
excludedAspects: []
};
await TestBed.configureTestingModule({
imports: [TranslateModule.forRoot(), ContentTestingModule, MatDialogModule],
providers: [
{ provide: MAT_DIALOG_DATA, useValue: data },
{
provide: MatDialogRef,
useValue: {
keydownEvents: () => of(event),
backdropClick: () => of(null),
close: jasmine.createSpy('close')
}
]
}).compileComponents();
});
}
]
}).compileComponents();
fixture = TestBed.createComponent(AspectListDialogComponent);
});

describe('Without passing node id', () => {
beforeEach(() => {
aspectListService = TestBed.inject(AspectListService);
spyOn(aspectListService, 'getAspects').and.returnValue(of(aspectListMock));
fixture = TestBed.createComponent(AspectListDialogComponent);
fixture.detectChanges();
});

Expand Down Expand Up @@ -243,32 +245,7 @@ describe('AspectListDialogComponent', () => {

describe('Passing the node id', () => {
beforeEach(async () => {
data = {
title: 'Title',
description: 'Description that can be longer or shorter',
overTableMessage: 'Over here',
select: new Subject<string[]>(),
nodeId: 'fake-node-id'
};

TestBed.configureTestingModule({
imports: [TranslateModule.forRoot(), ContentTestingModule, MatDialogModule],
providers: [
{ provide: MAT_DIALOG_DATA, useValue: data },
{
provide: MatDialogRef,
useValue: {
close: jasmine.createSpy('close'),
keydownEvents: () => of(event),
backdropClick: () => of(null)
}
}
]
});
await TestBed.compileComponents();
});

beforeEach(async () => {
data.nodeId = 'fake-node-id';
aspectListService = TestBed.inject(AspectListService);
nodeService = TestBed.inject(NodesApiService);
spyOn(aspectListService, 'getAspects').and.returnValue(of([...aspectListMock, ...customAspectListMock]));
Expand All @@ -278,7 +255,6 @@ describe('AspectListDialogComponent', () => {
of(new Node({ id: 'fake-node-id', aspectNames: ['frs:AspectOne', 'cst:customAspect'] })).pipe(delay(0))
);
fixture = TestBed.createComponent(AspectListDialogComponent);
fixture.componentInstance.data.select = new Subject<string[]>();
fixture.detectChanges();
await fixture.whenStable();
});
Expand Down Expand Up @@ -328,4 +304,14 @@ describe('AspectListDialogComponent', () => {
expect(applyButton.disabled).toBe(false);
});
});

describe('AspectListComponent', () => {
it('should have set excludedAspects from dialog data', () => {
data.excludedAspects = ['some aspect 1', 'some aspect 2'];

fixture.detectChanges();
expect(fixture.debugElement.query(By.directive(AspectListComponent)).componentInstance.excludedAspects)
.toBe(data.excludedAspects);
});
});
});
Loading

0 comments on commit 7793aba

Please sign in to comment.