aboutsummaryrefslogtreecommitdiffstats
path: root/workflow/workflow-designer-ui/src/main/frontend/src/features/version/versionController/VersionControllerView.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'workflow/workflow-designer-ui/src/main/frontend/src/features/version/versionController/VersionControllerView.jsx')
-rw-r--r--workflow/workflow-designer-ui/src/main/frontend/src/features/version/versionController/VersionControllerView.jsx110
1 files changed, 110 insertions, 0 deletions
diff --git a/workflow/workflow-designer-ui/src/main/frontend/src/features/version/versionController/VersionControllerView.jsx b/workflow/workflow-designer-ui/src/main/frontend/src/features/version/versionController/VersionControllerView.jsx
new file mode 100644
index 00000000..27260e60
--- /dev/null
+++ b/workflow/workflow-designer-ui/src/main/frontend/src/features/version/versionController/VersionControllerView.jsx
@@ -0,0 +1,110 @@
+/*
+* Copyright © 2018 European Support Limited
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+ * http://www.apache.org/licenses/LICENSE-2.0
+*
+ * Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+import React, { Component } from 'react';
+import PropTypes from 'prop-types';
+
+import ActionButtons from 'features/version/versionController/views/ActionButtons';
+import VersionContainer from 'features/version/versionController/views/VersionsContainer';
+import WorkflowTitle from 'features/version/versionController/views/WorkflowTitle';
+import { versionState as versionStateType } from 'features/version/versionConstants';
+
+export default class VersionControllerView extends Component {
+ static propTypes = {
+ location: PropTypes.object,
+ workflowName: PropTypes.string,
+ currentWorkflowVersion: PropTypes.string,
+ viewableVersions: PropTypes.arrayOf(Object),
+ callForAction: PropTypes.func,
+ getVersions: PropTypes.func,
+ versionsList: PropTypes.array,
+ history: PropTypes.object,
+ getOverview: PropTypes.func,
+ match: PropTypes.object,
+ savedParams: PropTypes.object,
+ saveParamsToServer: PropTypes.func,
+ workflowId: PropTypes.string,
+ versionState: PropTypes.string,
+ certifyVersion: PropTypes.func
+ };
+
+ constructor(props) {
+ super(props);
+ }
+
+ dynamicDispatcher = (action, payload) => {
+ const { history, callForAction } = this.props;
+ const actionName =
+ typeof action === 'object'
+ ? action.target.attributes.actionType.value
+ : action;
+ let pageName = history.location.pathname.split('/').pop();
+ callForAction(pageName + '/' + actionName, payload);
+ };
+
+ routeToOverview = () => {
+ const { history, match } = this.props;
+ const workflowId = match.params.workflowId;
+ history.push('/workflow/' + workflowId + '/overview');
+ };
+
+ sendSaveParamsToServer = () => {
+ const { savedParams, saveParamsToServer, workflowId } = this.props;
+ saveParamsToServer({ params: savedParams, workflowId });
+ };
+
+ certifyVersion = () => {
+ const {
+ certifyVersion,
+ workflowId,
+ currentWorkflowVersion
+ } = this.props;
+ certifyVersion({ workflowId, versionId: currentWorkflowVersion });
+ };
+
+ render() {
+ const {
+ currentWorkflowVersion,
+ workflowName,
+ versionsList,
+ versionState
+ } = this.props;
+ let isCertifyDisable =
+ versionState &&
+ versionState.toLowerCase() === versionStateType.CERTIFIED;
+ return (
+ <div className="version-controller-bar">
+ <WorkflowTitle workflowName={workflowName} />
+ <div className="vc-container">
+ <VersionContainer
+ currentWorkflowVersion={currentWorkflowVersion}
+ viewableVersions={versionsList}
+ onOverviewClick={this.routeToOverview}
+ />
+ <ActionButtons
+ onSaveClick={this.sendSaveParamsToServer}
+ certifyDisabled={isCertifyDisable}
+ onCertifyClick={this.certifyVersion}
+ />
+ </div>
+ </div>
+ );
+ }
+}
+
+VersionControllerView.defaultProps = {
+ getVersions: () => {},
+ callForAction: () => {}
+};