Skip to content

Commit

Permalink
adds dummy verification for hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
josemigallas committed Aug 6, 2018
1 parent 10601cd commit 35189f5
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 4 deletions.
7 changes: 7 additions & 0 deletions ui/components/resolvers/HookFormGroup.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.verifyButton {
width: 10rem;
}

.verifyButtonLabel {
margin-right: 5px;
}
47 changes: 43 additions & 4 deletions ui/components/resolvers/HookFormGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,55 @@ import {
Col,
FormControl,
InputGroup,
Button
Button,
Icon
} from "patternfly-react";

import { verifyButton, verifyButtonLabel } from "./HookFormGroup.css";

const INITIAL_STATE = {
verifyingUrl: false,
verificationResult: null
};

class HookFormGroup extends Component {

constructor(props) {
super(props);
this.state = INITIAL_STATE;
}

testHook() {
// TODO: implement verification with server
const { url = "" } = this.props;
console.log(`Test url: ${url}`);
console.log("Verifying url...", url);

this.setState({ verifyingUrl: true, verificationResult: null });

setTimeout(() => this.setState({ verifyingUrl: false, verificationResult: "error" }), 1000);
}

renderVerificationIcon() {
const { verifyingUrl, verificationResult } = this.state;

if (verifyingUrl) {
return <Icon name="spinner" spin />;
}

if (verificationResult === "success") {
return <Icon type="pf" name="ok" />;
}

if (verificationResult === "error") {
return <Icon type="pf" name="error-circle-o" />;
}

return null;
}

render() {
const { url = "", label, onChange } = this.props;
const { verifyingUrl } = this.state;

return (
<React.Fragment>
Expand All @@ -27,15 +64,17 @@ class HookFormGroup extends Component {
onChange={ev => onChange(ev.currentTarget.value)}
/>
<InputGroup.Button>
<Button onClick={() => this.testHook()}>
Verify URL
<Button onClick={() => this.testHook()} className={verifyButton}>
<span className={verifyButtonLabel}>{verifyingUrl ? "Verifying..." : "Verify URL"}</span>
{this.renderVerificationIcon()}
</Button>
</InputGroup.Button>
</InputGroup>
</Col>
</React.Fragment>
);
}

}

export { HookFormGroup };

0 comments on commit 35189f5

Please sign in to comment.