[ACS-8001] hide under the feature flag

This commit is contained in:
Mykyta Maliarchuk
2024-08-07 14:01:04 +02:00
parent 10462855b4
commit a939547f9f
12 changed files with 80 additions and 21 deletions

View File

@@ -26,7 +26,7 @@ import { NodeAspectService } from '../../../aspect-list/services/node-aspect.ser
import { ContentMetadataService } from '../../services/content-metadata.service';
import { AllowableOperationsEnum } from '../../../common/models/allowable-operations.enum';
import { of } from 'rxjs';
import { AlfrescoApiService, AlfrescoApiServiceMock, AuthModule, PipeModule, TranslationMock, TranslationService } from '@alfresco/adf-core';
import { AlfrescoApiService, AlfrescoApiServiceMock, AuthModule, PipeModule, TranslationMock, TranslationService, CONTENT_ENRICHMENT } from '@alfresco/adf-core';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { HttpClientModule } from '@angular/common/http';
import { versionCompatibilityFactory } from '../../../version-compatibility/version-compatibility-factory';
@@ -37,6 +37,7 @@ import { MatTooltipModule } from '@angular/material/tooltip';
import { CategoryService } from '../../../category';
import { TagService } from '../../../tag';
import { PropertyDescriptorsService } from '../../public-api';
import { provideMockFeatureFlags } from '@alfresco/adf-core/feature-flags';
describe('ContentMetadataCardComponent', () => {
let component: ContentMetadataCardComponent;
@@ -72,7 +73,8 @@ describe('ContentMetadataCardComponent', () => {
useFactory: versionCompatibilityFactory,
deps: [VersionCompatibilityService],
multi: true
}
},
provideMockFeatureFlags({[CONTENT_ENRICHMENT.EXPERIENCE_INSIGHT]: true})
]
});
fixture = TestBed.createComponent(ContentMetadataCardComponent);

View File

@@ -45,7 +45,8 @@ import {
TranslationService,
UpdateNotification,
PredictionService,
PredictionStatusUpdate
PredictionStatusUpdate,
CONTENT_ENRICHMENT
} from '@alfresco/adf-core';
import { NodesApiService } from '../../../common/services/nodes-api.service';
import { EMPTY, of, throwError, Subject } from 'rxjs';
@@ -70,6 +71,7 @@ import { MatProgressBarModule } from '@angular/material/progress-bar';
import { MatTooltipModule } from '@angular/material/tooltip';
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
import { MatChipHarness } from '@angular/material/chips/testing';
import { provideMockFeatureFlags } from '@alfresco/adf-core/feature-flags';
describe('ContentMetadataComponent', () => {
let component: ContentMetadataComponent;
@@ -239,7 +241,8 @@ describe('ContentMetadataComponent', () => {
getPredictions: () => EMPTY,
predictionStatusUpdated$: new Subject<PredictionStatusUpdate>()
}
}
},
provideMockFeatureFlags({[CONTENT_ENRICHMENT.EXPERIENCE_INSIGHT]: true})
]
});
fixture = TestBed.createComponent(ContentMetadataComponent);
@@ -1807,7 +1810,9 @@ describe('ContentMetadataComponent', () => {
});
it('should call onPredictionStatusChanged when prediction status has changed', () => {
const onPredictionStatusChangedSpy = spyOn(updateService, 'onPredictionStatusChanged');
const updatedNode = { ...node, name: 'new test name' };
const onPredictionStatusChangedSpy = spyOn(updateService, 'onPredictionStatusChanged').and.stub();
spyOn(nodesApiService, 'getNode').and.returnValue(of(updatedNode));
const notification = { key: 'test:test', previousValue: 'previous value' };
component.ngOnInit();
predictionService.predictionStatusUpdated$.next(notification);

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { Component, Input, OnChanges, OnDestroy, OnInit, SimpleChanges, ViewEncapsulation } from '@angular/core';
import { Component, Inject, Input, OnChanges, OnDestroy, OnInit, SimpleChanges, ViewEncapsulation } from '@angular/core';
import { Category, CategoryEntry, CategoryLinkBody, CategoryPaging, Node, TagBody, TagEntry, TagPaging, Prediction, ReviewStatus } from '@alfresco/js-api';
import { forkJoin, Observable, of, Subject, zip } from 'rxjs';
import {
@@ -26,8 +26,10 @@ import {
NotificationService,
PredictionService,
TranslationService,
UpdateNotification
UpdateNotification,
CONTENT_ENRICHMENT
} from '@alfresco/adf-core';
import { FeaturesServiceToken, IFeaturesService } from '@alfresco/adf-core/feature-flags';
import { ContentMetadataService } from '../../services/content-metadata.service';
import { CardViewGroup, PresetConfig, ContentMetadataCustomPanel, ContentMetadataPanel } from '../../interfaces/content-metadata.interfaces';
import { catchError, debounceTime, map, takeUntil } from 'rxjs/operators';
@@ -161,6 +163,7 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
changedProperties = {};
hasMetadataChanged = false;
isContentEnrichmentFlagOn = false;
assignedCategories: Category[] = [];
categories: Category[] = [];
categoriesManagementMode = CategoriesManagementMode.ASSIGN;
@@ -182,7 +185,8 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
private categoryService: CategoryService,
private contentService: ContentService,
private notificationService: NotificationService,
private predictionService: PredictionService
private predictionService: PredictionService,
@Inject(FeaturesServiceToken) private readonly featuresService: IFeaturesService
) {
this.copyToClipboardAction = this.appConfig.get<boolean>('content-metadata.copy-to-clipboard-action');
this.multiValueSeparator = this.appConfig.get<string>('content-metadata.multi-value-pipe-separator') || DEFAULT_SEPARATOR;
@@ -190,6 +194,12 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
}
ngOnInit() {
this.featuresService.isOn$(CONTENT_ENRICHMENT.EXPERIENCE_INSIGHT).pipe(
takeUntil(this.onDestroy$)
).subscribe((isOn) => {
this.isContentEnrichmentFlagOn = isOn;
});
this.cardViewContentUpdateService.itemUpdated$
.pipe(debounceTime(500), takeUntil(this.onDestroy$))
.subscribe((updatedNode: UpdateNotification) => {
@@ -203,7 +213,7 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
this.loadProperties(node);
});
if (this.displayPredictions) {
if (this.isContentEnrichmentFlagOn && this.displayPredictions) {
this.predictionService.predictionStatusUpdated$.pipe(takeUntil(this.onDestroy$)).subscribe(({ key, previousValue }) => {
this.cardViewContentUpdateService.onPredictionStatusChanged([{ key, previousValue }]);
this.nodesApiService
@@ -424,7 +434,7 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
)
.subscribe((result: any) => {
if (result) {
if (this.displayPredictions) {
if (this.isContentEnrichmentFlagOn && this.displayPredictions) {
this.cardViewContentUpdateService.onPredictionStatusChanged(
Object.keys(this.changedProperties['properties']).map((key) => ({ key }))
);
@@ -471,7 +481,7 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
requests['groupedProperties'] = this.contentMetadataService.getGroupedProperties(node, this.preset);
}
if (this.displayPredictions) {
if (this.isContentEnrichmentFlagOn && this.displayPredictions) {
requests['predictions'] = this.loadPredictionsForNode(this.node.id);
}

View File

@@ -47,6 +47,7 @@ import { NewVersionUploaderDialogComponent } from './new-version-uploader';
import { VersionCompatibilityDirective } from './version-compatibility';
import { CONTENT_UPLOAD_DIRECTIVES } from './upload';
import { TreeViewComponent } from './tree-view';
import { provideDebugFeatureFlags, provideDummyFeatureFlags } from '@alfresco/adf-core/feature-flags';
@NgModule({
imports: [
@@ -109,7 +110,9 @@ import { TreeViewComponent } from './tree-view';
]
})
export class ContentModule {
static forRoot(): ModuleWithProviders<ContentModule> {
static forRoot(
devTools = false
): ModuleWithProviders<ContentModule> {
return {
ngModule: ContentModule,
providers: [
@@ -126,7 +129,13 @@ export class ContentModule {
useFactory: contentAuthLoaderFactory,
deps: [ContentAuthLoaderService],
multi: true
}
},
...provideDummyFeatureFlags(),
...(devTools
? provideDebugFeatureFlags({
storageKey: 'content-feature-flags'
})
: [])
]
};
}

View File

@@ -17,6 +17,6 @@
export interface Dictionary<T> {
[key: string]: T;
};
}
export type Constructor<T> = new (...args: any[]) => T;

View File

@@ -18,7 +18,7 @@
import { IsFlagsOverrideOn } from '../guards/is-flags-override-on.guard';
import { IsFeatureOn } from '../guards/is-feature-on.guard';
import { IsFeatureOff } from '../guards/is-feature-off.guard';
import { FeaturesServiceToken, FlagsOverrideToken } from '../interfaces/features.interface';
import { FeaturesServiceToken, FlagsOverrideToken, OverridableFeaturesServiceToken } from '../interfaces/features.interface';
import { DummyFeaturesService } from '../services/dummy-features.service';
/**
@@ -28,7 +28,8 @@ import { DummyFeaturesService } from '../services/dummy-features.service';
*/
export function provideDummyFeatureFlags() {
return [
{ provide: FeaturesServiceToken, useClass: DummyFeaturesService },
{ provide: OverridableFeaturesServiceToken, useClass: DummyFeaturesService },
{ provide: FeaturesServiceToken, useExisting: OverridableFeaturesServiceToken },
{ provide: FlagsOverrideToken, useValue: false },
IsFeatureOn,
IsFeatureOff,

View File

@@ -45,4 +45,4 @@ export function loadAppConfig(
});
};
return () => appConfigService.load(init);
};
}

View File

@@ -20,4 +20,4 @@ export interface UserLike {
firstName?: string;
lastName?: string;
email?: string;
};
}

View File

@@ -0,0 +1,20 @@
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export enum CONTENT_ENRICHMENT {
EXPERIENCE_INSIGHT = 'content-enrichment-with-experience-insight'
}

View File

@@ -17,3 +17,4 @@
export * from './services';
export * from './interfaces/prediction-status-update.interface';
export * from './feature-flag';

View File

@@ -21,6 +21,8 @@ import { ProcessServiceCloudTestingModule } from '../../../../../testing/process
import { of } from 'rxjs';
import { fakeNodeWithProperties } from '../../../../mocks/attach-file-cloud-widget.mock';
import { NodesApiService, BasicPropertiesService } from '@alfresco/adf-content-services';
import { provideMockFeatureFlags } from '@alfresco/adf-core/feature-flags';
import { CONTENT_ENRICHMENT } from '@alfresco/adf-core';
describe('PropertiesViewerWidgetComponent', () => {
let component: PropertiesViewerWrapperComponent;
@@ -30,7 +32,11 @@ describe('PropertiesViewerWidgetComponent', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [ProcessServiceCloudTestingModule],
providers: [NodesApiService, { provide: BasicPropertiesService, useValue: { getProperties: () => [] } }]
providers: [
NodesApiService,
{ provide: BasicPropertiesService, useValue: { getProperties: () => [] } },
provideMockFeatureFlags({[CONTENT_ENRICHMENT.EXPERIENCE_INSIGHT]: false})
]
});
fixture = TestBed.createComponent(PropertiesViewerWrapperComponent);
component = fixture.componentInstance;

View File

@@ -16,13 +16,14 @@
*/
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { FormFieldModel, FormModel } from '@alfresco/adf-core';
import { CONTENT_ENRICHMENT, FormFieldModel, FormModel } from '@alfresco/adf-core';
import { PropertiesViewerWidgetComponent } from './properties-viewer.widget';
import { ProcessServiceCloudTestingModule } from '../../../../testing/process-service-cloud.testing.module';
import { fakeNodeWithProperties } from '../../../mocks/attach-file-cloud-widget.mock';
import { PropertiesViewerWrapperComponent } from './properties-viewer-wrapper/properties-viewer-wrapper.component';
import { NodesApiService, BasicPropertiesService } from '@alfresco/adf-content-services';
import { of } from 'rxjs';
import { provideMockFeatureFlags } from '@alfresco/adf-core/feature-flags';
describe('PropertiesViewerWidgetComponent', () => {
let widget: PropertiesViewerWidgetComponent;
@@ -49,7 +50,11 @@ describe('PropertiesViewerWidgetComponent', () => {
TestBed.configureTestingModule({
imports: [ProcessServiceCloudTestingModule],
declarations: [PropertiesViewerWrapperComponent],
providers: [NodesApiService, { provide: BasicPropertiesService, useValue: { getProperties: () => [] } }]
providers: [
NodesApiService,
{ provide: BasicPropertiesService, useValue: { getProperties: () => [] } },
provideMockFeatureFlags({[CONTENT_ENRICHMENT.EXPERIENCE_INSIGHT]: false})
]
});
fixture = TestBed.createComponent(PropertiesViewerWidgetComponent);
nodesApiService = TestBed.inject(NodesApiService);