fix: make workspace tooltips actionable (#11700)

This commit is contained in:
Marcin Tojek 2024-01-19 15:17:02 +01:00 committed by GitHub
parent 200a87e7d4
commit 4b059c4c93
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 13 additions and 5 deletions

View File

@ -83,7 +83,7 @@ export const WorkspaceActions: FC<WorkspaceActionsProps> = ({
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<WorkspaceActionsProps> = ({
);
};
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 "";