-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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 and fix clone button script #20415
Conversation
f27f702
to
9281b98
Compare
The init function can be called before jQuery's document-ready, eg: https://github.com/go-gitea/gitea/blob/main/web_src/js/index.js#L90-L92 Then there is no need to write scripts in templates (well, if the loading of compiled update: if the clone buttons are moved into a dropdown menu (like GitHub), then there will be no UI flicker anymore, resolved fundamentally. |
Any script that's loaded via URL will be asynchronously executed and not be fast enough to prevent the flicker, which is very noticable in Firefox to me. I see no other way around than this inline script. Maybe it would be possible to get webpack to pre-compile inline scripts directly into the template files, but other than that I see no way of avoiding inline scripts here. |
(I updated my comment, sorry for bothering). How about moving the buttons into a dropdown menu like GitHub? |
Dropdown menu akin to GitHub might work for existing repos, but the new repo page still needs the URLs in the page rendering. Proper solution will probably be to eventually store user settings like this in the backend so protocol preference is available at template rendering time and we don't need Still I think this PR is valuable until then. |
Squashed and rebased. |
The button 'primary' class needs to be set in a synchronous script to prevent flicker of the button which was regressed recently, fixed that. Additionally, reduced the two script tags to just one, the previous scripts were actually initializing the buttons thrice on the empty repo page, now it only initializes once. Finally, removed duplicate code and re-used the inline function in the update code as well.
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.
nice refactor of the clone button script, much more readable 👍
. |
* giteaofficial/main: (29 commits) [skip ci] Updated translations via Crowdin Support localized README (go-gitea#20508) Clean up and fix clone button script (go-gitea#20415) Add disable download source configuration (go-gitea#20548) Fix default merge style (go-gitea#20564) Update login methods in package docs (go-gitea#20561) Add missing Tabs on organisation/package view (Frontport go-gitea#20539) (go-gitea#20540) [skip ci] Updated licenses and gitignores Add setting `SQLITE_JOURNAL_MODE` to enable WAL (go-gitea#20535) Rework file highlight rendering and fix yaml copy-paste (go-gitea#19967) Add new API endpoints for push mirrors management (go-gitea#19841) WebAuthn CredentialID field needs to be increased in size (go-gitea#20530) Add latest commit's SHA to content response (go-gitea#20398) Improve token and secret key generation docs (go-gitea#20387) [skip ci] Updated translations via Crowdin Rework raw file http header logic (go-gitea#20484) Update lunny/levelqueue to prevent NPE when reads are performed after close (go-gitea#20534) Added guidance on file to choose to download (go-gitea#20474) [skip ci] Updated translations via Crowdin Ensure that all unmerged files are merged when conflict checking (go-gitea#20528) ...
The button 'primary' class needs to be set in a synchronous script to prevent flicker of the button which was regressed recently, fixed that. Additionally, reduced the two script tags to just one, the previous scripts were actually initializing the buttons thrice on the empty repo page, now it only initializes once. Finally, removed duplicate code and re-used the inline function in the update code as well. I had to split out the script into a separate template as on the empty repo page, the script needs access to the clone URL span in the example text, which is rendered below the clone buttons, so buttons and script could not be combined.
* Clean up and fix clone button script (#20415) The button 'primary' class needs to be set in a synchronous script to prevent flicker of the button which was regressed recently, fixed that. Additionally, reduced the two script tags to just one, the previous scripts were actually initializing the buttons thrice on the empty repo page, now it only initializes once. Finally, removed duplicate code and re-used the inline function in the update code as well. I had to split out the script into a separate template as on the empty repo page, the script needs access to the clone URL span in the example text, which is rendered below the clone buttons, so buttons and script could not be combined. * Add default value for clone URLs Default clone URLs to HTTP(S) in DOM rendering. JS will immediately replace this if the user preference is SSH. Fixes: #20558
The button 'primary' class needs to be set in a synchronous script to prevent flicker of the button which was regressed recently, fixed that. Additionally, reduced the two script tags to just one, the previous scripts were actually initializing the buttons thrice on the empty repo page, now it only initializes once. Finally, removed duplicate code and re-used the inline function in the update code as well. I had to split out the script into a separate template as on the empty repo page, the script needs access to the clone URL span in the example text, which is rendered below the clone buttons, so buttons and script could not be combined.
## [1.17.1](https://github.com/go-gitea/gitea/releases/tag/1.17.1) - 2022-08-17 * SECURITY * Correctly escape within tribute.js (go-gitea#20831) (go-gitea#20832) * FEATURES * Add support for NuGet API keys (go-gitea#20721) (go-gitea#20734) * ENHANCEMENTS * Display project in issue list (go-gitea#20583) * Add disable download source configuration (go-gitea#20548) (go-gitea#20579) * BUGFIXES * Use the total issue count for UI (go-gitea#20785) (go-gitea#20827) * Add proxy host into allow list (go-gitea#20798) (go-gitea#20819) * Add missing translation for queue flush workers (go-gitea#20791) (go-gitea#20792) * Improve comment header for mobile (go-gitea#20781) (go-gitea#20789) * Fix git.Init for doctor sub-command (go-gitea#20782) (go-gitea#20783) * Check webhooks slice length before calling xorm (go-gitea#20642) (go-gitea#20768) * Remove manual rollback for failed generated repositories (go-gitea#20639) (go-gitea#20762) * Use correct field name in npm template (go-gitea#20675) (go-gitea#20760) * Keep download count on Container tag overwrite (go-gitea#20728) (go-gitea#20735) * Fix v220 migration to be compatible for MSSQL 2008 r2 (go-gitea#20702) (go-gitea#20707) * Use request timeout for git service rpc (go-gitea#20689) (go-gitea#20693) * Send correct NuGet status codes (go-gitea#20647) (go-gitea#20677) * Use correct context to get package content (go-gitea#20673) (go-gitea#20676) * Fix the JS error "EventSource is not defined" caused by some non-standard browsers (go-gitea#20584) (go-gitea#20663) * Add default commit messages to PR for squash merge (go-gitea#20618) (go-gitea#20645) * Fix package upload for files >32mb (go-gitea#20622) (go-gitea#20635) * Fix the new-line copy-paste for rendered code (go-gitea#20612) * Clean up and fix clone button script (go-gitea#20415 & go-gitea#20600) (go-gitea#20599) * Fix default merge style (go-gitea#20564) (go-gitea#20565) * Add repository condition for issue count (go-gitea#20454) (go-gitea#20496) * MISC * Make branch icon stand out more (go-gitea#20726) (go-gitea#20774) * Fix loading button with invalid form (go-gitea#20754) (go-gitea#20759) * Add username check to doctor (go-gitea#20140) (go-gitea#20671) * Enable Wire 2 for Internal SSH Server (go-gitea#20616) (go-gitea#20617) * Fix SecToTime edge-cases (go-gitea#20610) (go-gitea#20611) Signed-off-by: Andrew Thornton <art27@cantab.net>
* Changelog 1.17.1 ## [1.17.1](https://github.com/go-gitea/gitea/releases/tag/1.17.1) - 2022-08-17 * SECURITY * Correctly escape within tribute.js (#20831) (#20832) * FEATURES * Add support for NuGet API keys (#20721) (#20734) * ENHANCEMENTS * Display project in issue list (#20583) * Add disable download source configuration (#20548) (#20579) * BUGFIXES * Use the total issue count for UI (#20785) (#20827) * Add proxy host into allow list (#20798) (#20819) * Add missing translation for queue flush workers (#20791) (#20792) * Improve comment header for mobile (#20781) (#20789) * Fix git.Init for doctor sub-command (#20782) (#20783) * Check webhooks slice length before calling xorm (#20642) (#20768) * Remove manual rollback for failed generated repositories (#20639) (#20762) * Use correct field name in npm template (#20675) (#20760) * Keep download count on Container tag overwrite (#20728) (#20735) * Fix v220 migration to be compatible for MSSQL 2008 r2 (#20702) (#20707) * Use request timeout for git service rpc (#20689) (#20693) * Send correct NuGet status codes (#20647) (#20677) * Use correct context to get package content (#20673) (#20676) * Fix the JS error "EventSource is not defined" caused by some non-standard browsers (#20584) (#20663) * Add default commit messages to PR for squash merge (#20618) (#20645) * Fix package upload for files >32mb (#20622) (#20635) * Fix the new-line copy-paste for rendered code (#20612) * Clean up and fix clone button script (#20415 & #20600) (#20599) * Fix default merge style (#20564) (#20565) * Add repository condition for issue count (#20454) (#20496) * MISC * Make branch icon stand out more (#20726) (#20774) * Fix loading button with invalid form (#20754) (#20759) * Add username check to doctor (#20140) (#20671) * Enable Wire 2 for Internal SSH Server (#20616) (#20617) * Fix SecToTime edge-cases (#20610) (#20611) Signed-off-by: Andrew Thornton <art27@cantab.net> * Apply suggestions from code review Co-authored-by: John Olheiser <john+github@jolheiser.com> * Update CHANGELOG.md Co-authored-by: delvh <dev.lh@web.de> * Update CHANGELOG.md * Update CHANGELOG.md * update changelog * Update CHANGELOG.md Co-authored-by: John Olheiser <john+github@jolheiser.com> Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: techknowlogick <matti@mdranta.net> Co-authored-by: John Olheiser <john+github@jolheiser.com> Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Changelog 1.17.1 ## [1.17.1](https://github.com/go-gitea/gitea/releases/tag/1.17.1) - 2022-08-17 * SECURITY * Correctly escape within tribute.js (go-gitea#20831) (go-gitea#20832) * FEATURES * Add support for NuGet API keys (go-gitea#20721) (go-gitea#20734) * ENHANCEMENTS * Display project in issue list (go-gitea#20583) * Add disable download source configuration (go-gitea#20548) (go-gitea#20579) * BUGFIXES * Use the total issue count for UI (go-gitea#20785) (go-gitea#20827) * Add proxy host into allow list (go-gitea#20798) (go-gitea#20819) * Add missing translation for queue flush workers (go-gitea#20791) (go-gitea#20792) * Improve comment header for mobile (go-gitea#20781) (go-gitea#20789) * Fix git.Init for doctor sub-command (go-gitea#20782) (go-gitea#20783) * Check webhooks slice length before calling xorm (go-gitea#20642) (go-gitea#20768) * Remove manual rollback for failed generated repositories (go-gitea#20639) (go-gitea#20762) * Use correct field name in npm template (go-gitea#20675) (go-gitea#20760) * Keep download count on Container tag overwrite (go-gitea#20728) (go-gitea#20735) * Fix v220 migration to be compatible for MSSQL 2008 r2 (go-gitea#20702) (go-gitea#20707) * Use request timeout for git service rpc (go-gitea#20689) (go-gitea#20693) * Send correct NuGet status codes (go-gitea#20647) (go-gitea#20677) * Use correct context to get package content (go-gitea#20673) (go-gitea#20676) * Fix the JS error "EventSource is not defined" caused by some non-standard browsers (go-gitea#20584) (go-gitea#20663) * Add default commit messages to PR for squash merge (go-gitea#20618) (go-gitea#20645) * Fix package upload for files >32mb (go-gitea#20622) (go-gitea#20635) * Fix the new-line copy-paste for rendered code (go-gitea#20612) * Clean up and fix clone button script (go-gitea#20415 & go-gitea#20600) (go-gitea#20599) * Fix default merge style (go-gitea#20564) (go-gitea#20565) * Add repository condition for issue count (go-gitea#20454) (go-gitea#20496) * MISC * Make branch icon stand out more (go-gitea#20726) (go-gitea#20774) * Fix loading button with invalid form (go-gitea#20754) (go-gitea#20759) * Add username check to doctor (go-gitea#20140) (go-gitea#20671) * Enable Wire 2 for Internal SSH Server (go-gitea#20616) (go-gitea#20617) * Fix SecToTime edge-cases (go-gitea#20610) (go-gitea#20611) Signed-off-by: Andrew Thornton <art27@cantab.net> * Apply suggestions from code review Co-authored-by: John Olheiser <john+github@jolheiser.com> * Update CHANGELOG.md Co-authored-by: delvh <dev.lh@web.de> * Update CHANGELOG.md * Update CHANGELOG.md * update changelog * Update CHANGELOG.md Co-authored-by: John Olheiser <john+github@jolheiser.com> Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: techknowlogick <matti@mdranta.net> Co-authored-by: John Olheiser <john+github@jolheiser.com> Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Changelog 1.17.1 (#20833) * Changelog 1.17.1 ## [1.17.1](https://github.com/go-gitea/gitea/releases/tag/1.17.1) - 2022-08-17 * SECURITY * Correctly escape within tribute.js (#20831) (#20832) * FEATURES * Add support for NuGet API keys (#20721) (#20734) * ENHANCEMENTS * Display project in issue list (#20583) * Add disable download source configuration (#20548) (#20579) * BUGFIXES * Use the total issue count for UI (#20785) (#20827) * Add proxy host into allow list (#20798) (#20819) * Add missing translation for queue flush workers (#20791) (#20792) * Improve comment header for mobile (#20781) (#20789) * Fix git.Init for doctor sub-command (#20782) (#20783) * Check webhooks slice length before calling xorm (#20642) (#20768) * Remove manual rollback for failed generated repositories (#20639) (#20762) * Use correct field name in npm template (#20675) (#20760) * Keep download count on Container tag overwrite (#20728) (#20735) * Fix v220 migration to be compatible for MSSQL 2008 r2 (#20702) (#20707) * Use request timeout for git service rpc (#20689) (#20693) * Send correct NuGet status codes (#20647) (#20677) * Use correct context to get package content (#20673) (#20676) * Fix the JS error "EventSource is not defined" caused by some non-standard browsers (#20584) (#20663) * Add default commit messages to PR for squash merge (#20618) (#20645) * Fix package upload for files >32mb (#20622) (#20635) * Fix the new-line copy-paste for rendered code (#20612) * Clean up and fix clone button script (#20415 & #20600) (#20599) * Fix default merge style (#20564) (#20565) * Add repository condition for issue count (#20454) (#20496) * MISC * Make branch icon stand out more (#20726) (#20774) * Fix loading button with invalid form (#20754) (#20759) * Add username check to doctor (#20140) (#20671) * Enable Wire 2 for Internal SSH Server (#20616) (#20617) * Fix SecToTime edge-cases (#20610) (#20611) Signed-off-by: Andrew Thornton <art27@cantab.net> * Apply suggestions from code review Co-authored-by: John Olheiser <john+github@jolheiser.com> * Update CHANGELOG.md Co-authored-by: delvh <dev.lh@web.de> * Update CHANGELOG.md * Update CHANGELOG.md * update changelog * Update CHANGELOG.md Co-authored-by: John Olheiser <john+github@jolheiser.com> Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: techknowlogick <matti@mdranta.net> Co-authored-by: John Olheiser <john+github@jolheiser.com> Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io> * update changelog Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: techknowlogick <matti@mdranta.net> Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Changelog 1.17.1 (go-gitea#20833) * Changelog 1.17.1 ## [1.17.1](https://github.com/go-gitea/gitea/releases/tag/1.17.1) - 2022-08-17 * SECURITY * Correctly escape within tribute.js (go-gitea#20831) (go-gitea#20832) * FEATURES * Add support for NuGet API keys (go-gitea#20721) (go-gitea#20734) * ENHANCEMENTS * Display project in issue list (go-gitea#20583) * Add disable download source configuration (go-gitea#20548) (go-gitea#20579) * BUGFIXES * Use the total issue count for UI (go-gitea#20785) (go-gitea#20827) * Add proxy host into allow list (go-gitea#20798) (go-gitea#20819) * Add missing translation for queue flush workers (go-gitea#20791) (go-gitea#20792) * Improve comment header for mobile (go-gitea#20781) (go-gitea#20789) * Fix git.Init for doctor sub-command (go-gitea#20782) (go-gitea#20783) * Check webhooks slice length before calling xorm (go-gitea#20642) (go-gitea#20768) * Remove manual rollback for failed generated repositories (go-gitea#20639) (go-gitea#20762) * Use correct field name in npm template (go-gitea#20675) (go-gitea#20760) * Keep download count on Container tag overwrite (go-gitea#20728) (go-gitea#20735) * Fix v220 migration to be compatible for MSSQL 2008 r2 (go-gitea#20702) (go-gitea#20707) * Use request timeout for git service rpc (go-gitea#20689) (go-gitea#20693) * Send correct NuGet status codes (go-gitea#20647) (go-gitea#20677) * Use correct context to get package content (go-gitea#20673) (go-gitea#20676) * Fix the JS error "EventSource is not defined" caused by some non-standard browsers (go-gitea#20584) (go-gitea#20663) * Add default commit messages to PR for squash merge (go-gitea#20618) (go-gitea#20645) * Fix package upload for files >32mb (go-gitea#20622) (go-gitea#20635) * Fix the new-line copy-paste for rendered code (go-gitea#20612) * Clean up and fix clone button script (go-gitea#20415 & go-gitea#20600) (go-gitea#20599) * Fix default merge style (go-gitea#20564) (go-gitea#20565) * Add repository condition for issue count (go-gitea#20454) (go-gitea#20496) * MISC * Make branch icon stand out more (go-gitea#20726) (go-gitea#20774) * Fix loading button with invalid form (go-gitea#20754) (go-gitea#20759) * Add username check to doctor (go-gitea#20140) (go-gitea#20671) * Enable Wire 2 for Internal SSH Server (go-gitea#20616) (go-gitea#20617) * Fix SecToTime edge-cases (go-gitea#20610) (go-gitea#20611) Signed-off-by: Andrew Thornton <art27@cantab.net> * Apply suggestions from code review Co-authored-by: John Olheiser <john+github@jolheiser.com> * Update CHANGELOG.md Co-authored-by: delvh <dev.lh@web.de> * Update CHANGELOG.md * Update CHANGELOG.md * update changelog * Update CHANGELOG.md Co-authored-by: John Olheiser <john+github@jolheiser.com> Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: techknowlogick <matti@mdranta.net> Co-authored-by: John Olheiser <john+github@jolheiser.com> Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io> * update changelog Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: techknowlogick <matti@mdranta.net> Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
The button 'primary' class needs to be set in a synchronous script to prevent flicker of the button which was regressed recently, fixed that.
Additionally, reduced the two script tags to just one, the previous scripts were actually initializing the buttons thrice on the empty repo page, now it only initializes once. Finally, removed duplicate code and re-used the inline function in the update code as well.
I had to split out the script into a separate template as on the empty repo page, the script needs access to the clone URL span in the example text, which is rendered below the clone buttons, so buttons and script could not be combined.