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

[Frontend] Fix run id not populated in NewRun page when clicked too fast bug #2547

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions frontend/src/pages/PipelineDetails.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,20 @@ describe('PipelineDetails', () => {
);
});

it('clicking new run button when viewing half-loaded page navigates to the new run page with run ID', async () => {
tree = shallow(<PipelineDetails {...generateProps(false)} />);
// Intentionally don't wait until all network requests finish.
const instance = tree.instance() as PipelineDetails;
const newRunFromPipelineBtn = instance.getInitialToolbarState().actions[
ButtonKeys.NEW_RUN_FROM_PIPELINE
];
newRunFromPipelineBtn.action();
expect(historyPushSpy).toHaveBeenCalledTimes(1);
expect(historyPushSpy).toHaveBeenLastCalledWith(
RoutePage.NEW_RUN + `?${QUERY_PARAMS.pipelineId}=${testPipeline.id}`,
);
});

it('clicking new experiment button navigates to new experiment page', async () => {
tree = shallow(<PipelineDetails {...generateProps()} />);
await getTemplateSpy;
Expand Down
9 changes: 8 additions & 1 deletion frontend/src/pages/PipelineDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,14 @@ class PipelineDetails extends Page<{}, PipelineDetailsState> {
public getInitialToolbarState(): ToolbarProps {
const buttons = new Buttons(this.props, this.refresh.bind(this));
const fromRunId = new URLParser(this.props).get(QUERY_PARAMS.fromRunId);
buttons.newRunFromPipeline(() => (this.state.pipeline ? this.state.pipeline.id! : ''));
buttons.newRunFromPipeline(() => {
const pipelineIdFromParams = this.props.match.params[RouteParams.pipelineId];
return this.state.pipeline
? this.state.pipeline.id!
: pipelineIdFromParams
? pipelineIdFromParams
: '';
Copy link
Contributor

Choose a reason for hiding this comment

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

try to learn TS from you.
do it equal to following? not sure whether should use ()
this.state.pipeline
? this.state.pipeline.id!
: (pipelineIdFromParams
? pipelineIdFromParams
: '')

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's equal.

I agree your format looks clearer to me too.
But we are using prettier for auto formatting, it doesn't allow any format change.

Main opinion of prettier

No need to discuss style in code review

https://prettier.io/docs/en/option-philosophy.html

And corresponding issue: prettier/prettier#3805
for context.

});

if (fromRunId) {
return {
Expand Down