[ACS-4331] Add deleteTag method to tag service (#8126)

* ACS-4331 - added deleteTag method to tag service

* ACS-4331 - docs + unit test

* ACS-4331 - docs correction

* ACS-4331 - docs alignment fix

* ACS-4331 - applied small fixes

* ACS-4331 - updated docs

* [ACS-4331] removed extra spaces
This commit is contained in:
Nikita Maliarchuk
2023-02-23 18:38:57 +01:00
committed by GitHub
parent 2dccde9e6b
commit 25d85c7890
3 changed files with 30 additions and 4 deletions

View File

@@ -66,7 +66,7 @@ describe('TagService', () => {
describe('Content tests', () => {
it('getTagsByNodeId catch errors call', async () => {
it('should catch errors on getTagsByNodeId call', async () => {
spyOn(service, 'getTagsByNodeId').and.returnValue(throwError({error : 'error'}));
await service.getTagsByNodeId('fake-node-id').subscribe(() => {
throwError('This call should fail');
@@ -75,7 +75,7 @@ describe('TagService', () => {
});
});
it('delete tag should trigger a refresh event', async () => {
it('should trigger a refresh event on removeTag() call', async () => {
await service.refresh.subscribe((res) => {
expect(res).toBeDefined();
});
@@ -83,7 +83,7 @@ describe('TagService', () => {
service.removeTag('fake-node-id', 'fake-tag');
});
it('add tag should trigger a refresh event', async () => {
it('should trigger a refresh event on addTag() call', async () => {
await service.refresh.subscribe((res) => {
expect(res).toBeDefined();
});
@@ -91,6 +91,14 @@ describe('TagService', () => {
service.addTag('fake-node-id', 'fake-tag');
});
it('should trigger a refresh event on deleteTag() call', async () => {
await service.refresh.subscribe((res) => {
expect(res).toBeDefined();
});
service.deleteTag('fake-tag-id');
});
describe('createTags', () => {
it('should call createTags on tagsApi', () => {
spyOn(service.tagsApi, 'createTags').and.returnValue(Promise.resolve([]));

View File

@@ -18,7 +18,7 @@
import { AlfrescoApiService, LogService, UserPreferencesService } from '@alfresco/adf-core';
import { EventEmitter, Injectable, Output } from '@angular/core';
import { from, Observable, throwError } from 'rxjs';
import { catchError, map } from 'rxjs/operators';
import { catchError, map, tap } from 'rxjs/operators';
import {
RequestQuery,
RequestSortDefinitionInner,
@@ -227,6 +227,20 @@ export class TagService {
);
}
/**
* Deletes a tag with tagId.
* This will cause the tag to be removed from all nodes.
* You must have admin rights to delete a tag.
*
* @param tagId of the tag to be deleted
* @returns Null object when the operation completes
*/
deleteTag(tagId: string): Observable<void> {
return from(this.tagsApi.deleteTag(tagId)).pipe(
tap((data) => this.refresh.emit(data))
);
}
private handleError(error: any) {
this.logService.error(error);
return throwError(error || 'Server error');