From d398e7c3dcaf461b53a96ca953ee4b3e79829e28 Mon Sep 17 00:00:00 2001 From: Noha Ihab <49988746+NohaIhab@users.noreply.github.com> Date: Thu, 25 Jul 2024 00:52:48 +0300 Subject: [PATCH] chore: bump dashboard links lib (#390) --- .../v0/kubeflow_dashboard_links.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/charms/jupyter-ui/lib/charms/kubeflow_dashboard/v0/kubeflow_dashboard_links.py b/charms/jupyter-ui/lib/charms/kubeflow_dashboard/v0/kubeflow_dashboard_links.py index 498f607e..9ab3e819 100644 --- a/charms/jupyter-ui/lib/charms/kubeflow_dashboard/v0/kubeflow_dashboard_links.py +++ b/charms/jupyter-ui/lib/charms/kubeflow_dashboard/v0/kubeflow_dashboard_links.py @@ -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'] @@ -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`. """ @@ -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.""" @@ -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)):