Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Job and Bridge Creation Pages #483

Closed

Conversation

NavyAdmiral
Copy link
Contributor

No description provided.

@NavyAdmiral NavyAdmiral force-pushed the Job-And-Bridge-Pages branch 4 times, most recently from c2c1957 to d6cd1dc Compare August 8, 2018 10:25
@rupurt
Copy link
Contributor

rupurt commented Aug 8, 2018

@NavyAdmiral I'm not exactly sure why that error is happening but doesn't occur when I remove the <BridgeForm /> component.

@NavyAdmiral NavyAdmiral force-pushed the Job-And-Bridge-Pages branch 6 times, most recently from 0076650 to 2c39d17 Compare August 10, 2018 19:13
@NavyAdmiral
Copy link
Contributor Author

NavyAdmiral commented Aug 10, 2018

@rupurt There was a bug with Enzyme and this has been reported both in Formik and Enzyme repos. issue
Enzyme 3.4.0 fixes it ✅

Copy link
Contributor

@rupurt rupurt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NavyAdmiral nice job on tracking down the Enzyme bug. I've investigated them before and it's quite frustrating.

</Grid>
<Grid item xs={3}>
{renderSidebar(this.props)}
<Grid item>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this should only have a Create Job button on this page. How do you feel about moving the Create Bridge button to the bridges index page?

Also, how do you feel about aligning the button to the right of the grid?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right of the grid? If I understand you correctly, I didn't like aligning it that way because Drawer slid over it when opened.

</Grid>
<Grid item>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs the xs attribute with a column size.

gui/src/api.js Outdated
@@ -73,4 +74,6 @@ export const getBridgeSpec = (name) => get(`/v2/bridge_types/${name}`)

export const createSession = (data) => post(`/sessions`, data)

export const createObject = (endpoint, data, shouldStringify) => post(`/${endpoint}`, data, shouldStringify)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like by having to pass in the endpoint we are leaking concerns. Actions shouldn't need to know about things like a URL path.

How do you feel about creating wrapper functions called something like createBridgeType & createJobSpec that abstracts this away?

handleSubmit (values, { props }) {
const formattedValues = JSON.parse(JSON.stringify(values).replace('confirmations', 'defaultConfirmations'))
formattedValues.defaultConfirmations = parseInt(formattedValues.defaultConfirmations) || 0
props.submitCreate('v2/bridge_types', formattedValues, true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of passing potentially invalid JSON to the endpoint how do you feel about parsing it in the browser and displaying an error instead?

Copy link
Contributor Author

@NavyAdmiral NavyAdmiral Aug 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rupurt since confirmations is an optional field of type int as demanded by the api, if I don't manually parseInt the input, then it will make a post request with string which will fail. alternatively, the input field can be set as type='number', so that no manual parsing is required, but if it's left untouched (no input from user) then it won't default to 0, it will default to ''

@@ -20,17 +20,23 @@ const styles = (theme) => {
error: {
backgroundColor: theme.palette.error.dark,
color: theme.palette.error.contrastText
},
warning: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should avoid using hex color codes outside of the theme. Can you add these to palette under something like warning?

https://github.com/smartcontractkit/chainlink/blob/master/gui/src/theme.js

}
})
}

const applyClass = ({base, success, error, classes, className}) => {
const applyClass = ({base, success, error, warning, classes, className}) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


export default (state = initialState, action = {}) => {
switch (action.type) {
case MATCH_ROUTE:
Copy link
Contributor

@rupurt rupurt Aug 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this doesn't change any properties, how do you feel about returning initialState directly?

paddingBottom: theme.spacing.unit * 2
},
tabPadding: {
padding: 24
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be relative to the theme's spacing

// Need to set int value because <Tabs/> component
// will not focus on tab with strings
if (this.props.match) {
switch (this.props.match.params.structure) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you feel about using setState with a ternary? Something like:

const value = this.props.match.params.structure === 'job' ? 1 : 0
this.setState({ value: value })

Copy link
Contributor Author

@NavyAdmiral NavyAdmiral Aug 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rupurt That will not work if we add Create Service Agreement in this tab container. Do you want to see it with a ternary in this PR though?

if (this.props.history) {
switch (value) {
case 0:
this.props.history.replace('/create/bridge')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like these should be regular links so that a history entry is pushed onto the stack instead of replacing the entry on the stack. If we go down this route the back button doesn't work.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

am I wrong to think .push should make it work?

@NavyAdmiral NavyAdmiral force-pushed the Job-And-Bridge-Pages branch 7 times, most recently from 368767b to 8eee300 Compare August 15, 2018 08:02
@NavyAdmiral
Copy link
Contributor Author

@rupurt addressed most of the comments; I'm not too happy with create button positionings

@NavyAdmiral
Copy link
Contributor Author

@rupurt addressed most of the comments including the create button positioning. I think I liked both create job/create bridge buttons on the `/ || /jobs`` page more though

@j16r
Copy link
Contributor

j16r commented Aug 15, 2018

Just looking at the form, a couple of thoughts:

  1. When I submitted apparently invalid JSON, the submit button was disabled, but there didn't appear to be a way to enable it again.
  2. The submit button in the form isn't obvious until I move my mouse cursor over it, like the sign in form, the button should have a clear demarcation from its surroundings.
  3. The JSON field should probably be a text area, rather than an input box.
  4. The verbs around fields are unnecessary "e.g: Type Bridge Name", the noun should be sufficient, e.g: "Paste JSON" should be "Job Spec"
  5. Not sure how I feel about combining all the forms into the one GUI with the tabs to select different functions, could be a bit limiting.

@NavyAdmiral
Copy link
Contributor Author

@j16r in what way do you think combining all the forms could be limiting?

@j16r
Copy link
Contributor

j16r commented Aug 15, 2018

It limits the opportunities to take cues from the context in which it is launched, e.g: imagine that the form for creating a job is at the top of the jobs index. Then you can view example jobs and you can see when the job is added live as you add the job. If you can change the "Create Job" form to another form, then this context no longer makes sense.

@NavyAdmiral
Copy link
Contributor Author

Will reopen a new PR as this one got messy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants