Skip to content

Commit

Permalink
feat(ux): Disabled Execute button while request is in progress (#6776)
Browse files Browse the repository at this point in the history
Avoid sending multiple request while old is in progress

Co-authored-by: Tim Lai <timothy.lai@gmail.com>
  • Loading branch information
mathis-m and tim-lai committed Jan 7, 2021
1 parent 0f541a1 commit 2bf39e0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/core/components/execute.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ export default class Execute extends Component {
method: PropTypes.string.isRequired,
oas3Selectors: PropTypes.object.isRequired,
oas3Actions: PropTypes.object.isRequired,
onExecute: PropTypes.func
onExecute: PropTypes.func,
disabled: PropTypes.bool
}

handleValidateParameters = () => {
Expand All @@ -24,7 +25,7 @@ export default class Execute extends Component {
let { path, method, specSelectors, oas3Selectors, oas3Actions } = this.props
let validationErrors = {
missingBodyValue: false,
missingRequiredKeys: []
missingRequiredKeys: []
}
// context: reset errors, then (re)validate
oas3Actions.clearRequestBodyValidateError({ path, method })
Expand Down Expand Up @@ -92,8 +93,9 @@ export default class Execute extends Component {
onChangeProducesWrapper = ( val ) => this.props.specActions.changeProducesValue([this.props.path, this.props.method], val)

render(){
const { disabled } = this.props
return (
<button className="btn execute opblock-control__btn" onClick={ this.onClick }>
<button className="btn execute opblock-control__btn" onClick={ this.onClick } disabled={disabled}>
Execute
</button>
)
Expand Down
3 changes: 2 additions & 1 deletion src/core/components/operation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ export default class Operation extends PureComponent {
oas3Actions={ oas3Actions }
path={ path }
method={ method }
onExecute={ onExecute } />
onExecute={ onExecute }
disabled={executeInProgress}/>
}

{ (!tryItOutEnabled || !response || !allowTryItOut) ? null :
Expand Down

0 comments on commit 2bf39e0

Please sign in to comment.