-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(uve): Add FF for Preview Mode (#30623)
This pull request introduces a new feature flag for UVE preview mode and integrates it into the existing system. The changes include updates to feature flag definitions, component additions, and modifications to the store to handle the new flag. ### Feature Flag Updates: * Added `FEATURE_FLAG_UVE_PREVIEW_MODE` to `FeaturedFlags` in `shared-models.ts`. * Updated `ConfigurationResource.java` to include `FEATURE_FLAG_UVE_PREVIEW_MODE` in the list of feature flags. ### Component Additions: * Created `DotUveToolbarComponent` with its HTML, SCSS, and TypeScript files. [[1]](diffhunk://#diff-217a9e619d6590c4f652e85353b9637ba5e464ddeb0424be35aef39bb8dceb30R1-R11) [[2]](diffhunk://#diff-9937556e73b051b878ba22ad1ce971a70019a617d7979b3e0bcc814801ad350bR1) [[3]](diffhunk://#diff-3eaa147616a5d1ff374a5fa27b0f38f0159a9039ef7e8d672dec43631f48a9e1R1-R22) ### Store Modifications: * Added `withFlags` feature to handle the fetching and state management of feature flags in `dot-uve.store.ts`. [[1]](diffhunk://#diff-42fdc01a4da73b6ecede38045c03fd631badeb73e299fbb4ed6442eb1f3ad963R5-R8) [[2]](diffhunk://#diff-42fdc01a4da73b6ecede38045c03fd631badeb73e299fbb4ed6442eb1f3ad963L148-R152) * Created a new model and utility function for managing feature flags in `flags/models.ts` and `flags/withFlags.ts`. [[1]](diffhunk://#diff-56a4c0b92a1c5300b155f1aaa7b4f6fec8507d90243521edba9d8c7568148aceR1-R7) [[2]](diffhunk://#diff-c000e8963865d1e077268b3e4de0a84c5d2709623e8e172bf395431078528d65R1-R55) ### Component Integration: * Integrated `DotUveToolbarComponent` into `edit-ema-editor.component.html` and updated SCSS accordingly. [[1]](diffhunk://#diff-7f93b3d5700edd531f6ee9f65ed695175ee686d7b1cfa63b46de3669e65fb1efR1-R6) [[2]](diffhunk://#diff-9f57717118542461b370728d90435befd6cecc18f94bf130ab48acd3ef795ca1L23-R24) * Updated imports and component declarations in `edit-ema-editor.component.ts` to include the new toolbar component. [[1]](diffhunk://#diff-24dc496db1eb6feb3e10a031baa4b4b63c20f1cd02ade574065f6b967f11c365L47-R50) [[2]](diffhunk://#diff-24dc496db1eb6feb3e10a031baa4b4b63c20f1cd02ade574065f6b967f11c365L111-R111) [[3]](diffhunk://#diff-24dc496db1eb6feb3e10a031baa4b4b63c20f1cd02ade574065f6b967f11c365R150)
- Loading branch information
Showing
18 changed files
with
264 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...portlet/src/lib/edit-ema-editor/components/dot-uve-toolbar/dot-uve-toolbar.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<p>dot-uve-toolbar works!</p> |
Empty file.
22 changes: 22 additions & 0 deletions
22
...tlet/src/lib/edit-ema-editor/components/dot-uve-toolbar/dot-uve-toolbar.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { DotUveToolbarComponent } from './dot-uve-toolbar.component'; | ||
|
||
describe('DotUveToolbarComponent', () => { | ||
let component: DotUveToolbarComponent; | ||
let fixture: ComponentFixture<DotUveToolbarComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [DotUveToolbarComponent] | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(DotUveToolbarComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
11 changes: 11 additions & 0 deletions
11
...a/portlet/src/lib/edit-ema-editor/components/dot-uve-toolbar/dot-uve-toolbar.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { ChangeDetectionStrategy, Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'dot-uve-toolbar', | ||
standalone: true, | ||
imports: [], | ||
templateUrl: './dot-uve-toolbar.component.html', | ||
styleUrl: './dot-uve-toolbar.component.scss', | ||
changeDetection: ChangeDetectionStrategy.OnPush | ||
}) | ||
export class DotUveToolbarComponent {} |
7 changes: 6 additions & 1 deletion
7
...web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/edit-ema-editor.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
core-web/libs/portlets/edit-ema/portlet/src/lib/store/features/flags/models.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { FeaturedFlags } from '@dotcms/dotcms-models'; | ||
|
||
export type UVEFlags = { [key in FeaturedFlags]?: boolean }; | ||
|
||
export interface WithFlagsState { | ||
flags: UVEFlags; | ||
} |
89 changes: 89 additions & 0 deletions
89
core-web/libs/portlets/edit-ema/portlet/src/lib/store/features/flags/withFlags.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import { describe } from '@jest/globals'; | ||
import { createServiceFactory, SpectatorService } from '@ngneat/spectator/jest'; | ||
import { signalStore, withState } from '@ngrx/signals'; | ||
import { of } from 'rxjs'; | ||
|
||
import { DotPropertiesService } from '@dotcms/data-access'; | ||
import { FeaturedFlags } from '@dotcms/dotcms-models'; | ||
|
||
import { withFlags } from './withFlags'; | ||
|
||
import { DotPageApiParams } from '../../../services/dot-page-api.service'; | ||
import { UVE_FEATURE_FLAGS } from '../../../shared/consts'; | ||
import { UVE_STATUS } from '../../../shared/enums'; | ||
import { UVEState } from '../../models'; | ||
|
||
const initialState: UVEState = { | ||
isEnterprise: false, | ||
languages: [], | ||
pageAPIResponse: null, | ||
currentUser: null, | ||
experiment: null, | ||
errorCode: null, | ||
params: {} as DotPageApiParams, | ||
status: UVE_STATUS.LOADING, | ||
isTraditionalPage: true, | ||
canEditPage: false, | ||
pageIsLocked: true | ||
}; | ||
|
||
export const uveStoreMock = signalStore( | ||
withState<UVEState>(initialState), | ||
withFlags(UVE_FEATURE_FLAGS) | ||
); | ||
|
||
const MOCK_RESPONSE = UVE_FEATURE_FLAGS.reduce((acc, flag) => { | ||
acc[flag] = true; | ||
|
||
return acc; | ||
}, {}); | ||
|
||
describe('withFlags', () => { | ||
let spectator: SpectatorService<InstanceType<typeof uveStoreMock>>; | ||
let store: InstanceType<typeof uveStoreMock>; | ||
|
||
const createService = createServiceFactory({ | ||
service: uveStoreMock, | ||
providers: [ | ||
{ | ||
provide: DotPropertiesService, | ||
useValue: { | ||
getFeatureFlags: jest.fn().mockReturnValue(of(MOCK_RESPONSE)) | ||
} | ||
} | ||
] | ||
}); | ||
|
||
beforeEach(() => { | ||
spectator = createService(); | ||
store = spectator.service; | ||
}); | ||
|
||
describe('onInit', () => { | ||
it('should call propertiesService.getFeatureFlags with flags', () => { | ||
const propertiesService = spectator.inject(DotPropertiesService); | ||
|
||
expect(propertiesService.getFeatureFlags).toHaveBeenCalledWith(UVE_FEATURE_FLAGS); | ||
}); | ||
|
||
it('should patch state with flags', () => { | ||
expect(store.flags()).toEqual(MOCK_RESPONSE); | ||
}); | ||
}); | ||
describe('methods', () => { | ||
describe('setFlags', () => { | ||
it('should patch state with flags', () => { | ||
store.setFlags(MOCK_RESPONSE); | ||
|
||
expect(store.flags()).toEqual(MOCK_RESPONSE); | ||
}); | ||
}); | ||
}); | ||
describe('computed', () => { | ||
it('should return $previewMode', () => { | ||
expect(store.$previewMode()).toEqual( | ||
MOCK_RESPONSE[FeaturedFlags.FEATURE_FLAG_UVE_PREVIEW_MODE] | ||
); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.