Skip to content

Commit

Permalink
[ACS-8001] hide under the feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
nikita-web-ua committed Aug 5, 2024
1 parent 1046285 commit b54e3a0
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
Expand Down Expand Up @@ -72,7 +73,8 @@ describe('ContentMetadataCardComponent', () => {
useFactory: versionCompatibilityFactory,
deps: [VersionCompatibilityService],
multi: true
}
},
provideMockFeatureFlags({[CONTENT_ENRICHMENT.EXPERIENCE_INSIGHT]: true})
]
});
fixture = TestBed.createComponent(ContentMetadataCardComponent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
Expand Down Expand Up @@ -239,7 +241,8 @@ describe('ContentMetadataComponent', () => {
getPredictions: () => EMPTY,
predictionStatusUpdated$: new Subject<PredictionStatusUpdate>()
}
}
},
provideMockFeatureFlags({[CONTENT_ENRICHMENT.EXPERIENCE_INSIGHT]: true})
]
});
fixture = TestBed.createComponent(ContentMetadataComponent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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';
Expand Down Expand Up @@ -161,6 +163,7 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {

changedProperties = {};
hasMetadataChanged = false;
isContentEnrichmentFlagOn = false;
assignedCategories: Category[] = [];
categories: Category[] = [];
categoriesManagementMode = CategoriesManagementMode.ASSIGN;
Expand All @@ -182,14 +185,21 @@ 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;
this.useChipsForMultiValueProperty = this.appConfig.get<boolean>('content-metadata.multi-value-chips');
}

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) => {
Expand All @@ -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
Expand Down Expand Up @@ -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 }))
);
Expand Down Expand Up @@ -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);
}

Expand Down
13 changes: 11 additions & 2 deletions lib/content-services/src/lib/content.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down Expand Up @@ -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: [
Expand All @@ -126,7 +129,13 @@ export class ContentModule {
useFactory: contentAuthLoaderFactory,
deps: [ContentAuthLoaderService],
multi: true
}
},
...provideDummyFeatureFlags(),
...(devTools
? provideDebugFeatureFlags({
storageKey: 'content-feature-flags'
})
: [])
]
};
}
Expand Down
2 changes: 1 addition & 1 deletion lib/core/api/src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@

export interface Dictionary<T> {
[key: string]: T;
};
}

export type Constructor<T> = new (...args: any[]) => T;
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion lib/core/src/lib/app-config/app-config.loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ export function loadAppConfig(
});
};
return () => appConfigService.load(init);
};
}
2 changes: 1 addition & 1 deletion lib/core/src/lib/pipes/user-like.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ export interface UserLike {
firstName?: string;
lastName?: string;
email?: string;
};
}
20 changes: 20 additions & 0 deletions lib/core/src/lib/prediction/feature-flag.ts
Original file line number Diff line number Diff line change
@@ -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'
}
1 change: 1 addition & 0 deletions lib/core/src/lib/prediction/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@

export * from './services';
export * from './interfaces/prediction-status-update.interface';
export * from './feature-flag';

0 comments on commit b54e3a0

Please sign in to comment.