diff --git a/src/designer/elsa-workflows-designer/src/components/shared/modal-dialog/default-contents.tsx b/src/designer/elsa-workflows-designer/src/components/shared/modal-dialog/default-contents.tsx index 6b8896bbe..ac2308be4 100644 --- a/src/designer/elsa-workflows-designer/src/components/shared/modal-dialog/default-contents.tsx +++ b/src/designer/elsa-workflows-designer/src/components/shared/modal-dialog/default-contents.tsx @@ -2,7 +2,7 @@ import {h} from '@stencil/core'; import { WarningIcon } from '../../icons/tooling'; export class DefaultContents { - public static Delete = (message: string): any => { + public static Warning = (message: string): any => { return(
diff --git a/src/designer/elsa-workflows-designer/src/components/shared/modal-dialog/modal-type.ts b/src/designer/elsa-workflows-designer/src/components/shared/modal-dialog/modal-type.ts index 6727e8ea0..72e7d3dd4 100644 --- a/src/designer/elsa-workflows-designer/src/components/shared/modal-dialog/modal-type.ts +++ b/src/designer/elsa-workflows-designer/src/components/shared/modal-dialog/modal-type.ts @@ -1,4 +1,4 @@ export enum ModalType { Default, - DeleteConfirmation + Confirmation } \ No newline at end of file diff --git a/src/designer/elsa-workflows-designer/src/components/shared/modal-dialog/models.ts b/src/designer/elsa-workflows-designer/src/components/shared/modal-dialog/models.ts index 1e0300eac..0a4a3ec36 100644 --- a/src/designer/elsa-workflows-designer/src/components/shared/modal-dialog/models.ts +++ b/src/designer/elsa-workflows-designer/src/components/shared/modal-dialog/models.ts @@ -60,6 +60,22 @@ export class DefaultActions { onClick: handler }); + public static Publish = (handler?: ActionClickArgs): ActionDefinition => ({ + text: 'Publish', + name: 'Publish', + type: ActionType.Button, + isDangerous: true, + onClick: handler + }); + + public static Unpublish = (handler?: ActionClickArgs): ActionDefinition => ({ + text: 'Unpublish', + name: 'Unpublish', + type: ActionType.Button, + isDangerous: true, + onClick: handler + }); + public static New = (handler?: ActionClickArgs): ActionDefinition => ({ text: 'New', name: 'New', @@ -67,27 +83,4 @@ export class DefaultActions { isPrimary: true, onClick: handler }); -} - -// export class DefaultContents { -// public static Delete = (message: string): any => { -// return( -//
-//
-// -//
-// -//

{message}

-// -// -//
-//
-//
-// ) -// }; -// } \ No newline at end of file +} \ No newline at end of file diff --git a/src/designer/elsa-workflows-designer/src/modules/activity-definitions/components/browser.tsx b/src/designer/elsa-workflows-designer/src/modules/activity-definitions/components/browser.tsx index a807f06f1..0a18c4a77 100644 --- a/src/designer/elsa-workflows-designer/src/modules/activity-definitions/components/browser.tsx +++ b/src/designer/elsa-workflows-designer/src/modules/activity-definitions/components/browser.tsx @@ -7,7 +7,7 @@ import {PagedList, VersionOptions} from "../../../models"; import {DeleteIcon, EditIcon, PublishIcon, UnPublishIcon} from "../../../components/icons/tooling"; import {PagerData} from "../../../components/shared/pager/pager"; import {updateSelectedActivityDefinitions} from "../services/utils"; -import {DefaultActions} from "../../../components/shared/modal-dialog"; +import {ModalDialogService, DefaultActions, DefaultContents, ModalType} from "../../../components/shared/modal-dialog"; @Component({ tag: 'elsa-activity-definition-browser', @@ -21,6 +21,11 @@ export class ActivityDefinitionBrowser { private activityDefinitionsApi: ActivityDefinitionsApi; private selectAllCheckbox: HTMLInputElement; + private readonly modalDialogService: ModalDialogService; + + constructor() { + this.modalDialogService = Container.get(ModalDialogService); + } @Event() public activityDefinitionSelected: EventEmitter; @Event() public newActivityDefinitionSelected: EventEmitter; @@ -54,28 +59,47 @@ export class ActivityDefinitionBrowser { } private async onDeleteClick(e: MouseEvent, ActivityDefinition: ActivityDefinitionSummary) { - // const result = await this.confirmDialog.show(t('DeleteConfirmationModel.Title'), t('DeleteConfirmationModel.Message')); - // - // if (!result) - // return; - - await this.activityDefinitionsApi.delete(ActivityDefinition); - await this.loadActivityDefinitions(); + this.modalDialogService.show( + () => DefaultContents.Warning("Are you sure you want to delete this activity definition?"), + [DefaultActions.Delete(async () => + { + await this.activityDefinitionsApi.delete(ActivityDefinition); + await this.loadActivityDefinitions(); + }), DefaultActions.Cancel()], + ModalType.Confirmation); } private onDeleteManyClick = async () => { - await this.activityDefinitionsApi.deleteMany({definitionIds: this.selectedActivityDefinitionIds}); - await this.loadActivityDefinitions(); + this.modalDialogService.show( + () => DefaultContents.Warning("Are you sure you want to delete selected activity definitions?"), + [DefaultActions.Delete(async () => + { + await this.activityDefinitionsApi.deleteMany({definitionIds: this.selectedActivityDefinitionIds}); + await this.loadActivityDefinitions(); + }), DefaultActions.Cancel()], + ModalType.Confirmation); }; private onPublishManyClick = async () => { - await this.activityDefinitionsApi.publishMany({definitionIds: this.selectedActivityDefinitionIds}); - await this.loadActivityDefinitions(); + this.modalDialogService.show( + () => DefaultContents.Warning("Are you sure you want to publish selected activity definitions?"), + [DefaultActions.Publish(async () => + { + await this.activityDefinitionsApi.publishMany({definitionIds: this.selectedActivityDefinitionIds}); + await this.loadActivityDefinitions(); + }), DefaultActions.Cancel()], + ModalType.Confirmation); }; private onUnpublishManyClick = async () => { - await this.activityDefinitionsApi.unpublishMany({definitionIds: this.selectedActivityDefinitionIds}); - await this.loadActivityDefinitions(); + this.modalDialogService.show( + () => DefaultContents.Warning("Are you sure you want to unpublish selected activity definitions?"), + [DefaultActions.Unpublish(async () => + { + await this.activityDefinitionsApi.unpublishMany({definitionIds: this.selectedActivityDefinitionIds}); + await this.loadActivityDefinitions(); + }), DefaultActions.Cancel()], + ModalType.Confirmation); }; private onActivityDefinitionClick = async (e: MouseEvent, ActivityDefinition: ActivityDefinitionSummary) => { diff --git a/src/designer/elsa-workflows-designer/src/modules/workflow-definitions/components/browser.tsx b/src/designer/elsa-workflows-designer/src/modules/workflow-definitions/components/browser.tsx index f1a769e9e..64be0a9f2 100644 --- a/src/designer/elsa-workflows-designer/src/modules/workflow-definitions/components/browser.tsx +++ b/src/designer/elsa-workflows-designer/src/modules/workflow-definitions/components/browser.tsx @@ -7,7 +7,7 @@ import {PagerData} from '../../../components/shared/pager/pager'; import {updateSelectedWorkflowDefinitions} from '../services/utils'; import {WorkflowDefinitionSummary} from "../models/entities"; import {WorkflowDefinitionsApi, WorkflowDefinitionsOrderBy} from "../services/api"; -import {DefaultActions} from "../../../components/shared/modal-dialog"; +import {ModalDialogService, DefaultActions, DefaultContents, ModalType} from "../../../components/shared/modal-dialog"; @Component({ tag: 'elsa-workflow-definition-browser', @@ -21,9 +21,11 @@ export class WorkflowDefinitionBrowser { private readonly api: WorkflowDefinitionsApi; private selectAllCheckbox: HTMLInputElement; + private readonly modalDialogService: ModalDialogService; constructor() { this.api = Container.get(WorkflowDefinitionsApi); + this.modalDialogService = Container.get(ModalDialogService); } @Event() workflowDefinitionSelected: EventEmitter; @@ -56,28 +58,43 @@ export class WorkflowDefinitionBrowser { } private async onDeleteClick(e: MouseEvent, workflowDefinition: WorkflowDefinitionSummary) { - // const result = await this.confirmDialog.show(t('DeleteConfirmationModel.Title'), t('DeleteConfirmationModel.Message')); - // - // if (!result) - // return; - - await this.api.delete(workflowDefinition); - await this.loadWorkflowDefinitions(); + this.modalDialogService.show( + () => DefaultContents.Warning("Are you sure you want to delete this workflow definition?"), + [DefaultActions.Delete(()=>{}), DefaultActions.Cancel()], + ModalType.Confirmation); } private onDeleteManyClick = async () => { - await this.api.deleteMany({definitionIds: this.selectedWorkflowDefinitionIds}); - await this.loadWorkflowDefinitions(); + this.modalDialogService.show( + () => DefaultContents.Warning("Are you sure you want to delete selected workflow definitions?"), + [DefaultActions.Delete(async () => + { + await this.api.deleteMany({definitionIds: this.selectedWorkflowDefinitionIds}); + await this.loadWorkflowDefinitions(); + }), DefaultActions.Cancel()], + ModalType.Confirmation); }; private onPublishManyClick = async () => { - await this.api.publishMany({definitionIds: this.selectedWorkflowDefinitionIds}); - await this.loadWorkflowDefinitions(); + this.modalDialogService.show( + () => DefaultContents.Warning("Are you sure you want to publish selected workflow definitions?"), + [DefaultActions.Publish(async () => + { + await this.api.publishMany({definitionIds: this.selectedWorkflowDefinitionIds}); + await this.loadWorkflowDefinitions(); + }), DefaultActions.Cancel()], + ModalType.Confirmation); }; private onUnpublishManyClick = async () => { - await this.api.unpublishMany({definitionIds: this.selectedWorkflowDefinitionIds}); - await this.loadWorkflowDefinitions(); + this.modalDialogService.show( + () => DefaultContents.Warning("Are you sure you want to unpublish selected workflow definitions?"), + [DefaultActions.Unpublish(async () => + { + await this.api.unpublishMany({definitionIds: this.selectedWorkflowDefinitionIds}); + await this.loadWorkflowDefinitions(); + }), DefaultActions.Cancel()], + ModalType.Confirmation); }; private onWorkflowDefinitionClick = async (e: MouseEvent, workflowDefinition: WorkflowDefinitionSummary) => { diff --git a/src/designer/elsa-workflows-designer/src/modules/workflow-definitions/components/version-history.tsx b/src/designer/elsa-workflows-designer/src/modules/workflow-definitions/components/version-history.tsx index 3345c7e70..7c4881008 100644 --- a/src/designer/elsa-workflows-designer/src/modules/workflow-definitions/components/version-history.tsx +++ b/src/designer/elsa-workflows-designer/src/modules/workflow-definitions/components/version-history.tsx @@ -28,15 +28,6 @@ export class WorkflowDefinitionVersionHistory { @Event() deleteVersionClicked: EventEmitter; @Event() revertVersionClicked: EventEmitter; - @Watch('workflowDefinition') - async onWorkflowDefinitionChanged(value: WorkflowDefinition) { - - } - - async componentWillLoad() { - - } - onViewVersionClick = (e: Event, version: WorkflowDefinition) => { e.preventDefault(); this.versionSelected.emit(version); @@ -45,9 +36,9 @@ export class WorkflowDefinitionVersionHistory { onDeleteVersionClick = async (e: Event, version: WorkflowDefinition) => { e.preventDefault(); this.modalDialogService.show( - () => DefaultContents.Delete("Are you sure you want to delete this version?"), + () => DefaultContents.Warning("Are you sure you want to delete this version?"), [DefaultActions.Delete(() => this.deleteVersionClicked.emit(version)), DefaultActions.Cancel()], - ModalType.DeleteConfirmation); + ModalType.Confirmation); }; onRevertVersionClick = (e: Event, version: WorkflowDefinition) => {