Skip to content

Commit

Permalink
allow downstream apps to set links to docs (#2392)
Browse files Browse the repository at this point in the history
* allow downstream apps to set links to doc (question button in top app bar)
  • Loading branch information
kecnry authored Aug 23, 2023
1 parent eef4f64 commit bbcdcc8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
10 changes: 8 additions & 2 deletions jdaviz/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
from jdaviz.utils import SnackbarQueue, alpha_index
from ipypopout import PopoutButton

__all__ = ['Application']
__all__ = ['Application', 'ALL_JDAVIZ_CONFIGS']

SplitPanes()
GoldenLayout()
Expand All @@ -67,6 +67,7 @@
EXT_TYPES = dict(flux=['flux', 'sci'],
uncert=['ivar', 'err', 'var', 'uncert'],
mask=['mask', 'dq'])
ALL_JDAVIZ_CONFIGS = ['cubeviz', 'specviz', 'specviz2d', 'mosviz', 'imviz']


@unit_converter('custom-jdaviz')
Expand Down Expand Up @@ -247,6 +248,7 @@ class Application(VuetifyTemplate, HubListener):
loading = Bool(False).tag(sync=True)
config = Unicode("").tag(sync=True)
vdocs = Unicode("").tag(sync=True)
docs_link = Unicode("").tag(sync=True)
popout_button = Any().tag(sync=True, **widget_serialization)

def __init__(self, configuration=None, *args, **kwargs):
Expand Down Expand Up @@ -2252,8 +2254,12 @@ def load_configuration(self, path=None, config=None):
# store the loaded config object
self._loaded_configuration = config
# give the vue templates access to the current config/layout
self.config = config['settings'].get('configuration', 'unknown')
self.config = config['settings'].get('configuration', 'unknown').lower()
self.vdocs = 'latest' if 'dev' in __version__ else 'v'+__version__
if self.config in ALL_JDAVIZ_CONFIGS:
self.docs_link = f'https://jdaviz.readthedocs.io/en/{self.vdocs}/{self.config}/index.html' # noqa
else:
self.docs_link = 'https://jdaviz.readthedocs.io'

self.state.settings.update(config.get('settings'))

Expand Down
9 changes: 1 addition & 8 deletions jdaviz/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<jupyter-widget :widget="popout_button" ></jupyter-widget>
</j-tooltip>
<j-tooltip tipid="app-help">
<v-btn icon :href="getReadTheDocsLink()" target="_blank">
<v-btn icon :href="docs_link" target="_blank">
<v-icon medium>mdi-help-box</v-icon>
</v-btn>
</j-tooltip>
Expand Down Expand Up @@ -170,13 +170,6 @@ export default {
|| document.querySelector('.jp-LabShell');
return this.notebook_context;
},
getReadTheDocsLink() {
if (['specviz', 'specviz2d', 'cubeviz', 'mosviz', 'imviz'].indexOf(this.config) !== -1) {
return 'https://jdaviz.readthedocs.io/en/'+this.vdocs+'/'+this.config+'/index.html'
} else {
return 'https://jdaviz.readthedocs.io'
}
},
trayItemVisible(trayItem, tray_items_filter) {
if (tray_items_filter === null || tray_items_filter.length == 0) {
return true
Expand Down
3 changes: 1 addition & 2 deletions jdaviz/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from voila.configuration import VoilaConfiguration

from jdaviz import __version__
from jdaviz.app import _verbosity_levels
from jdaviz.app import _verbosity_levels, ALL_JDAVIZ_CONFIGS
from jdaviz import configs

__all__ = ['main']
Expand All @@ -19,7 +19,6 @@
JDAVIZ_DIR = pathlib.Path(__file__).parent.resolve()
DEFAULT_VERBOSITY = 'warning'
DEFAULT_HISTORY_VERBOSITY = 'info'
ALL_JDAVIZ_CONFIGS = ['cubeviz', 'specviz', 'specviz2d', 'mosviz', 'imviz']


def main(filepaths=None, layout='default', instrument=None, browser='default',
Expand Down

0 comments on commit bbcdcc8

Please sign in to comment.