Skip to content

Commit

Permalink
Fix URL handling on first load of PipelineRun or TaskRun
Browse files Browse the repository at this point in the history
Avoid invalid / unexpected interim state when navigating back using
browser history by ensure we call `history.replace` instead of
`history.push` when we automatically update the URL to include the
selected task and/or step when rendering the PipelineRun or TaskRun
resource.

If the URL query params already specify a selected task and/or step
then push the new history entry into the stack as normal.
  • Loading branch information
AlanGreene authored and tekton-robot committed Sep 12, 2022
1 parent 43047aa commit 748b788
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/containers/PipelineRun/PipelineRun.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,12 @@ export /* istanbul ignore next */ function PipelineRunContainer({ intl }) {
}

const browserURL = location.pathname.concat(`?${queryParams.toString()}`);
history.push(browserURL);
if (currentPipelineTaskName) {
history.push(browserURL);
} else {
// auto-selecting task & step on first load
history.replace(browserURL);
}
}

function cancel() {
Expand Down
7 changes: 6 additions & 1 deletion src/containers/TaskRun/TaskRun.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,12 @@ export function TaskRunContainer({ intl }) {
}

const browserURL = location.pathname.concat(`?${queryParams.toString()}`);
history.push(browserURL);
if (showTaskRunDetails || selectedStepId) {
history.push(browserURL);
} else {
// auto-selecting step on first load
history.replace(browserURL);
}
}

function cancel() {
Expand Down

0 comments on commit 748b788

Please sign in to comment.