Fix UI bug where "Script is already running" tooltip incorrectly displayed when script is not running (#20384)

This commit is contained in:
Sarah Gillespie 2024-07-11 12:37:36 -05:00 committed by GitHub
parent a410f330b9
commit 24303c6670
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 11 deletions

View file

@ -0,0 +1 @@
- Fixed UI issue where "Script is already running" tooltip incorrectly displayed when the script is not running.

View file

@ -1,8 +1,4 @@
import React from "react";
import ReactTooltip from "react-tooltip";
import { noop } from "lodash";
import { COLORS } from "styles/var/colors";
import { IDropdownOption } from "interfaces/dropdownOption";
import { IHostScript, ILastExecution } from "interfaces/script";
@ -42,6 +38,7 @@ const generateActionDropdownOptions = (
teamId: number | null,
{ last_execution }: IHostScript
): IDropdownOption[] => {
const isPending = last_execution?.status === "pending";
const hasRunPermission =
!!currentUser &&
(isGlobalAdmin(currentUser) ||
@ -58,14 +55,15 @@ const generateActionDropdownOptions = (
disabled: last_execution === null,
value: "showDetails",
},
{
label: "Run",
disabled: last_execution?.status === "pending",
value: "run",
tooltipContent: "Script is already running.",
},
];
return hasRunPermission ? options : options.slice(0, 1);
hasRunPermission &&
options.push({
label: "Run",
disabled: isPending,
value: "run",
tooltipContent: isPending ? "Script is already running." : undefined,
});
return options;
};
// eslint-disable-next-line import/prefer-default-export