-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
feat(ui): prefill parameters for workflow submit form. Fixes #12124 #13766
Conversation
isShown={!!getSidePanel()} | ||
onClose={() => { | ||
// Remove any lingering query params | ||
const qParams: {[key: string]: string | null} = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is duplicate can be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you explain why this is necessary? The navigation.goto()
function already has logic to automatically strip out the query parameters if there's been a path change: https://github.com/argoproj/argo-ui/blob/54f36c723d9a0e5d3386689298cbb9c27767fa00/src/components/navigation.ts#L20-L21
If there hasn't been a path change, I think it's fine to leave these query parameters in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the workflow this would fix is
- Open the submit page prefilled through the URL
- Close the submit page
- Click on Submit again,
In this case, if the parameters are preserved, we would open the prefilled page. Removing the parameters will ensure the developer can start the page fresh without pre filled data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, thanks. IMO, it'd be better to remove this, because if a developer wants to start fresh, they can click on the "Workflows" icon on the left bar (or navigate to another page and back again)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I tried that workflow and the developer would need to go back to the workflows tab and re-trigger a workflow.
Most likely the developer who lands on this page through query parameters would try to Submit it.
Removing the extra added query parameters in this PR, will make the developer experience much better as they can recover quickly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, that makes sense. I checked and this is the only page using a<SlidingPanel>
that calls navigation.goto()
on close. Every other page just sets a parameter on close, e.g.
argo-workflows/ui/src/app/cluster-workflow-templates/cluster-workflow-template-details.tsx
Line 145 in e09d2f1
<SlidingPanel isShown={!!sidePanel} onClose={() => setSidePanel(null)} isMiddle={true}> |
I'm not sure why this page is special in that respect, but it could be a developer experience thing
Good start! A couple initial comments:
Here's a commit that does both things: MasonM@d2c11c8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- [...] Ideally, we'd use
useQueryParams()
too, but when I tried that, thehistory.listen()
callback wouldn't fire. I think that's due to the interdependency with theworkflowTemplates
/workflowParameters
props
In this case, I don't think it's necessary, because the URL should not change after the page loads, since the purpose is deeplinking. history.listen()
is to make sure the state and query params match.
It could still be used, but may be unnecessary complexity in this case.
- It'd be simpler to push the logic for handling workflow parameters to
ui/src/app/workflows/components/submit-workflow-panel.tsx
Agree, that was what I thought on first glance of this yesterday too, but hadn't commented yet since it's still draft and wanted to see if you or Sairam would pick that up in iteration 🙂
isShown={!!getSidePanel()} | ||
onClose={() => { | ||
// Remove any lingering query params | ||
const qParams: {[key: string]: string | null} = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you explain why this is necessary? The navigation.goto()
function already has logic to automatically strip out the query parameters if there's been a path change: https://github.com/argoproj/argo-ui/blob/54f36c723d9a0e5d3386689298cbb9c27767fa00/src/components/navigation.ts#L20-L21
If there hasn't been a path change, I think it's fine to leave these query parameters in.
|
||
// Add the sidePanel query parameter if it exists | ||
params.append('sidePanel', getSidePanel()); | ||
params.append('template', queryParams.get('template')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why this component is taking an allow-list approach to query parameters, but you could get rid of this extra code by changing const params = new URLSearchParams()
to const params = new URLSearchParams(history.location.search);
I'm not sure what side-effects that'll have, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could preserve all the parameters. We might have to try different scenarios to check for side-effects.
@@ -126,7 +126,7 @@ export function WorkflowsList({match, location, history}: RouteComponentProps<an | |||
} | |||
storage.setItem('options', options, {} as WorkflowListRenderOptions); | |||
|
|||
const params = new URLSearchParams(); | |||
const params = new URLSearchParams(history.location.search); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found one side-effect of this change: if you visit http://localhost:8080/workflows?namespace=argo and refresh the page, it'll append &namespace=argo
each time you refresh. That's happening because historyUrl()
isn't deduplicating query parameters, which it should IMO. Here's a commit that fixes that: MasonM@8b48d5b
I haven't extensively tested that, so it's possible there's other side-effects
const path = createPath({pathname: '/workflows', search: '?parameters[key1]=value1¶meters[key2]=value2'}); | ||
history.location.search = path; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is failing because window.location.search
should only contain the query string, not the path:
const path = createPath({pathname: '/workflows', search: '?parameters[key1]=value1¶meters[key2]=value2'}); | |
history.location.search = path; | |
history.location.search = '?parameters[key1]=value1¶meters[key2]=value2'; |
Also, if you haven't already, you should install the Jest extension in the DevContainer so you can debug the tests and set breakpoints:
const path = createPath({pathname: '/workflows', search: '?parameters[key1]=value1¶meters[key2]=value2&test=123'}); | ||
history.location.search = path; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above:
const path = createPath({pathname: '/workflows', search: '?parameters[key1]=value1¶meters[key2]=value2&test=123'}); | |
history.location.search = path; | |
history.location.search = '?parameters[key1]=value1¶meters[key2]=value2&test=123'; |
@sairam91 Sorry for the delay. You mentioned you were going to fill out the "Verification" section of the PR, so I was waiting for that. If you're unsure of what to put there, I think this would work (you can copy-and-paste this): Verification
Also, it looks like there's conflicts. If you can add me as a collaborator at https://github.com/sairam91/argo-workflows/settings, I can resolve them for you, if you want. |
…1214 Signed-off-by: Sairam Arunachalam <[email protected]>
d34ee68
to
5e884b8
Compare
Closed in favor of #13922 |
Fixes #12124
Motivation
This PR adds support for developers to prefil submit workflow form by passing in the values through query parameters.
To prefil a submit workflow developers can pass in the following query parameters
Modifications
workflow-list
componentsubmit-workflow-panel.tsx
component to default entry point if provided.workflow-creator.tsx
to read default values from query parameters.?parameters[key]=value
.Verification