2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2021 Nordix Foundation.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
20 import React, { useState } from "react";
21 import GetToscaTemplate from "../../api/GetToscaTemplate";
22 import Modal from "react-bootstrap/Modal";
23 import Button from "react-bootstrap/Button";
25 import styled from 'styled-components';
27 const ModalStyled = styled(Modal)`
28 background-color: transparent;
31 const ErrMsgStyled = styled.div`
35 const PreStyled = styled.pre`
41 const ReadAndConvertYaml = (props) => {
42 const [show, setShow] = useState(true);
43 const [toscaTemplateData, setToscaTemplateData] = useState();
44 const name = 'ToscaServiceTemplateSimple';
45 const version = '1.0.0';
47 const handleClose = () => {
48 console.log('handleClose called');
50 props.history.push('/');
53 const getToscaServiceTemplateHandler = async (toscaServiceTemplate) => {
54 console.log('getToscaServiceTemplateHandler called');
56 ...toscaServiceTemplate,
57 id: Math.random().toString()
59 // console.log(toscaData);
60 setToscaTemplateData(toscaData);
64 <ModalStyled size="xl"
66 onHide={ handleClose }
69 <Modal.Header closeButton>
70 <Modal.Title>View Tosca Template</Modal.Title>
73 <GetToscaTemplate templateName={ name }
74 templateVersion={ version }
75 onGetToscaServiceTemplate={ getToscaServiceTemplateHandler }/>
76 <PreStyled>{ JSON.stringify(toscaTemplateData, null, 2) }</PreStyled>
79 <Button variant="secondary"
81 onClick={ handleClose }>Cancel</Button>
87 export default ReadAndConvertYaml;