From bccd1d99212bd6d0a442cac10340b9e5bff37ddf Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Fri, 19 Jan 2024 14:55:42 +0100 Subject: [PATCH] fix: make workspace tooltips actionable --- .../WorkspaceActions/WorkspaceActions.tsx | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/site/src/pages/WorkspacePage/WorkspaceActions/WorkspaceActions.tsx b/site/src/pages/WorkspacePage/WorkspaceActions/WorkspaceActions.tsx index 1c57e85d7de01..dbac824a8b8e9 100644 --- a/site/src/pages/WorkspacePage/WorkspaceActions/WorkspaceActions.tsx +++ b/site/src/pages/WorkspacePage/WorkspaceActions/WorkspaceActions.tsx @@ -83,7 +83,7 @@ export const WorkspaceActions: FC = ({ workspaceUpdatePolicy(workspace, canChangeVersions) === "always" && workspace.outdated; - const tooltipText = getTooltipText(workspace, mustUpdate); + const tooltipText = getTooltipText(workspace, mustUpdate, canChangeVersions); const canBeUpdated = workspace.outdated && canAcceptJobs; // A mapping of button type to the corresponding React component @@ -202,17 +202,25 @@ export const WorkspaceActions: FC = ({ ); }; -function getTooltipText(workspace: Workspace, disabled: boolean): string { - if (!disabled) { +function getTooltipText( + workspace: Workspace, + mustUpdate: boolean, + canChangeVersions: boolean, +): string { + if (!mustUpdate && !canChangeVersions) { return ""; } + if (!mustUpdate && canChangeVersions) { + return "This template requires automatic updates on workspace startup, but template administrators can ignore this policy."; + } + if (workspace.template_require_active_version) { - return "This template requires automatic updates"; + return "This template requires automatic updates on workspace startup. Contact your administrator if you want to preserve the template version."; } if (workspace.automatic_updates === "always") { - return "You have enabled automatic updates for this workspace"; + return "Automatic updates are enabled for this workspace. Modify the update policy in workspace settings if you want to preserve the template version."; } return "";