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

plugins: disable action button while computing #2560

Merged
merged 5 commits into from
Nov 15, 2023

Conversation

kecnry
Copy link
Member

@kecnry kecnry commented Nov 10, 2023

Description

This pull request implements re-usable infrastructure via a @with_spinner() method, which sets the spinner traitlet to True at the beginning of a method, and resets to False when it completes (successfully or not). This traitlet can then be used to disable and change the icon on the action button by passing it to <plugin-add-results :action_spinner='spinner'>. For expensive operations, this provides immediate feedback that something is happening and avoids the user clicking the button again before the action completes.

For more advanced cases, individual boolean traitlets can be added to the plugin and controlled separately by passing the name of the traitlet to the decorator. For example @with_spinner('spinner_custom').

All the logic lives in template_mixin.py and plugin_add_results.vue... everything else is just using that within all the various applicable plugins.

Example for model fitting a cube (but this PR applies the logic to all existing plugin-add-results buttons and a few others):

Screen.Recording.2023-11-10.at.2.01.03.PM.mov

Change log entry

  • Is a change log needed? If yes, is it added to CHANGES.rst? If you want to avoid merge conflicts,
    list the proposed change log here for review and add to CHANGES.rst before merge. If no, maintainer
    should add a no-changelog-entry-needed label.

Checklist for package maintainer(s)

This checklist is meant to remind the package maintainer(s) who will review this pull request of some common things to look for. This list is not exhaustive.

  • Are two approvals required? Branch protection rule does not check for the second approval. If a second approval is not necessary, please apply the trivial label.
  • Do the proposed changes actually accomplish desired goals? Also manually run the affected example notebooks, if necessary.
  • Do the proposed changes follow the STScI Style Guides?
  • Are tests added/updated as required? If so, do they follow the STScI Style Guides?
  • Are docs added/updated as required? If so, do they follow the STScI Style Guides?
  • Did the CI pass? If not, are the failures related?
  • Is a milestone set? Set this to bugfix milestone if this is a bug fix and needs to be released ASAP; otherwise, set this to the next major release milestone.
  • After merge, any internal documentations need updating (e.g., JIRA, Innerspace)?

* all action buttons get check icon
* optional: plugins can pass action_spinner as a traitlet, in which case the button will automatically disable and show a different icon as the action is being completed, before re-enabling.
and apply across all plugins
@kecnry kecnry added this to the 3.8 milestone Nov 10, 2023
@kecnry kecnry added UI/UX😍 plugin Label for plugins common to multiple configurations labels Nov 10, 2023
Copy link

codecov bot commented Nov 10, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Files Coverage Δ
...configs/cubeviz/plugins/moment_maps/moment_maps.py 92.55% <100.00%> (+0.08%) ⬆️
...plugins/spectral_extraction/spectral_extraction.py 69.07% <100.00%> (+0.32%) ⬆️
...daviz/configs/default/plugins/collapse/collapse.py 98.07% <100.00%> (+0.03%) ⬆️
...configs/default/plugins/export_plot/export_plot.py 60.40% <100.00%> (+1.06%) ⬆️
...default/plugins/gaussian_smooth/gaussian_smooth.py 97.89% <100.00%> (+0.04%) ⬆️
...igs/default/plugins/model_fitting/model_fitting.py 86.59% <100.00%> (+0.02%) ⬆️
...nfigs/default/plugins/plot_options/plot_options.py 91.20% <100.00%> (-0.03%) ⬇️
...imviz/plugins/aper_phot_simple/aper_phot_simple.py 91.13% <100.00%> (+0.03%) ⬆️
jdaviz/configs/imviz/plugins/catalogs/catalogs.py 86.72% <100.00%> (+0.11%) ⬆️
...plugins/spectral_extraction/spectral_extraction.py 90.97% <100.00%> (+0.20%) ⬆️
... and 1 more

📢 Thoughts on this report? Let us know!

kecnry added a commit to kecnry/lcviz that referenced this pull request Nov 10, 2023
kecnry added a commit to kecnry/lcviz that referenced this pull request Nov 10, 2023
Copy link
Collaborator

@rosteen rosteen left a comment

Choose a reason for hiding this comment

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

I really like this now with the spinner rather than check marks - code looks fine, approved.

@kecnry kecnry merged commit 5b45ba7 into spacetelescope:main Nov 15, 2023
19 checks passed
@kecnry kecnry deleted the add-results-spinner branch November 15, 2023 15:50
kecnry added a commit to kecnry/lcviz that referenced this pull request Nov 27, 2023
kecnry added a commit to kecnry/lcviz that referenced this pull request Nov 30, 2023
kecnry added a commit to kecnry/lcviz that referenced this pull request Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cubeviz imviz plugin Label for plugins common to multiple configurations Ready for final review specviz2d UI/UX😍
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants