Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions jupyterlab_gallery/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def get(self):
{
"title": self.gallery_manager.title,
"exhibitsConfigured": len(self.gallery_manager.exhibits) != 0,
"hideGalleryWithoutExhibits": self.gallery_manager.hideGalleryWithoutExhibits,
"apiVersion": "1.0",
}
)
Expand Down
8 changes: 7 additions & 1 deletion jupyterlab_gallery/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from threading import Thread

from traitlets.config.configurable import LoggingConfigurable
from traitlets import Dict, List, Unicode
from traitlets import Dict, List, Unicode, Bool

from .git_utils import (
extract_repository_owner,
Expand Down Expand Up @@ -69,6 +69,12 @@ def __init__(self, *args, **kwargs):
config=True,
)

hideGalleryWithoutExhibits = Bool(
help="Hide Gallery if not exhibits are configured",
default_value=False,
config=True
)

def get_local_path(self, exhibit) -> Path:
clone_destination = Path(self.destination)
repository_name = extract_repository_name(exhibit["git"])
Expand Down
6 changes: 5 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,12 @@ const plugin: JupyterFrontEndPlugin<void> = {
`jupyter-gallery API version out of sync, expected ${expectedVersion}, got ${data.apiVersion}`
);
}

const title = data.title === 'Gallery' ? trans.__('Gallery') : data.title;

// hide the widget if no exhibits are configured
if (data.hideGalleryWithoutExhibits && !data.exhibitsConfigured) {
return;
}
// add the widget to sidebar before waiting for server reply to reduce UI jitter
if (launcher && isNewLauncher(launcher) && data.exhibitsConfigured) {
launcher.addSection({
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export interface IGalleryReply {
title: string;
apiVersion: string;
exhibitsConfigured: boolean;
hideGalleryWithoutExhibits: boolean;
}

export interface IExhibitReply {
Expand Down