-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Add Job and Bridge Creation Pages #483
Conversation
26c2438
to
c4059af
Compare
c2c1957
to
d6cd1dc
Compare
@NavyAdmiral I'm not exactly sure why that error is happening but doesn't occur when I remove the |
0076650
to
2c39d17
Compare
0fba22f
to
37d7199
Compare
There was a problem hiding this 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.
gui/src/containers/Jobs.js
Outdated
</Grid> | ||
<Grid item xs={3}> | ||
{renderSidebar(this.props)} | ||
<Grid item> |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
gui/src/containers/Jobs.js
Outdated
</Grid> | ||
<Grid item> |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
gui/src/components/BridgeForm.js
Outdated
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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: { |
There was a problem hiding this comment.
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}) => { |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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?
gui/src/containers/Create.js
Outdated
paddingBottom: theme.spacing.unit * 2 | ||
}, | ||
tabPadding: { | ||
padding: 24 |
There was a problem hiding this comment.
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
gui/src/containers/Create.js
Outdated
// 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) { |
There was a problem hiding this comment.
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 })
There was a problem hiding this comment.
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?
gui/src/containers/Create.js
Outdated
if (this.props.history) { | ||
switch (value) { | ||
case 0: | ||
this.props.history.replace('/create/bridge') |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
368767b
to
8eee300
Compare
@rupurt addressed most of the comments; I'm not too happy with create button positionings |
8eee300
to
db02a43
Compare
@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 |
2a30464
to
db02a43
Compare
Just looking at the form, a couple of thoughts:
|
@j16r in what way do you think combining all the forms could be limiting? |
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. |
a22387d
to
96393e3
Compare
Will reopen a new PR as this one got messy. |
No description provided.