Bug 1609211 - Persist settings in URL#6656
Conversation
Codecov Report
@@ Coverage Diff @@
## master #6656 +/- ##
=======================================
Coverage 88.32% 88.32%
=======================================
Files 280 280
Lines 12776 12776
=======================================
Hits 11284 11284
Misses 1492 1492 Continue to review full report at Codecov.
|
|
@sarah-clements @camd Could you give your initial reviews if this is the expected way |
| regressionsGroupBy: 'path', | ||
| knownIssuesOrderBy: 'count', | ||
| knownIssuesGroupBy: 'path', | ||
| setRegressionsOrderBy: () => {}, |
There was a problem hiding this comment.
This should be a required prop.
| const queryString = createQueryParams(newParams); | ||
| updateQueryParams(queryString, history, location); | ||
| this.setState({ knownIssuesGroupBy }); | ||
| }; |
There was a problem hiding this comment.
You're on the right track here, but since all of this logic is the same you should create one generic function that accepts an argument for the state that should be updated (there is a way to do this without entering a specific state name/key). I suggest naming the generic function something like updateParamsAndState.
There was a problem hiding this comment.
I was facing the problem of updating the state variable from a generic function
I mean, how do I come to know which state variable regressionsGroupBy or knownIssuesOrderBy is to be changed
Other things will be surely much better to handle in a generic function
There was a problem hiding this comment.
There is a way to solve this problem, you just need to research it :)
There was a problem hiding this comment.
It is better to find a DRY solution - here you are repeating the same code multiple times. So there are a few different approaches you can take that would be better.
There was a problem hiding this comment.
I am unable to find a good solution to it.
The only way I find is to pass a string parameter from the classification group component to see which state variable has to be changed. Does this method work?Or a still better solution is needed
There was a problem hiding this comment.
An easy solution is to pass an object parameter instead of a variable: this.setState(stateObj). Another one would be to call setState inline in the onClick and update the query parameters as a callback function.
There was a problem hiding this comment.
You could pass in a string, but then you'd need a value unless you were doing a boolean toogle, so: (stateName, value) => this.setState({ [stateName]: value }). This is possible by using computed property names.
I would look at what the minimum amount of data that is needed in order to call the push health API for the failure summary for a selected task. You'll also need a query string/param that will tell the task component to be open instead of collapsed. |
cadb2f3 to
7a60b86
Compare
|
@camd I have facing a problem in persist the exact task inside the exact group
The things seem to be working fine except that many tests are expanded |
One way to do this would be to add the That way you could just use the When we move to using |
|
@camd Please review this too . |
camd
left a comment
There was a problem hiding this comment.
This seems to be working well. A bit more refinement is needed. But a great start!
| if (selectedTask === task || !task) { | ||
| this.setState({ selectedTask: null, detailsShowing: false }); | ||
| } else { | ||
| this.props.updateParamsAndState({ expandedDefaultMetric: task.id }); |
There was a problem hiding this comment.
A metric is different than a task. I think this state name should be selectedTask. Or you could use selectedTaskId for the querystring param name.
metricwould be either tests, builds or linting. And we should persist that, too.
The url params are seeming a bit verbose to me. I'm wondering about something closer to this:
selectedTask = task.id
test= test.id (rather than the full test text)
testgroup = one of pr(possible regressions), ki (known issues)
metric = one of tests, linting, or builds
It also seems worthwhile to add these settings to the URL as you expand each one. You may not want to necessarily share just a selected task, but an expanded list of tests in one area.
Those names might seem a bit generic for being part of state. Perhaps selectedTest, selectedTestGroup, etc would be fine.
There was a problem hiding this comment.
metricwould be either tests, builds or linting. And we should persist that, too.
I think we can have that without persisting it on the URL. If any of the params, that have been added in this PR is present, tests should be shown by default. The cost of this would be checking max 7 conditions on the React code
test= test.id (rather than the full test text)
The tests are actually grouped by path or platform. So under any tests object in the frontend(which can be expanded or collapse), there are several tests from different failure lines.

This is the screenshot of the props in the Test Component. the test object may have more than one tests from different failure lines, hence different failure.id. This was my understanding from the code. Please rectify me if I am wrong or we have to store the id which has the whole test name in the URL
There was a problem hiding this comment.
This is the screenshot of the props in the Test Component. the
testobject may have more than one tests from different failure lines, hence differentfailure.id. This was my understanding from the code. Please rectify me if I am wrong or we have to store the id which has the whole test name in the URL
Ahh yes. I see what you mean. That ID won't be consistent, especially if some of the back-end data changes and a task is moved to "known issues" because retriggers come back with more passing than failing.
OK, let's go with the text, then. I'll test this locally a bit today and see if I can find any issues. But this is looking good. :)
29ab083 to
5597a08
Compare
|
@camd I just wanted to confirm if we are adding test group to the URL or the current way is fine |
|
It opens ALL of the tasks on that platform. So I think it needs to also persist the |
It looks like you have added |
5597a08 to
4324065
Compare
|
camd
left a comment
There was a problem hiding this comment.
I think this is almost there. Just a few small nit-picky changes here and there. :)
Thanks!!!
| const newParams = { | ||
| ...parseQueryParams(location.search), | ||
| }; | ||
| Object.assign(newParams, stateObj); |
There was a problem hiding this comment.
Instead of Object.assign, let's use spreading, like you did for newParams. So just add ...stateObj to the creation of newParams in the spread on line 105.
| jobs, | ||
| failure: { jobName, testName }, | ||
| } = this.props; | ||
| if (selectedJobName === `${testName} ${jobName}`) { |
There was a problem hiding this comment.
I think this section could be condensed into:
this.setState({
detailsShowing: selectedJobName === `${testName} ${jobName}`,
selectedTask: selectedTaskId ? jobs[jobName].filter(
(job) => job.id === parseInt(selectedTaskId, 10),
).length > 0 : null,
});
Would you give that a shot and see if it works ok?
There was a problem hiding this comment.
also, please add a blank line before this.setState
4324065 to
18ed3a3
Compare
camd
left a comment
There was a problem hiding this comment.
This is working great! I've been doing some testing with it, and it's a really nice addition. Thank you!!

Fixes #6226