diff options
author | saul.gill <saul.gill@est.tech> | 2021-07-02 17:10:54 +0100 |
---|---|---|
committer | saul.gill <saul.gill@est.tech> | 2021-07-02 17:10:59 +0100 |
commit | 6687b48b58bf1248532de48f3e375b1f663f4015 (patch) | |
tree | 6582070c8db251b85695bcdc902ea98aac573003 /gui-clamp/ui-react/src/components | |
parent | b908988c81db910d4e2bea3e569e468f5f2c8f85 (diff) |
Changed components to be service-centric
Moved endpoints to ControlLoopService.js
Refactored components and tests
Issue-ID: POLICY-3424
Change-Id: I70d48750250eecd651b845ef0c726617983f75f5
Signed-off-by: saul.gill <saul.gill@est.tech>
Diffstat (limited to 'gui-clamp/ui-react/src/components')
15 files changed, 480 insertions, 218 deletions
diff --git a/gui-clamp/ui-react/src/components/dialogs/GetLocalToscaFileForUpload.js b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/GetLocalToscaFileForUpload.js index bac9953..013dd89 100644 --- a/gui-clamp/ui-react/src/components/dialogs/GetLocalToscaFileForUpload.js +++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/GetLocalToscaFileForUpload.js @@ -1,23 +1,20 @@ /* - * - - * * ============LICENSE_START======================================================= - * * Copyright (C) 2021 Nordix Foundation. - * * ================================================================================ - * * 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. - * * - * * SPDX-License-Identifier: Apache-2.0 - * * ============LICENSE_END========================================================= + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= */ import React, { useState } from 'react'; @@ -28,7 +25,7 @@ import Row from 'react-bootstrap/Row'; import styled from 'styled-components'; import Alert from 'react-bootstrap/Alert'; import * as yaml from "js-yaml"; -import UploadToscaFile from "../../api/UploadToscaFile"; +import UploadToscaFile from "./UploadToscaFile"; const ModalStyled = styled(Modal)` background-color: transparent; @@ -82,9 +79,9 @@ const GetLocalToscaFileForUpload = (props) => { } }; - const receiveResponseFromUpload = (response, responseMessage) => { + const receiveResponseFromUpload = async (response) => { - if (response.ok) { + if (await response.ok) { setAlertMessages(<Alert variant="success"> <Alert.Heading>Upload Success</Alert.Heading> <p>Tosca Service Template from { selectedFile.name } was Successfully Uploaded</p> @@ -96,8 +93,8 @@ const GetLocalToscaFileForUpload = (props) => { setAlertMessages(<Alert variant="danger"> <Alert.Heading>Upload Failure</Alert.Heading> <p>Tosca Service Template from { selectedFile.name } failed to upload</p> - <p>Status code: { response.status }: { response.statusText }</p> - <p>Response from CLAMP: { responseMessage }</p> + <p>Status code: { await response.status }: { response.statusText }</p> + <p>Response Text: { await response.text() }</p> <hr/> <p>Type: { selectedFile.type }</p><p>Size: { +selectedFile.size / 1000 }Kb</p> </Alert>); diff --git a/gui-clamp/ui-react/src/components/dialogs/GetLocalToscaFileForUpload.test.js b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/GetLocalToscaFileForUpload.test.js index dfd3b9e..9b885c6 100644 --- a/gui-clamp/ui-react/src/components/dialogs/GetLocalToscaFileForUpload.test.js +++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/GetLocalToscaFileForUpload.test.js @@ -1,24 +1,22 @@ /* - * - - * * ============LICENSE_START======================================================= - * * Copyright (C) 2021 Nordix Foundation. - * * ================================================================================ - * * 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. - * * - * * SPDX-License-Identifier: Apache-2.0 - * * ============LICENSE_END========================================================= + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= */ + import React from 'react'; import { mount, shallow } from 'enzyme'; import toJson from 'enzyme-to-json'; diff --git a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/GetToscaTemplate.js b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/GetToscaTemplate.js new file mode 100644 index 0000000..7da8c13 --- /dev/null +++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/GetToscaTemplate.js @@ -0,0 +1,50 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +import React, { useState } from "react"; +import Button from "react-bootstrap/Button"; +import ControlLoopService from "../../../api/ControlLoopService"; + +const GetToscaTemplate = (props) => { + + const [windowLocationPathName, setWindowLocationPathname] = useState(''); + + const getTemplateHandler = async () => { + console.log('getTemplateHandler called') + setWindowLocationPathname(window.location.pathname); + + const response = await ControlLoopService.getToscaTemplate(props.templateName, props.templateVersion, windowLocationPathName) + .catch(error => error.message); + + props.onGetToscaServiceTemplate(response); + + } + + return ( + <React.Fragment> + <Button variant="primary" + type="submit" + onClick={ getTemplateHandler }>Get Tosca Service Template</Button> + </React.Fragment> + ); + + +} + +export default GetToscaTemplate; diff --git a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/GetToscaTemplate.test.js b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/GetToscaTemplate.test.js new file mode 100644 index 0000000..ce2a398 --- /dev/null +++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/GetToscaTemplate.test.js @@ -0,0 +1,53 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +import React from 'react'; +import { mount, shallow } from 'enzyme'; +import GetToscaTemplate from './GetToscaTemplate'; +import toJson from "enzyme-to-json"; + +describe('Verify GetToscaTemplate', () => { + + it("renders without crashing", () => { + shallow(<GetToscaTemplate/>); + }); + + it("renders correctly", () => { + const tree = shallow(<GetToscaTemplate/>); + expect(toJson(tree)).toMatchSnapshot(); + }); + + it('should have a Button element', () => { + const container = shallow(<GetToscaTemplate/>) + expect(container.find('Button').length).toEqual(1); + }); + + it('button should call getTemplateHandler when clicked', async () => { + const component = mount(<GetToscaTemplate/>) + const logSpy = jest.spyOn(console, 'log'); + + component.find('[variant="primary"]').simulate('click'); + expect(logSpy).toHaveBeenCalledWith('getTemplateHandler called'); + }); + + it('should have a Button element with specified text', () => { + const container = shallow(<GetToscaTemplate/>) + expect(container.find('Button').text()).toBe('Get Tosca Service Template'); + }); +}); diff --git a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/ReadAndConvertYaml.js b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/ReadAndConvertYaml.js new file mode 100644 index 0000000..53b541c --- /dev/null +++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/ReadAndConvertYaml.js @@ -0,0 +1,96 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +import React, { useState } from "react"; +import GetToscaTemplate from "./GetToscaTemplate"; +import Modal from "react-bootstrap/Modal"; +import Button from "react-bootstrap/Button"; +import { Alert } from "react-bootstrap"; + +import styled from 'styled-components'; + +const ModalStyled = styled(Modal)` + background-color: transparent; +` + +const AlertStyled = styled(Alert)` + margin-top: 10px; +` + +const PreStyled = styled.pre` + color: #7F0055; + overflow: auto; + max-height: 70vh; + margin-top: 10px; +` + +const ReadAndConvertYaml = (props) => { + const [show, setShow] = useState(true); + const [toscaTemplateData, setToscaTemplateData] = useState(); + const [responeOk, setResponseOk] = useState(true); + const name = 'ToscaServiceTemplateSimple'; + const version = '1.0.0'; + + const handleClose = () => { + console.log('handleClose called'); + setShow(false); + props.history.push('/'); + } + + const getToscaServiceTemplateHandler = async (toscaServiceTemplateResponse) => { + // console.log('getToscaServiceTemplateHandler called: ' + toscaServiceTemplate); + + if (!toscaServiceTemplateResponse.ok) { + setResponseOk(false); + const toscaData = await toscaServiceTemplateResponse; + setToscaTemplateData(toscaData); + } else { + setResponseOk(true); + const toscaData = await toscaServiceTemplateResponse.json(); + setToscaTemplateData(toscaData); + } + } + + return ( + <ModalStyled size="xl" + show={ show } + onHide={ handleClose } + backdrop="static" + keyboard={ false }> + <Modal.Header closeButton> + <Modal.Title>View Tosca Template</Modal.Title> + </Modal.Header> + <Modal.Body> + <GetToscaTemplate templateName={ name } + templateVersion={ version } + onGetToscaServiceTemplate={ getToscaServiceTemplateHandler }/> + { responeOk && <PreStyled> { JSON.stringify(toscaTemplateData, null, 2) } </PreStyled> } + <AlertStyled show={ !responeOk } + variant="danger">{ toscaTemplateData }</AlertStyled> + </Modal.Body> + <Modal.Footer> + <Button variant="secondary" + type="null" + onClick={ handleClose }>Cancel</Button> + </Modal.Footer> + </ModalStyled> + ); +}; + +export default ReadAndConvertYaml; diff --git a/gui-clamp/ui-react/src/components/dialogs/ReadAndConvertYaml.test.js b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/ReadAndConvertYaml.test.js index daec619..90d7185 100644 --- a/gui-clamp/ui-react/src/components/dialogs/ReadAndConvertYaml.test.js +++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/ReadAndConvertYaml.test.js @@ -1,24 +1,22 @@ /* - * - - * * ============LICENSE_START======================================================= - * * Copyright (C) 2021 Nordix Foundation. - * * ================================================================================ - * * 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. - * * - * * SPDX-License-Identifier: Apache-2.0 - * * ============LICENSE_END========================================================= + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= */ + import React from 'react'; import { mount, shallow } from 'enzyme'; import ReadAndConvertYaml from './ReadAndConvertYaml'; diff --git a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/UploadToscaFile.js b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/UploadToscaFile.js new file mode 100644 index 0000000..6ee6a43 --- /dev/null +++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/UploadToscaFile.js @@ -0,0 +1,54 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +import Button from "react-bootstrap/Button"; +import React, { useState } from "react"; +import ControlLoopService from "../../../api/ControlLoopService"; + +const UploadToscaFile = (props) => { + const [windowLocationPathName, setWindowLocationPathname] = useState(''); + + const postServiceTemplateHandler = async (event) => { + event.preventDefault(); + console.log('postServiceTemplateHandler called'); + setWindowLocationPathname(window.location.pathname); + + const response = await ControlLoopService.uploadToscaFile(props.toscaObject, windowLocationPathName) + .catch(error => error.message); + + // const responseMessage = await response.text(); + + props.onResponseReceived(response); + + } + + return ( + <React.Fragment> + <Button variant="primary" + block={ true } + type="submit" + onClick={ postServiceTemplateHandler }> + Upload Tosca Service Template + </Button> + </React.Fragment> + ); + +}; + +export default UploadToscaFile; diff --git a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/UploadToscaFile.test.js b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/UploadToscaFile.test.js new file mode 100644 index 0000000..94d9038 --- /dev/null +++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/UploadToscaFile.test.js @@ -0,0 +1,61 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +import React from 'react'; +import { mount, shallow } from 'enzyme'; +import UploadToscaFile from './UploadToscaFile'; +import toJson from "enzyme-to-json"; +import { act } from "react-dom/test-utils"; + +describe('Verify UploadToscaFile', () => { + + it("renders without crashing", () => { + shallow(<UploadToscaFile/>); + }); + + it("renders correctly", () => { + const tree = shallow(<UploadToscaFile/>); + expect(toJson(tree)).toMatchSnapshot(); + }); + + it('should have a Button element', () => { + const container = shallow(<UploadToscaFile/>) + expect(container.find('Button').length).toEqual(1); + }); + + it('button should call postServiceTemplateHandler when clicked', async () => { + const component = mount(<UploadToscaFile/>) + const logSpy = jest.spyOn(console, 'log'); + const event = { + preventDefault() { + } + }; + + act(async () => { + component.find('[variant="primary"]').get(0).props.onClick(event); + expect(logSpy).toHaveBeenCalledWith('postServiceTemplateHandler called'); + }) + + }); + + it('should have a Button element with specified text', () => { + const container = shallow(<UploadToscaFile/>) + expect(container.find('Button').text()).toBe('Upload Tosca Service Template'); + }); +}); diff --git a/gui-clamp/ui-react/src/components/dialogs/__snapshots__/GetLocalToscaFileForUpload.test.js.snap b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/__snapshots__/GetLocalToscaFileForUpload.test.js.snap index 84168fd..84168fd 100644 --- a/gui-clamp/ui-react/src/components/dialogs/__snapshots__/GetLocalToscaFileForUpload.test.js.snap +++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/__snapshots__/GetLocalToscaFileForUpload.test.js.snap diff --git a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/__snapshots__/GetToscaTemplate.test.js.snap b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/__snapshots__/GetToscaTemplate.test.js.snap new file mode 100644 index 0000000..2c591d9 --- /dev/null +++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/__snapshots__/GetToscaTemplate.test.js.snap @@ -0,0 +1,15 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Verify GetToscaTemplate renders correctly 1`] = ` +<Fragment> + <Button + active={false} + disabled={false} + onClick={[Function]} + type="submit" + variant="primary" + > + Get Tosca Service Template + </Button> +</Fragment> +`; diff --git a/gui-clamp/ui-react/src/components/dialogs/__snapshots__/ReadAndConvertYaml.test.js.snap b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/__snapshots__/ReadAndConvertYaml.test.js.snap index cbead03..fab7801 100644 --- a/gui-clamp/ui-react/src/components/dialogs/__snapshots__/ReadAndConvertYaml.test.js.snap +++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/__snapshots__/ReadAndConvertYaml.test.js.snap @@ -22,7 +22,14 @@ exports[`Verify ReadAndConvertYaml renders correctly 1`] = ` templateName="ToscaServiceTemplateSimple" templateVersion="1.0.0" /> - <styled.pre /> + <styled.pre> + + + </styled.pre> + <Styled(Alert) + show={false} + variant="danger" + /> </ModalBody> <ModalFooter> <Button diff --git a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/__snapshots__/UploadToscaFile.test.js.snap b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/__snapshots__/UploadToscaFile.test.js.snap new file mode 100644 index 0000000..a1ae439 --- /dev/null +++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/__snapshots__/UploadToscaFile.test.js.snap @@ -0,0 +1,16 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Verify UploadToscaFile renders correctly 1`] = ` +<Fragment> + <Button + active={false} + block={true} + disabled={false} + onClick={[Function]} + type="submit" + variant="primary" + > + Upload Tosca Service Template + </Button> +</Fragment> +`; diff --git a/gui-clamp/ui-react/src/components/dialogs/ReadAndConvertYaml.js b/gui-clamp/ui-react/src/components/dialogs/ReadAndConvertYaml.js deleted file mode 100644 index 3a02588..0000000 --- a/gui-clamp/ui-react/src/components/dialogs/ReadAndConvertYaml.js +++ /dev/null @@ -1,87 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ -import React, { useState } from "react"; -import GetToscaTemplate from "../../api/GetToscaTemplate"; -import Modal from "react-bootstrap/Modal"; -import Button from "react-bootstrap/Button"; - -import styled from 'styled-components'; - -const ModalStyled = styled(Modal)` - background-color: transparent; -` - -const ErrMsgStyled = styled.div` - color: red; -` - -const PreStyled = styled.pre` - color: #7F0055; - overflow: auto; - max-height: 70vh; -` - -const ReadAndConvertYaml = (props) => { - const [show, setShow] = useState(true); - const [toscaTemplateData, setToscaTemplateData] = useState(); - const name = 'ToscaServiceTemplateSimple'; - const version = '1.0.0'; - - const handleClose = () => { - console.log('handleClose called'); - setShow(false); - props.history.push('/'); - } - - const getToscaServiceTemplateHandler = async (toscaServiceTemplate) => { - console.log('getToscaServiceTemplateHandler called'); - const toscaData = { - ...toscaServiceTemplate, - id: Math.random().toString() - }; - // console.log(toscaData); - setToscaTemplateData(toscaData); - } - - return ( - <ModalStyled size="xl" - show={ show } - onHide={ handleClose } - backdrop="static" - keyboard={ false }> - <Modal.Header closeButton> - <Modal.Title>View Tosca Template</Modal.Title> - </Modal.Header> - <Modal.Body> - <GetToscaTemplate templateName={ name } - templateVersion={ version } - onGetToscaServiceTemplate={ getToscaServiceTemplateHandler }/> - <PreStyled>{ JSON.stringify(toscaTemplateData, null, 2) }</PreStyled> - </Modal.Body> - <Modal.Footer> - <Button variant="secondary" - type="null" - onClick={ handleClose }>Cancel</Button> - </Modal.Footer> - </ModalStyled> - ); -} - -export default ReadAndConvertYaml; diff --git a/gui-clamp/ui-react/src/components/menu/MenuBar.js b/gui-clamp/ui-react/src/components/menu/MenuBar.js index d7784ef..4574a2a 100644 --- a/gui-clamp/ui-react/src/components/menu/MenuBar.js +++ b/gui-clamp/ui-react/src/components/menu/MenuBar.js @@ -87,10 +87,6 @@ export default class MenuBar extends React.Component { render() { return ( <Navbar.Collapse> - <StyledNavDropdown title="Tosca"> - <NavDropdown.Item as={ StyledLink } to="/readToscaTemplate">View Tosca Template</NavDropdown.Item> - <NavDropdown.Item as={ StyledLink } to="/uploadToscaFile">Upload Tosca to Commissioning</NavDropdown.Item> - </StyledNavDropdown> <StyledNavDropdown title="POLICY Framework"> <NavDropdown.Item as={ StyledLink } to="/viewAllPolicies">View All Policies</NavDropdown.Item> </StyledNavDropdown> @@ -119,6 +115,10 @@ export default class MenuBar extends React.Component { </StyledNavDropdown> <StyledNavDropdown title="TOSCA Control Loop"> <NavDropdown.Item as={ StyledLink } to="/monitoring">Monitoring Control Loop</NavDropdown.Item> + <NavDropdown.Divider /> + <NavDropdown.Header>Commissioning</NavDropdown.Header> + <NavDropdown.Item as={ StyledLink } to="/readToscaTemplate">View Tosca Template</NavDropdown.Item> + <NavDropdown.Item as={ StyledLink } to="/uploadToscaFile">Upload Tosca to Commissioning</NavDropdown.Item> </StyledNavDropdown> <StyledNavDropdown title="Help"> <StyledNavLink href="https://wiki.onap.org/" target="_blank">Wiki</StyledNavLink> diff --git a/gui-clamp/ui-react/src/components/menu/__snapshots__/MenuBar.test.js.snap b/gui-clamp/ui-react/src/components/menu/__snapshots__/MenuBar.test.js.snap index 416d62e..8bdfb09 100644 --- a/gui-clamp/ui-react/src/components/menu/__snapshots__/MenuBar.test.js.snap +++ b/gui-clamp/ui-react/src/components/menu/__snapshots__/MenuBar.test.js.snap @@ -3,7 +3,7 @@ exports[`Verify MenuBar Test the render method 1`] = ` <NavbarCollapse> <Styled(NavDropdown) - title="Tosca" + title="POLICY Framework" > <DropdownItem as={ @@ -66,10 +66,14 @@ exports[`Verify MenuBar Test the render method 1`] = ` } } disabled={false} - to="/readToscaTemplate" + to="/viewAllPolicies" > - View Tosca Template + View All Policies </DropdownItem> + </Styled(NavDropdown)> + <Styled(NavDropdown) + title="CLAMP Options" + > <DropdownItem as={ Object { @@ -131,14 +135,13 @@ exports[`Verify MenuBar Test the render method 1`] = ` } } disabled={false} - to="/uploadToscaFile" + to="/manageDictionaries" > - Upload Tosca to Commissioning + Tosca Metadata Dictionaries </DropdownItem> - </Styled(NavDropdown)> - <Styled(NavDropdown) - title="POLICY Framework" - > + <DropdownDivider + role="separator" + /> <DropdownItem as={ Object { @@ -200,13 +203,13 @@ exports[`Verify MenuBar Test the render method 1`] = ` } } disabled={false} - to="/viewAllPolicies" + to="/viewLoopTemplatesModal" > - View All Policies + View All Loop Templates </DropdownItem> </Styled(NavDropdown)> <Styled(NavDropdown) - title="CLAMP Options" + title="LOOP Instance" > <DropdownItem as={ @@ -269,13 +272,10 @@ exports[`Verify MenuBar Test the render method 1`] = ` } } disabled={false} - to="/manageDictionaries" + to="/createLoop" > - Tosca Metadata Dictionaries + Create </DropdownItem> - <DropdownDivider - role="separator" - /> <DropdownItem as={ Object { @@ -337,14 +337,10 @@ exports[`Verify MenuBar Test the render method 1`] = ` } } disabled={false} - to="/viewLoopTemplatesModal" + to="/openLoop" > - View All Loop Templates + Open </DropdownItem> - </Styled(NavDropdown)> - <Styled(NavDropdown) - title="LOOP Instance" - > <DropdownItem as={ Object { @@ -405,10 +401,10 @@ exports[`Verify MenuBar Test the render method 1`] = ` "withComponent": [Function], } } - disabled={false} - to="/createLoop" + disabled={true} + to="/closeLoop" > - Create + Close </DropdownItem> <DropdownItem as={ @@ -470,11 +466,14 @@ exports[`Verify MenuBar Test the render method 1`] = ` "withComponent": [Function], } } - disabled={false} - to="/openLoop" + disabled={true} + to="/modifyLoop" > - Open + Modify </DropdownItem> + <DropdownDivider + role="separator" + /> <DropdownItem as={ Object { @@ -536,9 +535,9 @@ exports[`Verify MenuBar Test the render method 1`] = ` } } disabled={true} - to="/closeLoop" + to="/loopProperties" > - Close + Properties </DropdownItem> <DropdownItem as={ @@ -601,13 +600,14 @@ exports[`Verify MenuBar Test the render method 1`] = ` } } disabled={true} - to="/modifyLoop" + to="/refreshStatus" > - Modify + Refresh Status </DropdownItem> - <DropdownDivider - role="separator" - /> + </Styled(NavDropdown)> + <Styled(NavDropdown) + title="LOOP Operations" + > <DropdownItem as={ Object { @@ -669,9 +669,9 @@ exports[`Verify MenuBar Test the render method 1`] = ` } } disabled={true} - to="/loopProperties" + to="/submit" > - Properties + Create and deploy to Policy Framework (SUBMIT) </DropdownItem> <DropdownItem as={ @@ -734,14 +734,10 @@ exports[`Verify MenuBar Test the render method 1`] = ` } } disabled={true} - to="/refreshStatus" + to="/stop" > - Refresh Status + Undeploy from Policy Framework (STOP) </DropdownItem> - </Styled(NavDropdown)> - <Styled(NavDropdown) - title="LOOP Operations" - > <DropdownItem as={ Object { @@ -803,9 +799,9 @@ exports[`Verify MenuBar Test the render method 1`] = ` } } disabled={true} - to="/submit" + to="/restart" > - Create and deploy to Policy Framework (SUBMIT) + ReDeploy to Policy Framework (RESTART) </DropdownItem> <DropdownItem as={ @@ -868,10 +864,13 @@ exports[`Verify MenuBar Test the render method 1`] = ` } } disabled={true} - to="/stop" + to="/delete" > - Undeploy from Policy Framework (STOP) + Delete loop instance (DELETE) </DropdownItem> + <DropdownDivider + role="separator" + /> <DropdownItem as={ Object { @@ -933,9 +932,9 @@ exports[`Verify MenuBar Test the render method 1`] = ` } } disabled={true} - to="/restart" + to="/deploy" > - ReDeploy to Policy Framework (RESTART) + Deploy to DCAE (DEPLOY) </DropdownItem> <DropdownItem as={ @@ -998,13 +997,14 @@ exports[`Verify MenuBar Test the render method 1`] = ` } } disabled={true} - to="/delete" + to="/undeploy" > - Delete loop instance (DELETE) + UnDeploy to DCAE (UNDEPLOY) </DropdownItem> - <DropdownDivider - role="separator" - /> + </Styled(NavDropdown)> + <Styled(NavDropdown) + title="TOSCA Control Loop" + > <DropdownItem as={ Object { @@ -1065,11 +1065,19 @@ exports[`Verify MenuBar Test the render method 1`] = ` "withComponent": [Function], } } - disabled={true} - to="/deploy" + disabled={false} + to="/monitoring" > - Deploy to DCAE (DEPLOY) + Monitoring Control Loop </DropdownItem> + <DropdownDivider + role="separator" + /> + <DropdownHeader + role="heading" + > + Commissioning + </DropdownHeader> <DropdownItem as={ Object { @@ -1130,15 +1138,11 @@ exports[`Verify MenuBar Test the render method 1`] = ` "withComponent": [Function], } } - disabled={true} - to="/undeploy" + disabled={false} + to="/readToscaTemplate" > - UnDeploy to DCAE (UNDEPLOY) + View Tosca Template </DropdownItem> - </Styled(NavDropdown)> - <Styled(NavDropdown) - title="TOSCA Control Loop" - > <DropdownItem as={ Object { @@ -1200,9 +1204,9 @@ exports[`Verify MenuBar Test the render method 1`] = ` } } disabled={false} - to="/monitoring" + to="/uploadToscaFile" > - Monitoring Control Loop + Upload Tosca to Commissioning </DropdownItem> </Styled(NavDropdown)> <Styled(NavDropdown) |