blob: 06e83164df1d1a383115e794f822b123764faa43 [file] [log] [blame]
sebdet1e2760e2021-02-26 19:14:03 +01001/*-
2 * ============LICENSE_START=======================================================
3 * ONAP POLICY-CLAMP
4 * ================================================================================
5 * Copyright (C) 2021 AT&T Intellectual Property. All rights
6 * reserved.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END============================================
20 * ===================================================================
21 *
22 */
23
24import React from 'react'
25import PolicyToscaService from '../../../api/PolicyToscaService';
26import styled from 'styled-components';
27import Button from 'react-bootstrap/Button';
28
29const JsonEditorDiv = styled.div`
30 margin-top: 20px;
31 background-color: ${props => props.theme.toscaTextareaBackgroundColor};
32 text-align: justify;
33 font-size: ${props => props.theme.toscaTextareaFontSize};
34 width: 100%;
35 height: 30%;
36`
37
38export default class ToscaViewer extends React.Component {
39
40 state = {
41 toscaData: this.props.toscaData,
42 yamlPolicyTosca: this.getToscaModelYamlFor(this.props.toscaData),
43 }
44
45 constructor(props, context) {
46 super(props, context);
47 this.getToscaModelYamlFor = this.getToscaModelYamlFor.bind(this);
48 }
49
50 getToscaModelYamlFor(toscaData) {
51 PolicyToscaService.getToscaPolicyModelYaml(toscaData["policyModelType"], toscaData["version"]).then(respYamlPolicyTosca => {
52 this.setState({
53 yamlPolicyTosca: respYamlPolicyTosca,
54 })
55 });
56 }
57
58 render() {
59 return (
60 <JsonEditorDiv>
61 <pre>{this.state.yamlPolicyTosca}</pre>
62 <Button variant="secondary" title="Create a new policy version from the defined parameters"
63 onClick={this.handleCreateNewVersion}>Create New Version</Button>
64 </JsonEditorDiv>
65 );
66 }
67}