Fix unpublish button

This commit is contained in:
Gürkan Güran 2023-04-14 17:36:41 +02:00
parent 56d8ac539d
commit 20d9b79abe
4 changed files with 28 additions and 2 deletions

View file

@ -131,6 +131,7 @@ export class WorkflowDefinitionsPlugin implements Plugin {
public showWorkflowDefinitionEditor = (workflowDefinition: WorkflowDefinition) => {
toolbarComponentStore.components = [() => <elsa-workflow-publish-button onPublishClicked={this.onPublishClicked}
onUnPublishClicked={this.onUnPublishClicked}
onExportClicked={this.onExportClicked}
onImportClicked={this.onImportClicked}/>];
studioComponentStore.activeComponentFactory = () => <elsa-workflow-definition-editor
@ -238,6 +239,29 @@ export class WorkflowDefinitionsPlugin implements Plugin {
});
}
private onUnPublishClicked = async (e: CustomEvent) => {
const definition = await this.workflowDefinitionEditorElement.getWorkflowDefinition();
const notification = NotificationService.createNotification({
title: 'Unpublishing',
id: uuid(),
text: 'Unpublishing the workflow. Please wait.',
type: NotificationDisplayType.InProgress
});
await this.workflowDefinitionManager.retractWorkflow(definition)
.then(async () => {
NotificationService.updateNotification(notification, {title: 'Workflow unpublished', text: 'Unpublished!'})
await this.activityDescriptorManager.refresh();
}).catch(() => {
NotificationService.updateNotification(notification, {
title: 'Error while unpublishing',
text: <span>Workflow {definition.definitionId} could not be unpublished.</span>,
type: NotificationDisplayType.Error
});
});
}
private onExportClicked = async (e: CustomEvent) => {
const workflowDefinition = await this.workflowDefinitionEditorElement.getWorkflowDefinition();
await this.workflowDefinitionManager.exportWorkflow(workflowDefinition);

View file

@ -23,7 +23,7 @@ export class WorkflowDefinitionsApi {
async retract(request: RetractWorkflowDefinitionRequest): Promise<WorkflowDefinition> {
const httpClient = await this.getHttpClient();
const response = await httpClient.post<WorkflowDefinition>(`workflow-definitions/${request.definitionId}/retract`);
const response = await httpClient.post<WorkflowDefinition>(`workflow-definitions/${request.definitionId}/retract`, request);
return response.data;
}

View file

@ -9,7 +9,7 @@ import {
WorkflowExecutionLogRecord,
Workflow
} from '../../../models';
import {PluginRegistry, ActivityNameFormatter, ActivityDriverRegistry, EventBus, ActivityNode} from '../../../services';
import {ActivityDriverRegistry, EventBus, ActivityNode} from '../../../services';
import {MonacoEditorSettings} from "../../../services/monaco-editor-settings";
import {WorkflowDefinition} from "../../workflow-definitions/models/entities";
import {WorkflowEditorEventTypes} from "../../workflow-definitions/models/ui";

View file

@ -3,9 +3,11 @@ using Elsa.Common.Models;
using Elsa.Workflows.Api.Mappers;
using Elsa.Workflows.Api.Models;
using Elsa.Workflows.Management.Contracts;
using JetBrains.Annotations;
namespace Elsa.Workflows.Api.Endpoints.WorkflowDefinitions.Retract;
[PublicAPI]
internal class Retract : ElsaEndpoint<Request, WorkflowDefinitionResponse, WorkflowDefinitionMapper>
{
private readonly IWorkflowDefinitionStore _store;