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

Dashboard for ArangoLocalStorage operator #213

Merged
merged 14 commits into from
Jul 10, 2018
Merged

Conversation

ewoutp
Copy link
Contributor

@ewoutp ewoutp commented Jul 9, 2018

This PR adds dashboard functionality to the ArangoLocalStorage operator.

@ewoutp ewoutp self-assigned this Jul 9, 2018
@ghost ghost added the 2 - Working label Jul 9, 2018
@@ -1,13 +1,22 @@
export function IsUnauthorized(e) {
Copy link

Choose a reason for hiding this comment

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

FYI in most JS styles only classes and components use leading uppercase. So this should be isUnauthorized.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed

const podInfoView = (<PodInfoView pod={pod} namespace={namespace}/>);
if (deployment) {
return (<DeploymentOperator podInfoView={podInfoView} error={error}/>);
}
if (storage) {
return (<StorageOperator podInfoView={podInfoView} error={error}/>);
}
Copy link

Choose a reason for hiding this comment

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

If you want to avoid repeating yourself a bit, you could do something like this:

let Operator = NoOperator;
if (deployment) Operator = DeploymentOperator;
else if (storage) Operator = StorageOperator;
return (
  <Operator
    podInfoView={
      <PodInfoView pod={pod} namespace={namespace} />
    }
    error={error}
  />
);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed

}
return (<LoadingView/>);
}
}

export default ReactTimeout(App);
export default ReactTimeout(withAuth(App));
Copy link

Choose a reason for hiding this comment

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

FYI this is why HOCs have been losing some traction to render props recently: you're now injecting props from two places. This is probably fine for the time being but it can get a bit confusing as the complexity grows.

{this.props.podInfoView}
{(this.props.error) ? <Message error content={this.props.error}/> : null}
</div>
<Container>
Copy link

Choose a reason for hiding this comment

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

This NoOperator component is exactly what I meant when I talked about presentational components btw. It doesn't have any state and it only contains display logic (i.e. "if there's an error message, put it here"). If you want to make it easier to swap out the styling later, you should try to extract all the actual presentation stuff into components like this one.

Minor nitpick: no point in using a class component here, you could just make it a function.

@@ -12,6 +13,7 @@ const LoginView = ({username, password, onUsernameChanged, onPasswordChanged, do
<label>Password</label>
<input type="password" value={password} onChange={(e) => onPasswordChanged(e.target.value)}/>
</Form.Field>
<Form.Button className={css`display:none`} type="submit" />
Copy link

Choose a reason for hiding this comment

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

Any particular reason you have a hidden submit button here? Pressing enter in the input field should already trigger the form submit.

Copy link

Choose a reason for hiding this comment

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

Also curious why you're using css here but styled elsewhere as most uses of styled can also be replaced with css (and generally vice versa unless you want to apply the same class to different components, in which case you'll always need css).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hidden button was out of need. I expected it to work without, but it did not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like styled better, but that did not work in combination with Form.Button.

return (<ListView items={items} loading={this.state.loading} />);
}
}

Copy link

Choose a reason for hiding this comment

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

This file is getting rather large. I'd split it out to a folder. I generally aim to have one component per folder but YMMV.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

once all the basic are in, I'll go over all of it for issues like this.

@ewoutp ewoutp merged commit f124554 into master Jul 10, 2018
@ghost ghost removed the 4 - Review label Jul 10, 2018
@ewoutp ewoutp deleted the feature/dashboard-storage branch July 10, 2018 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants