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 VersionContainer from 'features/version/versionController/views/VersionsContainer';
21 import WorkflowTitle from 'features/version/versionController/views/WorkflowTitle';
23 export default class VersionControllerView extends Component {
25 location: PropTypes.object,
26 workflowName: PropTypes.string,
27 currentWorkflowVersion: PropTypes.object,
28 viewableVersions: PropTypes.arrayOf(Object),
29 getVersions: PropTypes.func,
30 versionsList: PropTypes.array,
31 history: PropTypes.object,
32 getOverview: PropTypes.func,
33 match: PropTypes.object,
34 savedParams: PropTypes.object,
35 saveParamsToServer: PropTypes.func,
36 workflowId: PropTypes.string,
37 certifyVersion: PropTypes.func,
38 changeVersion: PropTypes.func,
39 isCertifyDisable: PropTypes.bool,
40 hasErrors: PropTypes.bool,
41 isArchive: PropTypes.bool
48 routeToOverview = () => {
49 const { history, match } = this.props;
50 const workflowId = match.params.workflowId;
51 history.push('/workflow/' + workflowId + '/overview');
54 sendSaveParamsToServer = () => {
61 saveParamsToServer({ params: savedParams, workflowId, workflowName });
64 certifyVersion = () => {
68 currentWorkflowVersion,
75 versionId: currentWorkflowVersion.id,
80 versionChangeCallback = versionId => {
81 const { changeVersion, workflowId } = this.props;
82 changeVersion({ versionId, workflowId });
85 undoClickCallback = () => {
87 currentWorkflowVersion,
91 changeVersion({ versionId: currentWorkflowVersion.id, workflowId });
96 currentWorkflowVersion,
103 const isReadonly = isCertifyDisable || hasErrors || isArchive;
105 <div className="version-controller-bar">
106 <WorkflowTitle workflowName={workflowName} />
107 <div className="vc-container">
109 currentWorkflowVersion={currentWorkflowVersion}
110 viewableVersions={versionsList}
111 onOverviewClick={this.routeToOverview}
112 onVersionSelectChange={this.versionChangeCallback}
113 isArchive={isArchive}
116 saveDisabled={isReadonly}
117 onSaveClick={this.sendSaveParamsToServer}
118 certifyDisabled={isReadonly}
119 onCertifyClick={this.certifyVersion}
120 onUndoClick={this.undoClickCallback}
128 VersionControllerView.defaultProps = {
129 getVersions: () => {}