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

Fix elipsis button not working if the last commit loading is deferred #29544

Merged
merged 9 commits into from
Mar 2, 2024

Commits on Mar 2, 2024

  1. Fix elipsis button not working if the last commit loading is deferred

    Before this change, if we had more than 200 entries being deferred in loading, the entire table would get replaced thus losing any event listeners attached to the elements within the table, such as the elipsis button and commit list with tippy.
    
    With this change we remove the previous javascript code that replaced the table and use htmx to replace the table.
    
    htmx attributes added:
    - `hx-indicator="tr.notready td.message span"`: attach the loading spinner to the files whose last commit is still being loaded
    - `hx-trigger="load[this.querySelectorAll('tr.notready').length > 0]"` trigger the request-replace behavior as soon as possible and only if the current table is showing files that haven't had their latest commit info loaded. If this inline javascript doesn't look good I can change it so the backend doesn't render the htmx attributes if it's an htmx request, and the trigger would simply be `load` but I like it as it is now
    - `hx-swap="morph"`:  use the idiomorph morphing algorithm, this is the thing that makes it so the elipsis button event listener is kept during the replacement, fixing the bug
    - `hx-post="{{.LastCommitLoaderURL}}"`: make a post request to this url to get the table with all of the commit information
    
    As part of this change I removed the handling of partial replacement in the case we have less than 200 "not ready" files. The first reason is that I couldn't make htmx replace only a subset of returned elements, the second reason is that we have a cache implemented in the backend already so the only cost added is that we query the cache a few times (which is sure to be populated due to the initial request), and the last reason is that since the last refactor of this functionality that removed jQuery we don't properly send the "not ready" entries as the backend expects `FormData` with `f[]` and we send a JSON with `f` so we always query for all rows anyway.
    
    Signed-off-by: Yarden Shoham <git@yardenshoham.com>
    yardenshoham committed Mar 2, 2024
    Configuration menu
    Copy the full SHA
    f0710c5 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    c5098d2 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    0f5d7d9 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    aa73b74 View commit details
    Browse the repository at this point in the history
  5. Update routers/web/repo/view.go

    Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
    yardenshoham and wxiaoguang committed Mar 2, 2024
    Configuration menu
    Copy the full SHA
    b6e65a7 View commit details
    Browse the repository at this point in the history
  6. Update templates/repo/view_list.tmpl

    Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
    yardenshoham and wxiaoguang committed Mar 2, 2024
    Configuration menu
    Copy the full SHA
    09efb7a View commit details
    Browse the repository at this point in the history
  7. Remove the ...

    yardenshoham committed Mar 2, 2024
    Configuration menu
    Copy the full SHA
    8bd082b View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    50e480e View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    ad98672 View commit details
    Browse the repository at this point in the history