Skip to content

Commit

Permalink
Added download testcase definition button (#108)
Browse files Browse the repository at this point in the history
* Added download testcase definition button

* Added metadata editor

* Added editable metadata for all test cases and requests in test runner

* Bumped up the version and postponed audits
  • Loading branch information
vijayg10 committed Jul 21, 2021
1 parent 3c79824 commit 5b4fefa
Show file tree
Hide file tree
Showing 7 changed files with 353 additions and 114 deletions.
2 changes: 1 addition & 1 deletion audit-resolve.json
Original file line number Diff line number Diff line change
Expand Up @@ -30114,7 +30114,7 @@
},
"1763|socket.io-client>socket.io-parser": {
"decision": "postpone",
"madeAt": 1626796239617
"madeAt": 1626884473999
}
},
"rules": {},
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ml-testing-toolkit-ui",
"version": "13.1.1",
"version": "13.2.0",
"description": "Mojaloop Testing Toolkit Web User Interface",
"main": "index.js",
"repository": {
Expand Down
156 changes: 156 additions & 0 deletions src/views/outbound/MetadataEditor.jsx
Original file line number Diff line number Diff line change
@@ -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 <email>.
* Gates Foundation
* ModusBox
* Vijaya Kumar Guthi <vijaya.guthi@modusbox.com> (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 (
<Checkbox
checked={this.state.itemValue}
onChange={(e) => this.setState({itemValue: e.target.check})}
/>
)
} else if (typeof this.props.value === 'number') {
return (
<Input
value={this.state.itemValue}
onChange={(e) => this.setState({itemValue: +e.target.value})}
/>
)
} else {
return (
<TextArea
rows={5}
value={this.state.itemValue}
onChange={(e) => this.setState({itemValue: e.target.value})}
/>
)
}
} else {
return (
<Text type='secondary'>{this.props.value}</Text>
)
}
}

render() {
return (
<>
<Row>
<Col span={24}>
<Text className='mr-2' strong>{this.props.name}</Text>
{
this.state.editMode
? (
<>
<SaveTwoTone
style={{ fontSize: '20px' }}
onClick={() => {
this.setState({editMode: false})
this.handleValueChange()
}}
/>
<CloseSquareTwoTone
style={{ fontSize: '20px' }}
className='mr-1'
onClick={() => {
this.setState({editMode: false})
}}
/>
</>
)
: (
<EditTwoTone
style={{ fontSize: '20px' }}
onClick={() => {
this.setState({editMode: true, itemValue: this.props.value})
}}
/>
)
}

</Col>
</Row>
<Row className='mt-2 mb-2'>
<Col span={24}>
{this.getMetadataItemType()}
</Col>
</Row>
</>
)
}

}

class MetadataEditor extends React.Component {

handleItemValueChange = (name, newValue) => {
this.props.values[name] = newValue
this.props.onChange()
}

getMetadataItems = () => {
let inputItems = []
let i = 0
for (let inputValueName in this.props.values) {
inputItems.push(
<MetadataItem name={inputValueName} value={this.props.values[inputValueName]} onChange={this.handleItemValueChange} />
)
}
return inputItems
}

render() {
return (
<>
{this.getMetadataItems()}
</>
)
}
}

export default MetadataEditor;
Loading

0 comments on commit 5b4fefa

Please sign in to comment.