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

Support multiline input for Params of type string in trigger UI form #40414

Merged

Conversation

sc-anssi
Copy link
Contributor


This patch adds the possibility to have a multiline input (textarea) for Params of type "string" in the trigger UI form. The choice between rendering a text input (single line) or a textarea (multiline) is based on the presence of a new line character in any of the examples of the Param.
For instance, the following code generates a multiline input:

Param(
    description="a parameter that is rendered better with a textarea",
    type=["string", "null"],
    examples=["first line of text before\na new line"],
)

I know Params of type "array" are rendered as textareas but forcing our end-users to format their multiline text into an array of strings would not be very friendly :). So it seems more practical to leave the Param as a "string" type and work on the rendering options instead.

The patch is merely a PoC to showcase what the feature would look like and by no means a definitive solution. I think that relying on the examples attribute is more a hack than a solution, but adding a new explicit attribute to the Param object is beyond my understanding of Airflow. So feel free to rewrite it completely if you think the feature is worth it.

@boring-cyborg boring-cyborg bot added area:UI Related to UI/UX. For Frontend Developers. area:webserver Webserver related Issues labels Jun 25, 2024
Copy link

boring-cyborg bot commented Jun 25, 2024

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
Here are some useful points:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our pre-commits will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example DAG that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
  • Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: [email protected]
    Slack: https://s.apache.org/airflow-slack

@sc-anssi sc-anssi marked this pull request as ready for review June 28, 2024 08:37
@sc-anssi sc-anssi force-pushed the feat-textarea-for-string-params-in-trigger-ui branch from e11430d to dfecf1d Compare June 28, 2024 08:37
Copy link
Contributor

@jscheffl jscheffl left a comment

Choose a reason for hiding this comment

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

I'd propose to make the feature explicit and not based on newline in examples.
Is any of the JSON schema attributes matching as an option? Else you are free to "invent" or deine a new and specific attribute as marker.

Can you also please adjust the docs such that users are able to know about the feature w/o the need to read source code?

@sc-anssi
Copy link
Contributor Author

Thanks for the feedback ! I'll try to check whether the format attribute of the JSON schema for string type can be used in this case.

Copy link

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

@github-actions github-actions bot added the stale Stale PRs per the .github/workflows/stale.yml policy file label Aug 26, 2024
@sc-anssi sc-anssi force-pushed the feat-textarea-for-string-params-in-trigger-ui branch from dfecf1d to 3596f03 Compare August 30, 2024 22:11
@sc-anssi sc-anssi requested a review from potiuk as a code owner August 31, 2024 00:12
@sc-anssi sc-anssi requested a review from jscheffl August 31, 2024 00:13
@jscheffl
Copy link
Contributor

Some static checks fail. Though I like the implementation a lot more than before... actually as project team we have decided (1) that Airflow 2.10 will only get new features in exceptional cases and (2) the UI will be completely re-written - So an upcoming Airflow 3 will have a 100% new codebase for UI... this change probably will never to live in any future release.

@bbovenzi WDYT how should we treat this PR? Make it to main to have a reminder to migrate it/the feature to the new UI? I think it is useful but code needs to be re-written anyway in 100% React.

@github-actions github-actions bot removed the stale Stale PRs per the .github/workflows/stale.yml policy file label Sep 3, 2024
@bbovenzi
Copy link
Contributor

bbovenzi commented Sep 4, 2024

Some static checks fail. Though I like the implementation a lot more than before... actually as project team we have decided (1) that Airflow 2.10 will only get new features in exceptional cases and (2) the UI will be completely re-written - So an upcoming Airflow 3 will have a 100% new codebase for UI... this change probably will never to live in any future release.

@bbovenzi WDYT how should we treat this PR? Make it to main to have a reminder to migrate it/the feature to the new UI? I think it is useful but code needs to be re-written anyway in 100% React.

I think this is a small enough of a surface area where adding it now doesn't significantly change how we rebuild this view. But having it in the code reminds us to make this feature work in 2.10.

@jscheffl
Copy link
Contributor

jscheffl commented Sep 4, 2024

Some static checks fail. Though I like the implementation a lot more than before... actually as project team we have decided (1) that Airflow 2.10 will only get new features in exceptional cases and (2) the UI will be completely re-written - So an upcoming Airflow 3 will have a 100% new codebase for UI... this change probably will never to live in any future release.
@bbovenzi WDYT how should we treat this PR? Make it to main to have a reminder to migrate it/the feature to the new UI? I think it is useful but code needs to be re-written anyway in 100% React.

I think this is a small enough of a surface area where adding it now doesn't significantly change how we rebuild this view. But having it in the code reminds us to make this feature work in 2.10.

@sc-anssi So then I would say... if you fix the static checks then we could merge it and back-port to a 2.10.2 release...

@sc-anssi sc-anssi force-pushed the feat-textarea-for-string-params-in-trigger-ui branch from ab0d291 to 8bfc7b3 Compare September 9, 2024 08:59
@sc-anssi sc-anssi force-pushed the feat-textarea-for-string-params-in-trigger-ui branch from 8bfc7b3 to ae64532 Compare September 9, 2024 09:06
@sc-anssi
Copy link
Contributor Author

sc-anssi commented Sep 9, 2024

@sc-anssi So then I would say... if you fix the static checks then we could merge it and back-port to a 2.10.2 release...

Spelling is fixed, please let me know if anything else needs to be done 👍

@jscheffl jscheffl merged commit 46306f5 into apache:main Sep 10, 2024
51 checks passed
Copy link

boring-cyborg bot commented Sep 10, 2024

Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions.

jscheffl pushed a commit to jscheffl/airflow that referenced this pull request Sep 10, 2024
…pache#40414)

* Add multiline input (textarea) support for Params of type string in trigger UI form

* Use the 'format' attribute in the Param for rendering a multiline text area in the trigger UI form

* Update example DAG and documentation to illustrate the use of a multiline text Param
bbovenzi pushed a commit that referenced this pull request Sep 10, 2024
…40414) (#42139)

* Add multiline input (textarea) support for Params of type string in trigger UI form

* Use the 'format' attribute in the Param for rendering a multiline text area in the trigger UI form

* Update example DAG and documentation to illustrate the use of a multiline text Param

Co-authored-by: sc-anssi <[email protected]>
ephraimbuddy pushed a commit that referenced this pull request Sep 13, 2024
…40414) (#42139)

* Add multiline input (textarea) support for Params of type string in trigger UI form

* Use the 'format' attribute in the Param for rendering a multiline text area in the trigger UI form

* Update example DAG and documentation to illustrate the use of a multiline text Param

Co-authored-by: sc-anssi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:UI Related to UI/UX. For Frontend Developers. area:webserver Webserver related Issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants