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

feat: Always Show Workflow Parameters #7809

Merged

Conversation

kennytrytek
Copy link
Contributor

@kennytrytek kennytrytek commented Feb 8, 2022

Signed-off-by: Kenny Trytek kenneth.g.trytek@gmail.com

Fixes #7311

Testing

The following GIF shows the submission of the example workflow from #7311 (comment).

  • Workflow can be submitted with workflow parameters given, even if a non-default entrypoint is selected.

submission

@kennytrytek kennytrytek force-pushed the kgt/always-submit-workflow-params branch from 65d30cf to 2799bc3 Compare February 8, 2022 03:02
@stale
Copy link

stale bot commented Feb 22, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the problem/stale This has not had a response in some time label Feb 22, 2022
@kennytrytek
Copy link
Contributor Author

Hi Stale bot, I'm planning on updating this today.

@stale stale bot removed the problem/stale This has not had a response in some time label Feb 28, 2022
@kennytrytek kennytrytek force-pushed the kgt/always-submit-workflow-params branch from 2799bc3 to 6293e12 Compare March 1, 2022 02:28
@stale
Copy link

stale bot commented Mar 12, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the problem/stale This has not had a response in some time label Mar 12, 2022
@kennytrytek kennytrytek force-pushed the kgt/always-submit-workflow-params branch from 6293e12 to 29ebabd Compare March 22, 2022 01:19
@stale stale bot removed the problem/stale This has not had a response in some time label Mar 22, 2022
@kennytrytek kennytrytek force-pushed the kgt/always-submit-workflow-params branch 2 times, most recently from 5bda1c3 to 2b2bb7a Compare March 22, 2022 16:19
value: p.name === parameter.name ? event.value : this.getValue(p),
enum: p.enum
}));
this.setState(update);
Copy link
Contributor

Choose a reason for hiding this comment

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

do you want to use this.setState(oldState => newState) version here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is only one example of the pattern you suggested in the code base:
https://github.com/argoproj/argo-workflows/blob/v3.3.1/ui/src/app/shared/components/input-filter.tsx#L63

What would this code gain by using that pattern? All other setStates in the UI look like this.

Copy link
Contributor

Choose a reason for hiding this comment

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

it is useful it you only want to modify part of the state, which is what I think you are trying to do here

Copy link
Contributor

Choose a reason for hiding this comment

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

I think I'd do this differently, I'd add a new parameters to displaySelectFieldForEnumValues named onChange and pass in the correct func to it. The decouples the two functions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is useful it you only want to modify part of the state

I'm not convinced that setState(update) does not do a partial update. At least, I haven't been able to find any documentation that reads otherwise. I also tried using the arrow function update anyway, but was unable to make it successfully update the state.

I'd add a new parameters to displaySelectFieldForEnumValues named onChange and pass in the correct func to it

I understand the sentiment here, but I gave up after a few hours of trying to make it work this way. I ran into two problems:

  • The update function would lose reference to this.
  • The setState update would appear to work, but didn't actually update any values.

If you have any more specific direction, or just want someone else to make the changes, that would be fine with me.

@kennytrytek kennytrytek marked this pull request as ready for review March 23, 2022 15:45
entrypoint: workflowEntrypoint,
entrypoints: this.props.templates.map(t => t.name),
selectedTemplate: defaultTemplate,
parameters: this.props.workflowParameters || [],
parameters: [] as Parameter[],
workflowParameters: this.props.workflowParameters,
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need to make a copy of this object rather than reference if we're going to change it? Use Object.assign to copy an object

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to a copy in 44da063.

value: p.name === parameter.name ? event.value : this.getValue(p),
enum: p.enum
}));
this.setState(update);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I'd do this differently, I'd add a new parameters to displaySelectFieldForEnumValues named onChange and pass in the correct func to it. The decouples the two functions.

}))
});
const update = {} as State;
update[parameterStateName] = this.state[parameterStateName].map(p => ({
Copy link
Contributor

Choose a reason for hiding this comment

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

As above.

 - Fixes argoproj#7311

Signed-off-by: Kenny Trytek <kenneth.g.trytek@gmail.com>
 - Fixes argoproj#7311

Signed-off-by: Kenny Trytek <kenneth.g.trytek@gmail.com>
@kennytrytek kennytrytek force-pushed the kgt/always-submit-workflow-params branch from 2b2bb7a to 44da063 Compare April 5, 2022 01:42
@kennytrytek kennytrytek requested a review from alexec April 5, 2022 01:51
@alexec alexec merged commit af80774 into argoproj:master Apr 5, 2022
@sarabala1979 sarabala1979 mentioned this pull request Apr 14, 2022
85 tasks
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.

Allow to always pass workflow scoped variable via UI
2 participants