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';
24 import { notificationType } from 'wfapp/pluginContext/pluginContextConstants';
25 export default class VersionControllerView extends Component {
27 location: PropTypes.object,
28 workflowName: PropTypes.string,
29 currentWorkflowVersion: PropTypes.object,
30 viewableVersions: PropTypes.arrayOf(Object),
31 getVersions: PropTypes.func,
32 versionsList: PropTypes.array,
33 history: PropTypes.object,
34 getOverview: PropTypes.func,
35 match: PropTypes.object,
36 savedParams: PropTypes.object,
37 saveParamsToServer: PropTypes.func,
38 workflowId: PropTypes.string,
39 certifyVersion: PropTypes.func,
40 changeVersion: PropTypes.func,
41 isCertifyDisable: PropTypes.bool,
42 hasErrors: PropTypes.bool,
43 isArchive: PropTypes.bool,
44 operationMode: PropTypes.bool,
45 pluginContext: PropTypes.object
52 routeToOverview = () => {
53 const { history, match } = this.props;
54 const workflowId = match.params.workflowId;
55 history.push('/workflow/' + workflowId + '/overview');
58 sendSaveParamsToServer = () => {
65 saveParamsToServer({ params: savedParams, workflowId, workflowName });
67 handleSendMsgToCatalog = isCompeleted => {
69 pluginContext: { eventsClientId, parentUrl }
71 const client = new PluginPubSub(eventsClientId, parentUrl);
72 client.notify(notificationType.CLOSE, { isCompleted: isCompeleted });
74 certifyVersion = () => {
78 currentWorkflowVersion,
85 versionId: currentWorkflowVersion.id,
90 versionChangeCallback = versionId => {
91 const { changeVersion, workflowId } = this.props;
92 changeVersion({ versionId, workflowId });
95 undoClickCallback = () => {
97 currentWorkflowVersion,
101 changeVersion({ versionId: currentWorkflowVersion.id, workflowId });
106 currentWorkflowVersion,
114 const isReadonly = isCertifyDisable || hasErrors || isArchive;
116 <div className="version-controller-bar">
117 <WorkflowTitle workflowName={workflowName} />
119 className={`vc-container ${
120 operationMode ? 'vs-container-operation' : ''
124 currentWorkflowVersion={currentWorkflowVersion}
125 viewableVersions={versionsList}
126 onOverviewClick={this.routeToOverview}
127 onVersionSelectChange={this.versionChangeCallback}
128 isArchive={isArchive}
132 <OperationModeButtons
133 sendMsgToCatalog={this.handleSendMsgToCatalog}
134 saveDisabled={isReadonly}
135 onSaveClick={this.sendSaveParamsToServer}
140 saveDisabled={isReadonly}
141 onSaveClick={this.sendSaveParamsToServer}
142 certifyDisabled={isReadonly}
143 onCertifyClick={this.certifyVersion}
144 onUndoClick={this.undoClickCallback}
153 VersionControllerView.defaultProps = {
154 getVersions: () => {}