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

chore: bump dashboard links lib #183

Merged
merged 2 commits into from
Jul 24, 2024
Merged
Changes from all 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
15 changes: 11 additions & 4 deletions lib/charms/kubeflow_dashboard/v0/kubeflow_dashboard_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def __init__(self, *args):

# Increment this PATCH version before using `charmcraft publish-lib` or reset
# to 0 if you are raising the major API version
LIBPATCH = 2
LIBPATCH = 3


DASHBOARD_LINK_LOCATIONS = ['menu', 'external', 'quick', 'documentation']
Expand All @@ -90,12 +90,12 @@ class DashboardLink:

Args:
text: The text shown for the link
link: The link (a relative link for `location=sidebar` or `location=quick`, eg: `/mlflow`,
link: The link (a relative link for `location=menu` or `location=quick`, eg: `/mlflow`,
or a full URL for other locations, eg: http://my-website.com)
type: A type of sidebar entry (typically, "item")
type: A type of link entry (typically, "item")
icon: An icon for the link, from
https://kevingleason.me/Polymer-Todo/bower_components/iron-icons/demo/index.html
location: Link's location on the dashboard. One of `sidebar`, `sidebar_external`, `quick`,
location: Link's location on the dashboard. One of `menu`, `external`, `quick`,
and `documentation`.
"""

Expand All @@ -106,6 +106,11 @@ class DashboardLink:
type: str = "item" # noqa: A003
desc: str = ""

def __post_init__(self):
"""Validate that location is one of the accepted values."""
if self.location not in DASHBOARD_LINK_LOCATIONS:
raise ValueError(f"location must be one of {DASHBOARD_LINK_LOCATIONS} - got '{self.location}'.")


class KubeflowDashboardLinksUpdatedEvent(RelationEvent):
"""Indicates the Kubeflow Dashboard link data was updated."""
Expand Down Expand Up @@ -287,6 +292,8 @@ def __init__(
self._charm.on[self._relation_name].relation_created, self._on_send_data
)

self.framework.observe(self._charm.on.upgrade_charm, self._on_send_data)

# apply user defined events
if refresh_event:
if not isinstance(refresh_event, (tuple, list)):
Expand Down
Loading