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
55 routeToOverview = () => {
56 const { history, match } = this.props;
57 const workflowId = match.params.workflowId;
58 history.push(`/workflows/workflow/${workflowId}/overview`);
61 sendSaveParamsToServer = () => {
68 saveParamsToServer({ params: savedParams, workflowId, workflowName });
70 handleSendMsgToCatalog = () => {
72 pluginContext: { eventsClientId, parentUrl },
76 const client = new PluginPubSub(eventsClientId, parentUrl);
77 client.notify(notificationType.CLOSE, {
78 isCompleted: isCertifyDisable,
83 certifyVersion = () => {
87 currentWorkflowVersion,
94 versionId: currentWorkflowVersion.id,
99 versionChangeCallback = versionId => {
100 const { changeVersion, workflowId } = this.props;
101 changeVersion({ versionId, workflowId });
104 undoClickCallback = () => {
106 currentWorkflowVersion,
110 changeVersion({ versionId: currentWorkflowVersion.id, workflowId });
115 currentWorkflowVersion,
123 const isReadonly = isCertifyDisable || hasErrors || isArchive;
125 <div className="version-controller-bar">
126 <WorkflowTitle workflowName={workflowName} />
128 className={`vc-container ${
129 operationMode ? 'vs-container-operation' : ''
133 currentWorkflowVersion={currentWorkflowVersion}
134 viewableVersions={versionsList}
135 onOverviewClick={this.routeToOverview}
136 onVersionSelectChange={this.versionChangeCallback}
137 isArchive={isArchive}
141 <OperationModeButtons
142 sendMsgToCatalog={this.handleSendMsgToCatalog}
143 saveDisabled={isReadonly}
144 onSaveClick={this.sendSaveParamsToServer}
145 onCertifyClick={this.certifyVersion}
150 saveDisabled={isReadonly}
151 onSaveClick={this.sendSaveParamsToServer}
152 certifyDisabled={isReadonly}
153 onCertifyClick={this.certifyVersion}
154 onUndoClick={this.undoClickCallback}
163 VersionControllerView.defaultProps = {
164 getVersions: () => {}