Skip to content

Permalink request within group - #1748

Merged
benheng merged 3 commits into
masterfrom
permalink-request-within-group
Mar 2, 2018
Merged

benheng merged 3 commits into
masterfrom
permalink-request-within-group

Conversation

@benheng

@benheng benheng commented Feb 28, 2018

Copy link
Copy Markdown
Contributor

Previously, request groups didn't support permalinks for requests within the group. It would simply select the first request and display that.

You'd have link that looked like this:

localhost/singularity/ui/group/RequestGroup1

Which would contain some requests: RequestGroup1-foo1, RequestGroup1-foo2, RequestGroup1-foo3

Now you can link them directly:

localhost/singularity/ui/group/RequestGroup1/RequestGroup1-foo1
localhost/singularity/ui/group/RequestGroup1/RequestGroup1-foo2
localhost/singularity/ui/group/RequestGroup1/RequestGroup1-foo3

The default behavior is maintained, no request ID means display the first request. Incorrect request ID will still load the selected group page, but the request data will not be displayed since there is none.

@@ -1,5 +1,6 @@
import React, {PropTypes, Component} from 'react';
import { connect } from 'react-redux';
import { LinkContainer } from 'react-router-bootstrap';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What's the reasoning behind using LinkContainer over the standard react-router Link or an onclick handler?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Link doesn't play nice with bootstrap components. I also wanted the URL to change when a user clicked on a request ID which is why I went with LinkContainer. Would it have been better to have an onClick handler and wrap the component using withRouter?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If we were already using react-router-bootstrap I'd say this is the best solution, however, I'm hesitant to add another dependency for this single use case since we already have so many. For that reason I'd say go with handling it via onClick and withRouter.

</NavItem>
<LinkContainer
eventKey={requestId}
key={index}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

requestId is a logical key here

super(props);
this.state = {
showRequestId: _.first(props.group.requestIds)
showRequestId: props.params.requestId || _.first(props.group.requestIds),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

component state isn't needed anymore, and you can get rid of onSelect={this.handleRequestSelect} on the Nav component

@ssalinas ssalinas added the UI label Mar 1, 2018
@kwm4385

kwm4385 commented Mar 2, 2018

Copy link
Copy Markdown
Contributor

🚢

@benheng
benheng merged commit a2eca5a into master Mar 2, 2018
@benheng
benheng deleted the permalink-request-within-group branch March 2, 2018 20:06
@ssalinas ssalinas added this to the 0.19.2 milestone Mar 26, 2018
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.

4 participants