2 * Copyright © 2018 European Support Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 import React, { Component } from 'react';
17 import PropTypes from 'prop-types';
19 import ActionButtons from 'features/version/versionController/views/ActionButtons';
20 import OperationModeButtons from 'features/version/versionController/views/OperationModeButtons';
21 import VersionContainer from 'features/version/versionController/views/VersionsContainer';
22 import WorkflowTitle from 'features/version/versionController/views/WorkflowTitle';
23 import { PluginPubSub } from 'shared/pubsub/plugin-pubsub.ts';
27 } from 'wfapp/pluginContext/pluginContextConstants';
28 export default class VersionControllerView extends Component {
30 location: PropTypes.object,
31 workflowName: PropTypes.string,
32 currentWorkflowVersion: PropTypes.object,
33 viewableVersions: PropTypes.arrayOf(Object),
34 getVersions: PropTypes.func,
35 versionsList: PropTypes.array,
36 history: PropTypes.object,
37 getOverview: PropTypes.func,
38 match: PropTypes.object,
39 savedParams: PropTypes.object,
40 saveParamsToServer: PropTypes.func,
41 workflowId: PropTypes.string,
42 certifyVersion: PropTypes.func,
43 changeVersion: PropTypes.func,
44 isCertifyDisable: PropTypes.bool,
45 hasErrors: PropTypes.bool,
46 isArchive: PropTypes.bool,
47 operationMode: PropTypes.bool,
48 pluginContext: PropTypes.object,
49 isCompositionUpdating: PropTypes.bool,
50 toggleCompositionUpdate: PropTypes.func
57 routeToOverview = () => {
58 const { history, match } = this.props;
59 const workflowId = match.params.workflowId;
60 history.push(`/workflows/workflow/${workflowId}/overview`);
63 sendSaveParamsToServer = () => {
70 saveParamsToServer({ params: savedParams, workflowId, workflowName });
72 handleSendMsgToCatalog = () => {
74 pluginContext: { eventsClientId, parentUrl },
78 const client = new PluginPubSub(eventsClientId, parentUrl);
79 client.notify(notificationType.CLOSE, {
80 isCompleted: isCertifyDisable,
85 certifyVersion = () => {
89 currentWorkflowVersion,
96 versionId: currentWorkflowVersion.id,
101 versionChangeCallback = versionId => {
102 const { changeVersion, workflowId } = this.props;
103 changeVersion({ versionId, workflowId });
106 undoClickCallback = () => {
108 currentWorkflowVersion,
112 changeVersion({ versionId: currentWorkflowVersion.id, workflowId });
117 currentWorkflowVersion,
124 isCompositionUpdating,
125 toggleCompositionUpdate
127 const isReadonly = isCertifyDisable || hasErrors || isArchive;
129 <div className="version-controller-bar">
130 <WorkflowTitle workflowName={workflowName} />
132 className={`vc-container ${
133 operationMode ? 'vs-container-operation' : ''
137 currentWorkflowVersion={currentWorkflowVersion}
138 viewableVersions={versionsList}
139 onOverviewClick={this.routeToOverview}
140 onVersionSelectChange={this.versionChangeCallback}
141 isArchive={isArchive}
145 <OperationModeButtons
146 sendMsgToCatalog={this.handleSendMsgToCatalog}
147 saveDisabled={isReadonly}
148 onSaveClick={this.sendSaveParamsToServer}
149 onCertifyClick={this.certifyVersion}
154 isCompositionUpdating={isCompositionUpdating}
155 saveDisabled={isReadonly}
156 onSaveClick={this.sendSaveParamsToServer}
157 certifyDisabled={isReadonly}
158 onCertifyClick={this.certifyVersion}
159 onUndoClick={this.undoClickCallback}
160 toggleCompositionUpdate={toggleCompositionUpdate}
169 VersionControllerView.defaultProps = {
170 getVersions: () => {}