Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(FTM): New UVE Toolbar - Implement Workflows Action button #30908

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
DotMessageService,
DotPropertiesService,
DotWorkflowActionsFireService,
DotWorkflowsActionsService,
PushPublishService
} from '@dotcms/data-access';
import {
Expand Down Expand Up @@ -208,6 +209,12 @@ describe('DotEmaShellComponent', () => {
DotWorkflowActionsFireService,
Router,
Location,
{
provide: DotWorkflowsActionsService,
useValue: {
getByInode: () => of([])
}
},
{
provide: DotPropertiesService,
useValue: dotPropertiesServiceMock
Expand Down Expand Up @@ -559,6 +566,23 @@ describe('DotEmaShellComponent', () => {
expect(spyloadPageAsset).toHaveBeenCalledWith({ url: '/my-awesome-page' });
});

it('should get the workflow action when an `UPDATE_WORKFLOW_ACTION` event is received', () => {
const spyGetWorkflowActions = jest.spyOn(store, 'getWorkflowActions');

spectator.detectChanges();

spectator.triggerEventHandler(
DotEmaDialogComponent,
'action',
DIALOG_ACTION_EVENT({
name: NG_CUSTOM_EVENTS.UPDATE_WORKFLOW_ACTION
})
);
spectator.detectChanges();

expect(spyGetWorkflowActions).toHaveBeenCalled();
});

it('should trigger a store reload if the url is the same', () => {
const spyReload = jest.spyOn(store, 'reloadCurrentPage');
const spyLocation = jest.spyOn(location, 'go');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import {
DotPageLayoutService,
DotPageRenderService,
DotSeoMetaTagsService,
DotSeoMetaTagsUtilService
DotSeoMetaTagsUtilService,
DotWorkflowsActionsService
} from '@dotcms/data-access';
import { SiteService } from '@dotcms/dotcms-js';
import { DotPageToolsSeoComponent } from '@dotcms/portlets/dot-ema/ui';
Expand Down Expand Up @@ -58,6 +59,7 @@ import {
DotPageRenderService,
DotSeoMetaTagsService,
DotSeoMetaTagsUtilService,
DotWorkflowsActionsService,
{
provide: WINDOW,
useValue: window
Expand Down Expand Up @@ -111,6 +113,7 @@ export class DotEmaShellComponent implements OnInit, OnDestroy {
...(pageParams ?? {}),
...(viewParams ?? {})
};

this.#updateLocation(queryParams);
});

Expand All @@ -131,6 +134,11 @@ export class DotEmaShellComponent implements OnInit, OnDestroy {

handleNgEvent({ event }: DialogAction) {
switch (event.detail.name) {
case NG_CUSTOM_EVENTS.UPDATE_WORKFLOW_ACTION: {
this.uveStore.getWorkflowActions();
break;
}

case NG_CUSTOM_EVENTS.SAVE_PAGE: {
this.handleSavePageEvent(event);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import {
DotExperimentsService,
DotLanguagesService,
DotLicenseService,
DotMessageService
DotMessageService,
DotWorkflowsActionsService
} from '@dotcms/data-access';
import { LoginService } from '@dotcms/dotcms-js';
import { DEFAULT_VARIANT_NAME } from '@dotcms/dotcms-models';
Expand Down Expand Up @@ -53,6 +54,12 @@ describe('DotEmaInfoDisplayComponent', () => {
MessageService,
mockProvider(Router),
mockProvider(ActivatedRoute),
{
provide: DotWorkflowsActionsService,
useValue: {
getByInode: () => of([])
}
},
{
provide: DotLanguagesService,
useValue: new DotLanguagesServiceMock()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
data-testId="uve-toolbar-persona-selector" />

@if (!preview) {
<span data-testId="uve-toolbar-workflow-actions">Workflows</span>
<dot-uve-workflow-actions />
}
</div>
</p-toolbar>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import {
DotExperimentsService,
DotLanguagesService,
DotLicenseService,
DotPersonalizeService
DotPersonalizeService,
DotWorkflowsActionsService
} from '@dotcms/data-access';
import { LoginService } from '@dotcms/dotcms-js';
import {
Expand Down Expand Up @@ -41,6 +42,7 @@ import {
} from '../../../utils';
import { DotEmaBookmarksComponent } from '../dot-ema-bookmarks/dot-ema-bookmarks.component';
import { DotEmaRunningExperimentComponent } from '../dot-ema-running-experiment/dot-ema-running-experiment.component';
import { DotUveWorkflowActionsComponent } from '../dot-uve-workflow-actions/dot-uve-workflow-actions.component';
import { EditEmaLanguageSelectorComponent } from '../edit-ema-language-selector/edit-ema-language-selector.component';
import { EditEmaPersonaSelectorComponent } from '../edit-ema-persona-selector/edit-ema-persona-selector.component';

Expand Down Expand Up @@ -107,14 +109,19 @@ describe('DotUveToolbarComponent', () => {
HttpClientTestingModule,
MockComponent(DotEmaBookmarksComponent),
MockComponent(DotEmaRunningExperimentComponent),
MockComponent(EditEmaPersonaSelectorComponent)
MockComponent(EditEmaPersonaSelectorComponent),
MockComponent(DotUveWorkflowActionsComponent)
],
providers: [
UVEStore,
provideHttpClientTesting(),
mockProvider(ConfirmationService, {
confirm: jest.fn()
}),

mockProvider(DotWorkflowsActionsService, {
getByInode: () => of([])
}),
{
provide: DotLanguagesService,
useValue: new DotLanguagesServiceMock()
Expand Down Expand Up @@ -181,6 +188,12 @@ describe('DotUveToolbarComponent', () => {
});
});

it('should have a dot-uve-workflow-actions component', () => {
const workflowActions = spectator.query(DotUveWorkflowActionsComponent);

expect(workflowActions).toBeTruthy();
});

describe('copy-url', () => {
let button: DebugElement;

Expand Down Expand Up @@ -359,10 +372,6 @@ describe('DotUveToolbarComponent', () => {
it('should have persona selector', () => {
expect(spectator.query(byTestId('uve-toolbar-persona-selector'))).toBeTruthy();
});

it('should have workflows button', () => {
expect(spectator.query(byTestId('uve-toolbar-workflow-actions'))).toBeTruthy();
});
});

describe('preview', () => {
Expand Down Expand Up @@ -411,8 +420,10 @@ describe('DotUveToolbarComponent', () => {
expect(spectator.query(byTestId('uve-toolbar-running-experiment'))).toBeFalsy();
});

it('should not have workflow actions', () => {
expect(spectator.query(byTestId('uve-toolbar-workflow-actions'))).toBeFalsy();
it('should not have a dot-uve-workflow-actions component', () => {
const workflowActions = spectator.query(DotUveWorkflowActionsComponent);

expect(workflowActions).toBeNull();
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { UVEStore } from '../../../store/dot-uve.store';
import { DotEmaBookmarksComponent } from '../dot-ema-bookmarks/dot-ema-bookmarks.component';
import { DotEmaInfoDisplayComponent } from '../dot-ema-info-display/dot-ema-info-display.component';
import { DotEmaRunningExperimentComponent } from '../dot-ema-running-experiment/dot-ema-running-experiment.component';
import { DotUveWorkflowActionsComponent } from '../dot-uve-workflow-actions/dot-uve-workflow-actions.component';
import { EditEmaLanguageSelectorComponent } from '../edit-ema-language-selector/edit-ema-language-selector.component';
import { EditEmaPersonaSelectorComponent } from '../edit-ema-persona-selector/edit-ema-persona-selector.component';

Expand All @@ -46,10 +47,10 @@ import { EditEmaPersonaSelectorComponent } from '../edit-ema-persona-selector/ed
SplitButtonModule,
FormsModule,
ReactiveFormsModule,
ChipModule,
EditEmaPersonaSelectorComponent,
EditEmaLanguageSelectorComponent,
ClipboardModule
DotUveWorkflowActionsComponent,
ChipModule
],
providers: [DotPersonalizeService],
templateUrl: './dot-uve-toolbar.component.html',
Expand All @@ -59,8 +60,10 @@ import { EditEmaPersonaSelectorComponent } from '../edit-ema-persona-selector/ed
export class DotUveToolbarComponent {
$personaSelector = viewChild<EditEmaPersonaSelectorComponent>('personaSelector');
$languageSelector = viewChild<EditEmaLanguageSelectorComponent>('languageSelector');
#store = inject(UVEStore);

@Output() translatePage = new EventEmitter<{ page: DotPage; newLanguage: number }>();

readonly #store = inject(UVEStore);
readonly #messageService = inject(MessageService);
readonly #dotMessageService = inject(DotMessageService);
readonly #confirmationService = inject(ConfirmationService);
Expand All @@ -71,8 +74,6 @@ export class DotUveToolbarComponent {
readonly $apiURL = this.#store.$apiURL;
readonly $personaSelectorProps = this.#store.$personaSelector;

@Output() translatePage = new EventEmitter<{ page: DotPage; newLanguage: number }>();

readonly $styleToolbarClass = computed(() => {
if (!this.$isPreviewMode()) {
return 'uve-toolbar';
Expand All @@ -81,6 +82,13 @@ export class DotUveToolbarComponent {
return 'uve-toolbar uve-toolbar-preview';
});

readonly $pageInode = computed(() => {
return this.#store.pageAPIResponse()?.page.inode;
});

readonly $actions = this.#store.workflowLoading;
readonly $workflowLoding = this.#store.workflowLoading;

protected readonly date = new Date();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
(actionFired)="handleActionTrigger($event)"
[size]="'small'"
[loading]="loading()"
[disabled]="!canEdit()"
[actions]="actions()" />
Loading
Loading