mirror of
https://github.com/fleetdm/fleet
synced 2026-05-23 17:08:53 +00:00
Fix UI bug where "Script is already running" tooltip incorrectly displayed when script is not running (#20384)
This commit is contained in:
parent
a410f330b9
commit
24303c6670
2 changed files with 10 additions and 11 deletions
1
changes/20293-script-pending-tooltip
Normal file
1
changes/20293-script-pending-tooltip
Normal file
|
|
@ -0,0 +1 @@
|
|||
- Fixed UI issue where "Script is already running" tooltip incorrectly displayed when the script is not running.
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue