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

Clean-up JS code in UI templates #14019

Merged
merged 1 commit into from
Feb 3, 2021
Merged

Conversation

XD-DENG
Copy link
Member

@XD-DENG XD-DENG commented Feb 2, 2021

Clean up JS code in UI templates. Mainly:

  • Use template literals instead of '+' for forming strings, when applicable
  • remove unused variables (in gantt.html)
  • remove unused function arguments, when applicable

^ Add meaningful description above

Read the Pull Request Guidelines for more information.
In case of fundamental code change, Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in UPDATING.md.

- Use template literals instead of '+' for forming strings, when applicable
- remove unused variables (gantt.html)
- remove unused function arguments, when applicable
@XD-DENG XD-DENG added priority:low Bug with a simple workaround that would not block a release area:UI Related to UI/UX. For Frontend Developers. labels Feb 2, 2021
@XD-DENG XD-DENG added this to the Airflow 2.0.1 milestone Feb 2, 2021
@boring-cyborg boring-cyborg bot added the area:webserver Webserver related Issues label Feb 2, 2021
@XD-DENG
Copy link
Member Author

XD-DENG commented Feb 2, 2021

All these are very simple changes. But it would be great to have more pairs of eyes to help check in case any mistake is made. I understand @ryanahamilton is working on automated eslint integration, but I guess it will come only later, so I hope this change is still helpful.

@XD-DENG XD-DENG removed the area:webserver Webserver related Issues label Feb 2, 2021
@@ -375,13 +375,13 @@ <h4 class="modal-title" id="dagModalLabel">
{{ super() }}
<script>
function updateQueryStringParameter(uri, key, value) {
var re = new RegExp('([?&])' + key + '=.*?(&|$)', 'i');
var re = new RegExp(`([?&])${key}=.*?(&|$)`, 'i');
Copy link
Member

Choose a reason for hiding this comment

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

What browsers support this? It's a "relatively" new syntax (and JS-in-html is not subject to any compile steps)

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you mean the template literals? Here is the information: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#browser_compatibility Only IE is marked "No support"

This should not be a concern to me though, because there is already usage of template literals in 2.0.0 (example And I believe in some 1.10.* versions too) and so far there is not any complaint regarding this.

Let me know if you are referring to anything else?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally, we'd start migrating these scripts to external (compiled) files to make this concern moot. I'm not super concerned about IE support, but I wish we had actual usage data to better inform us. Google Analytics appears to be installed on the documentation site—maybe its browser usage reports could serve as proxy (better than nothing)?

Copy link
Contributor

Choose a reason for hiding this comment

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

I conferred w/ @ashb and we're both good on moving forward with this given it is already in practice. I'll add an issue for migrating all of the inline scripting to external files.

@github-actions
Copy link

github-actions bot commented Feb 3, 2021

The PR is likely OK to be merged with just subset of tests for default Python and Database versions without running the full matrix of tests, because it does not modify the core of Airflow. If the committers decide that the full tests matrix is needed, they will add the label 'full tests needed'. Then you should rebase to the latest master or amend the last commit of the PR, and push it with --force-with-lease.

@github-actions github-actions bot added the okay to merge It's ok to merge this PR as it does not require more tests label Feb 3, 2021
@kaxil kaxil merged commit 14805cc into apache:master Feb 3, 2021
@XD-DENG XD-DENG deleted the js-simple-cleanup branch February 3, 2021 19:28
@XD-DENG
Copy link
Member Author

XD-DENG commented Feb 6, 2021

Hi @ryanahamilton @ashb , may I know if there is already an issue created for items below?

  • migrating all of the inline scripting to external files
  • eslint integration

Let me know if not, and I can create it (surely will need you to help enrich the description though).

@ryanahamilton
Copy link
Contributor

@XD-DENG no, not yet. That would be appreciated, and I can certainly add more detail.

As for the ESLint integration, I actually made an attempt at resolving it several months ago in #11699. While I had it working locally with pre-commit, I was unable to get it executing properly in our CI environment.

@ashb
Copy link
Member

ashb commented Feb 6, 2021

I think Kamil may have created an issue about splitting it out a year+ ago but can't find it right now

@XD-DENG
Copy link
Member Author

XD-DENG commented Feb 6, 2021

I have tried to search now as well, but cannot find any either. I will proceed to create one; if we find it duplicated later, we can merge & clean anyway.

@XD-DENG
Copy link
Member Author

XD-DENG commented Feb 6, 2021

I created a new issue at #14115 . Please feel free to enrich/correct the description.

In terms of timeline, does aiming for having in 2.2 make sense? @ashb @ryanahamilton . Let's continue the discussion in the issue anyway. Thanks.

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. okay to merge It's ok to merge this PR as it does not require more tests priority:low Bug with a simple workaround that would not block a release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants