Skip to content

Commit

Permalink
Add short plugin description to each plugin under title (#3268)
Browse files Browse the repository at this point in the history
* plugin descriptions

* changes based on code review

* update change log entry

* review

* search on plugin description

* search on plugin description text

* tighten padding around new plugin descriptions

* small fix

---------

Co-authored-by: Kyle Conroy <[email protected]>
  • Loading branch information
cshanahan1 and kecnry authored Nov 14, 2024
1 parent 72ed856 commit f715ffe
Show file tree
Hide file tree
Showing 55 changed files with 202 additions and 34 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ Specviz2d

Other Changes and Additions
---------------------------
- Added a short description of each plugin in the side menu, visible before the plugin is opened. Removes redundant descriptions above link
out to documentation when plugin is opened. Enable search on plugin description in addition to title. [#3268]

4.0.1 (unreleased)
==================
Expand Down
4 changes: 4 additions & 0 deletions jdaviz/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2762,6 +2762,7 @@ def compose_viewer_area(viewer_area_items):
self._application_handler._tools[name] = tool

for name in config.get('tray', []):

tray = tray_registry.members.get(name)

tray_item_instance = tray.get('cls')(app=self, tray_instance=True)
Expand All @@ -2770,10 +2771,13 @@ def compose_viewer_area(viewer_area_items):
# plugin itself
tray_item_label = tray.get('label')

tray_item_description = tray_item_instance.plugin_description

# NOTE: is_relevant is later updated by observing irrelevant_msg traitlet
self.state.tray_items.append({
'name': name,
'label': tray_item_label,
'tray_item_description': tray_item_description,
'is_relevant': len(tray_item_instance.irrelevant_msg) == 0,
'widget': "IPY_MODEL_" + tray_item_instance.model_id
})
Expand Down
29 changes: 24 additions & 5 deletions jdaviz/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,17 @@
<v-expansion-panels accordion multiple focusable flat tile v-model="state.tray_items_open">
<v-expansion-panel v-for="(trayItem, index) in state.tray_items" :key="index">
<div v-if="trayItem.is_relevant && trayItemVisible(trayItem, state.tray_items_filter)">
<v-expansion-panel-header >
<j-tooltip :tipid="trayItem.name">
{{ trayItem.label }}
</j-tooltip>
<v-expansion-panel-header class="plugin-header">
<v-list-item style="display: grid; min-height: 6px" class="plugin-title">
<v-list-item-title>
<j-tooltip :tipid="trayItem.name">
{{ trayItem.label }}
</j-tooltip>
</v-list-item-title>
<v-list-item-subtitle style="white-space: normal; font-size: 8pt">
{{ trayItem.tray_item_description }}
</v-list-item-subtitle>
</v-list-item>
</v-expansion-panel-header>
<v-expansion-panel-content style="margin-left: -12px; margin-right: -12px;">
<jupyter-widget v-if="state.tray_items_open.includes(index)" :widget="trayItem.widget"></jupyter-widget>
Expand Down Expand Up @@ -174,7 +181,7 @@ export default {
return true
}
// simple exact text search match on the plugin title for now.
return trayItem.label.toLowerCase().indexOf(tray_items_filter.toLowerCase()) !== -1
return trayItem.label.toLowerCase().indexOf(tray_items_filter.toLowerCase()) !== -1 || trayItem.tray_item_description.toLowerCase().indexOf(tray_items_filter.toLowerCase()) !== -1
},
onLayoutChange() {
/* Workaround for #1677, can be removed when bqplot/bqplot#1531 is released */
Expand All @@ -191,3 +198,15 @@ export default {
}
};
</script>

<style scoped>
.plugin-header.v-expansion-panel-header {
padding-top: 8px;
padding-bottom: 8px;
padding-left: 4px;
padding-right: 12px;
}
.plugin-title.v-list-item:after {
display: none !important;
}
</style>
3 changes: 3 additions & 0 deletions jdaviz/configs/cubeviz/plugins/moment_maps/moment_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ class MomentMap(PluginTemplateMixin, DatasetSelectMixin, SpectralSubsetSelectMix
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

# description displayed under plugin title in tray
self._plugin_description = 'Create a 2D image from a data cube.'

self.moment = None

self.continuum_dataset = DatasetSelect(self,
Expand Down
2 changes: 1 addition & 1 deletion jdaviz/configs/cubeviz/plugins/moment_maps/moment_maps.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
:config="config"
plugin_key="Moment Maps"
:api_hints_enabled.sync="api_hints_enabled"
:description="docs_description || 'Create a 2D image from a data cube.'"
:description="docs_description"
:link="docs_link || 'https://jdaviz.readthedocs.io/en/'+vdocs+'/'+config+'/plugins.html#moment-maps'"
:uses_active_status="uses_active_status"
@plugin-ping="plugin_ping($event)"
Expand Down
7 changes: 7 additions & 0 deletions jdaviz/configs/cubeviz/plugins/slice/slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ class Slice(PluginTemplateMixin):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

# description displayed under plugin title in tray
self._plugin_description = 'Select and interact with slice of cube in image viewers.'

self._cached_properties = ['valid_selection_values', 'valid_selection_values_sorted',
'valid_indicator_values', 'valid_indicator_values_sorted',
'valid_values', 'valid_values_sorted']
Expand Down Expand Up @@ -103,6 +107,9 @@ def __init__(self, *args, **kwargs):
handler=self._on_global_display_unit_changed)
self._initialize_location()

self.docs_description = 'The slice can also be changed interactively\
in the spectrum viewer by activating the slice tool.'

@property
def _cube_viewer_default_label(self):
if hasattr(self.app, '_jdaviz_helper') and self.app._jdaviz_helper is not None:
Expand Down
2 changes: 1 addition & 1 deletion jdaviz/configs/cubeviz/plugins/slice/slice.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
:config="config"
:plugin_key="plugin_key || 'Slice'"
:api_hints_enabled.sync="api_hints_enabled"
:description="docs_description || 'Select slice of the cube to show in the image viewers. The slice can also be changed interactively in the spectrum viewer by activating the slice tool.'"
:description="docs_description"
:irrelevant_msg="irrelevant_msg"
:link="docs_link || 'https://jdaviz.readthedocs.io/en/'+vdocs+'/'+config+'/plugins.html#slice'"
:popout_button="popout_button"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ class SpectralExtraction(PluginTemplateMixin, ApertureSubsetSelectMixin,
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

# description displayed under plugin title in tray
self._plugin_description = 'Extract a spectrum from a spectral cube.'

self.extracted_spec = None

self.dataset.filters = ['is_flux_cube']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
:config="config"
:plugin_key="plugin_key || 'Spectral Extraction'"
:api_hints_enabled.sync="api_hints_enabled"
:description="docs_description || 'Extract a '+resulting_product_name+' from a spectral cube.'"
:description="docs_description"
:link="docs_link || 'https://jdaviz.readthedocs.io/en/'+vdocs+'/'+config+'/plugins.html#spectral-extraction'"
:uses_active_status="uses_active_status"
@plugin-ping="plugin_ping($event)"
Expand Down
3 changes: 3 additions & 0 deletions jdaviz/configs/default/plugins/about/about.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.jdaviz_version = __version__

# description displayed under plugin title in tray
self._plugin_description = 'Information about Jdaviz.'

if __version__ != "unknown":
_ver_pypi = latest_version_from_pypi("jdaviz")
if _ver_pypi:
Expand Down
2 changes: 1 addition & 1 deletion jdaviz/configs/default/plugins/about/about.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<j-tray-plugin
:description="docs_description || 'About Jdaviz.'"
:description="docs_description"
:link="docs_link || 'https://jdaviz.readthedocs.io/en/'+vdocs+'/'"
:popout_button="popout_button"
:scroll_to.sync="scroll_to">
Expand Down
3 changes: 3 additions & 0 deletions jdaviz/configs/default/plugins/collapse/collapse.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ def __init__(self, *args, **kwargs):
# on the user's machine, so export support in cubeviz should be disabled
self.export_enabled = False

# description displayed under plugin title in tray
self._plugin_description = 'Collapse a spectral cube along one axis.'

@property
def _default_spectrum_viewer_reference_name(self):
return self.jdaviz_helper._default_spectrum_viewer_reference_name
Expand Down
2 changes: 1 addition & 1 deletion jdaviz/configs/default/plugins/collapse/collapse.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
:config="config"
plugin_key="Collapse"
:api_hints_enabled.sync="api_hints_enabled"
:description="docs_description || 'Collapse a spectral cube along one axis.'"
:description="docs_description"
:link="docs_link || 'https://jdaviz.readthedocs.io/en/'+vdocs+'/'+config+'/plugins.html#collapse'"
:popout_button="popout_button"
:scroll_to.sync="scroll_to">
Expand Down
4 changes: 4 additions & 0 deletions jdaviz/configs/default/plugins/data_quality/data_quality.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ class DataQuality(PluginTemplateMixin, ViewerSelectMixin):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

# description displayed under plugin title in tray
self._plugin_description = 'Data Quality layer visualization options.'

self.icons = {k: v for k, v in self.app.state.icons.items()}

self.science_layer = LayerSelect(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
:config="config"
plugin_key="Data Quality"
:api_hints_enabled.sync="api_hints_enabled"
:description="docs_description || 'Data Quality layer visualization options.'"
:description="docs_description'"
:link="docs_link || 'https://jdaviz.readthedocs.io/en/'+vdocs+'/'+config+'/plugins.html#data-quality'"
@plugin-ping="plugin_ping($event)"
:popout_button="popout_button">
Expand Down
4 changes: 4 additions & 0 deletions jdaviz/configs/default/plugins/export/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from jdaviz.core.events import AddDataMessage, SnackbarMessage
from jdaviz.core.user_api import PluginUserApi

from specutils import Spectrum1D
from astropy import units as u
from astropy.nddata import CCDData
Expand Down Expand Up @@ -115,6 +116,9 @@ def __init__(self, *args, **kwargs):
'filename_auto',
'filename_invalid_msg')

# description displayed under plugin title in tray
self._plugin_description = 'Export data/plots and other outputs to a file.'

# NOTE: if adding export support for non-plugin products, also update the language
# in the UI as well as in _set_dataset_not_supported_msg
self.dataset.filters = ['is_not_wcs_only', 'not_child_layer',
Expand Down
2 changes: 1 addition & 1 deletion jdaviz/configs/default/plugins/export/export.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
:config="config"
plugin_key="Export"
:api_hints_enabled.sync="api_hints_enabled"
description='Export data or plots from the app to a file.'
:description="docs_description"
:link="docs_link || 'https://jdaviz.readthedocs.io/en/'+vdocs+'/'+config+'/plugins.html#export'"
:popout_button="popout_button"
:scroll_to.sync="scroll_to">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ def __init__(self, *args, **kwargs):
# set the filter on the dataset and viewer options
self._update_dataset_viewer_filters()

# description displayed under plugin title in tray
self._plugin_description = 'Smooth data with a Gaussian kernel.'

@property
def _default_spectrum_viewer_reference_name(self):
return getattr(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
:config="config"
plugin_key="Gaussian Smooth"
:api_hints_enabled.sync="api_hints_enabled"
:description="docs_description || 'Smooth data with a Gaussian kernel.'"
:description="docs_description"
:link="docs_link || 'https://jdaviz.readthedocs.io/en/'+vdocs+'/'+config+'/plugins.html#gaussian-smooth'"
:popout_button="popout_button"
:scroll_to.sync="scroll_to">
Expand Down
3 changes: 3 additions & 0 deletions jdaviz/configs/default/plugins/line_lists/line_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ def __init__(self, *args, **kwargs):

self._disable_if_no_data()

# description displayed under plugin title in tray
self._plugin_description = 'Plot spectral lines from preset or custom line lists.'

@property
def _default_spectrum_viewer_reference_name(self):
return getattr(
Expand Down
2 changes: 1 addition & 1 deletion jdaviz/configs/default/plugins/line_lists/line_lists.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<j-tray-plugin
:description="docs_description || 'Plot lines from preset or custom line lists.'"
:description="docs_description"
:link="docs_link || 'https://jdaviz.readthedocs.io/en/'+vdocs+'/'+config+'/plugins.html#line-lists'"
:disabled_msg="disabled_msg"
:popout_button="popout_button"
Expand Down
9 changes: 9 additions & 0 deletions jdaviz/configs/default/plugins/markers/markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@ def __init__(self, *args, **kwargs):
self.hub.subscribe(self, RemoveDataMessage,
handler=lambda msg: self._recompute_mark_positions(msg.viewer))

self.docs_description = "Press 'm' with the cursor over a viewer to log\
the mouseover information. To change the\
selected layer, click the layer cycler in the\
mouseover information section of the app-level\
toolbar."

# description displayed under plugin title in tray
self._plugin_description = 'Create markers on viewers.'

def _create_viewer_callbacks(self, viewer):
if not self.is_active:
return
Expand Down
2 changes: 1 addition & 1 deletion jdaviz/configs/default/plugins/markers/markers.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<j-tray-plugin
:config="config"
plugin_key="Markers"
:description="docs_description || 'Create and export markers. Press m with the cursor over a viewer to log the mouseover information. To change the selected layer, click the layer cycler in the mouseover information section of the app-level toolbar.'"
:description="docs_description"
:link="docs_link || 'https://jdaviz.readthedocs.io/en/'+vdocs+'/'+config+'/plugins.html#markers'"
:uses_active_status="uses_active_status"
@plugin-ping="plugin_ping($event)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class MetadataViewer(PluginTemplateMixin, DatasetSelectMixin):
:ref:`public plugin API <plugin-apis>`:
* :meth:`~jdaviz.core.template_mixin.PluginTemplateMixin.show`
* :meth:`~jdaviz.core.template_mixin.PluginTemplateMixin.open_in_tray`
* :meth:`~jdaviz.core.template_mixin.PluginTemplateMixin.open_in_tray`
* :meth:`~jdaviz.core.template_mixin.PluginTemplateMixin.close_in_tray`
* ``dataset`` (:class:`~jdaviz.core.template_mixin.DatasetSelect`):
Dataset to expose the metadata.
Expand All @@ -42,6 +42,9 @@ def __init__(self, *args, **kwargs):
# override the default filters on dataset entries to require metadata in entries
self.dataset.add_filter('not_from_plugin')

# description displayed under plugin title in tray
self._plugin_description = 'View metadata.'

@property
def user_api(self):
return PluginUserApi(self, expose=('dataset', 'show_primary'), readonly=('metadata',))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
:config="config"
plugin_key="Metadata"
:api_hints_enabled.sync="api_hints_enabled"
:description="docs_description || 'View metadata.'"
:description="docs_description"
:link="docs_link || 'https://jdaviz.readthedocs.io/en/'+vdocs+'/'+config+'/plugins.html#metadata-viewer'"
:popout_button="popout_button"
:scroll_to.sync="scroll_to">
Expand Down
3 changes: 3 additions & 0 deletions jdaviz/configs/default/plugins/model_fitting/model_fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ def __init__(self, *args, **kwargs):
self._initialized_models = {}
self._display_order = False

# description displayed under plugin title in tray
self._plugin_description = 'Fit an analytic model to data or a subset of data.'

# create the label first so that when model_component defaults to the first selection,
# the label automatically defaults as well
self.model_component_label = AutoTextField(self, 'comp_label', 'comp_label_default',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
:config="config"
plugin_key="Model Fitting"
:api_hints_enabled.sync="api_hints_enabled"
:description="docs_description || 'Fit an analytic model to data or a subset.'"
:description="docs_description"
:link="docs_link || 'https://jdaviz.readthedocs.io/en/'+vdocs+'/'+config+'/plugins.html#model-fitting'"
:popout_button="popout_button"
:scroll_to.sync="scroll_to">
Expand Down
4 changes: 4 additions & 0 deletions jdaviz/configs/default/plugins/plot_options/plot_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,10 @@ class PlotOptions(PluginTemplateMixin, ViewerSelectMixin):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

# description displayed under plugin title in tray
self._plugin_description = 'Set viewer and layer display options.'

self.layer = LayerSelect(self, 'layer_items', 'layer_selected',
'viewer_selected', 'layer_multiselect')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
:config="config"
plugin_key="Plot Options"
:api_hints_enabled.sync="api_hints_enabled"
:description="docs_description || 'Viewer and data/layer options.'"
:description="docs_description"
:link="docs_link || 'https://jdaviz.readthedocs.io/en/'+vdocs+'/'+config+'/plugins.html#plot-options'"
:uses_active_status="uses_active_status"
@plugin-ping="plugin_ping($event)"
Expand Down
9 changes: 9 additions & 0 deletions jdaviz/configs/default/plugins/subset_plugin/subset_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@ class SubsetPlugin(PluginTemplateMixin, DatasetSelectMixin):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

# description displayed under plugin title in tray
config = self.app.config
if config in ['cubeviz', 'specviz2d', 'mosviz', 'rampviz']:
self._plugin_description = 'Select and interact with spectral/spatial subsets.'
elif config == 'imviz':
self._plugin_description = 'Select and interact with spatial subsets.'
elif config == 'specviz':
self._plugin_description = 'Select and interact with spectral subsets.'

self.components = {
'g-subset-mode': SelectionModeMenu(session=self.session)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<j-tray-plugin
:description="docs_description || 'Tools for selecting and interacting with subsets.'"
:description="docs_description"
:link="docs_link || 'https://jdaviz.readthedocs.io/en/'+vdocs+'/'+config+'/plugins.html#subset-tools'"
:popout_button="popout_button"
:scroll_to.sync="scroll_to">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ class SimpleAperturePhotometry(PluginTemplateMixin, ApertureSubsetSelectMixin,
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

# description displayed under plugin title in tray
self._plugin_description = 'Perform aperture photometry for drawn regions.'

self.background = SubsetSelect(self,
'background_items',
'background_selected',
Expand Down
Loading

0 comments on commit f715ffe

Please sign in to comment.