From fdd2ad9cbd4261d51bfa03d6eda345a5a54ead66 Mon Sep 17 00:00:00 2001 From: Vijay Kumar Date: Fri, 16 Jul 2021 01:42:17 +0530 Subject: [PATCH 1/4] Added download testcase definition button --- src/views/outbound/OutboundRequest.jsx | 47 ++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/views/outbound/OutboundRequest.jsx b/src/views/outbound/OutboundRequest.jsx index 8511d0b7..bc760bb7 100644 --- a/src/views/outbound/OutboundRequest.jsx +++ b/src/views/outbound/OutboundRequest.jsx @@ -495,6 +495,32 @@ class OutboundRequest extends React.Component { } + handleDownloadDefinition = async (event) => { + switch (event.key) { + case 'printhtml': + case 'html': + default: + message.loading({ content: 'Generating the report...', key: 'downloadReportProgress', duration: 10 }); + const { apiBaseUrl } = getConfig() + const reportFormat = event.key + const response = await axios.post(apiBaseUrl + "/api/reports/testcase_definition/" + reportFormat, this.state.template, { headers: { 'Content-Type': 'application/json' }, responseType: 'blob' }) + let downloadFilename = "test." + reportFormat + if (response.headers['content-disposition']) { + const disposition = response.headers['content-disposition'] + if (disposition && disposition.indexOf('attachment') !== -1) { + var filenameRegex = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/; + var matches = filenameRegex.exec(disposition); + if (matches != null && matches[1]) { + downloadFilename = matches[1].replace(/['"]/g, ''); + } + } + } + FileDownload(response.data, downloadFilename) + message.success({ content: 'Report Generated', key: 'downloadReportProgress', duration: 2 }); + } + + } + handleTestCaseChange = () => { this.autoSave = true this.forceUpdate() @@ -572,6 +598,14 @@ class OutboundRequest extends React.Component { ) } + downloadDefinitionMenu = () => { + return ( + this.handleDownloadDefinition(event)}> + HTML report + + ) + } + handleShowSequenceDiagram = async (testCase) => { await this.setState({ sequenceDiagramVisible: true }) this.seqDiagContainer.removeAttribute('data-processed') @@ -1022,6 +1056,19 @@ class OutboundRequest extends React.Component { : null } + { + this.state.template.test_cases && this.state.template.test_cases.length > 0 + ? + + + + : null + } From 7569dacf93d5bf64d082feac5c68c28af0f776ed Mon Sep 17 00:00:00 2001 From: Vijay Kumar Date: Wed, 21 Jul 2021 00:13:59 +0530 Subject: [PATCH 2/4] Added metadata editor --- src/views/outbound/MetadataEditor.jsx | 156 ++++++++++++++++++++ src/views/outbound/OutboundRequest.jsx | 188 +++++++++++++------------ src/views/outbound/TestCaseEditor.jsx | 7 + 3 files changed, 262 insertions(+), 89 deletions(-) create mode 100644 src/views/outbound/MetadataEditor.jsx diff --git a/src/views/outbound/MetadataEditor.jsx b/src/views/outbound/MetadataEditor.jsx new file mode 100644 index 00000000..53e7d85d --- /dev/null +++ b/src/views/outbound/MetadataEditor.jsx @@ -0,0 +1,156 @@ +/***** + License + -------------- + Copyright © 2017 Bill & Melinda Gates Foundation + The Mojaloop files are made available by the Bill & Melinda Gates Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files 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, the Mojaloop files are 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. + Contributors + -------------- + This is the official list of the Mojaloop project contributors for this file. + Names of the original copyright holders (individuals or organizations) + should be listed with a '*' in the first column. People who have + contributed from an organization can be listed under the organization + that actually holds the copyright for their contributions (see the + Gates Foundation organization for an example). Those individuals should have + their names indented and be marked with a '-'. Email address can be added + optionally within square brackets . + * Gates Foundation + + * ModusBox + * Vijaya Kumar Guthi (Original Author) + -------------- + ******/ + +import React from "react"; +import { Input, Row, Col, Descriptions, message, Popover, Button, Card, Checkbox, Radio, Typography } from 'antd'; +import { EditTwoTone, SaveTwoTone, CloseSquareTwoTone } from '@ant-design/icons'; +import 'antd/dist/antd.css'; + +const {Text, Title} = Typography + +const { TextArea } = Input; + +class MetadataItem extends React.Component { + state = { + editMode: false, + itemValue: null + }; + + componentDidMount = () => { + this.setState({itemValue: this.props.value}) + } + + handleValueChange = () => { + this.props.onChange(this.props.name, this.state.itemValue) + } + + getMetadataItemType = () => { + if(this.state.editMode) { + if (typeof this.props.value === 'boolean') { + return ( + this.setState({itemValue: e.target.check})} + /> + ) + } else if (typeof this.props.value === 'number') { + return ( + this.setState({itemValue: +e.target.value})} + /> + ) + } else { + return ( +