493ad650696d7b277e06c896caa8b6516b4799a5
[sdc/sdc-workflow-designer.git] /
1 /*
2 * Copyright © 2018 European Support Limited
3 *
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
7
8  *      http://www.apache.org/licenses/LICENSE-2.0
9
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.
15 */
16 import React, { Component } from 'react';
17 import { I18n } from 'react-redux-i18n';
18 import { Input, Button } from 'sdc-ui/lib/react';
19 import PropTypes from 'prop-types';
20
21 import Description from 'shared/components/Description';
22 import { VersionInfo, LabeledValue } from 'shared/components/VersionInfo';
23
24 class WorkflowDetails extends Component {
25     constructor(props) {
26         super(props);
27         this.state = {
28             editWorkflow: ''
29         };
30     }
31
32     workflowDetailsChanged = val => {
33         this.setState({ editWorkflow: val });
34     };
35
36     handleSubmitForm = e => {
37         e.preventDefault();
38         this.props.updateWorkflow(this.state.editWorkflow);
39     };
40
41     render() {
42         const { name, description, workflowId, versionId } = this.props;
43         return (
44             <div className="workflow-details">
45                 <form onSubmit={this.handleSubmitForm}>
46                     <Input
47                         name="workflowName"
48                         value={name || ''}
49                         type="text"
50                         label={I18n.t('workflow.general.name')}
51                         isRequired
52                         disabled
53                     />
54                     <Description
55                         description={
56                             this.state.editWorkflow.description || description
57                         }
58                         onDataChange={this.workflowDetailsChanged}
59                     />
60                     <div className="save-description">
61                         <Button btnType="primary">
62                             {I18n.t('buttons.saveBtn')}
63                         </Button>
64                     </div>
65                 </form>
66                 <VersionInfo>
67                     {versionId && (
68                         <LabeledValue title="UUID" value={versionId} />
69                     )}
70                     <LabeledValue title="Invariant UUID" value={workflowId} />
71                 </VersionInfo>
72             </div>
73         );
74     }
75 }
76
77 WorkflowDetails.propTypes = {
78     name: PropTypes.string,
79     created: PropTypes.string,
80     modified: PropTypes.string,
81     description: PropTypes.string,
82     workflowId: PropTypes.string,
83     versionId: PropTypes.string,
84     updateWorkflow: PropTypes.func
85 };
86
87 export default WorkflowDetails;