mirror of
https://github.com/fleetdm/fleet
synced 2026-05-23 08:58:41 +00:00
Fleet UI: Host details activity script package uses correct modal (#35050)
This commit is contained in:
parent
b8f1a816aa
commit
9f174b7cdc
4 changed files with 46 additions and 25 deletions
|
|
@ -193,7 +193,7 @@ interface ISoftwareInstallDetailsProps {
|
|||
contactUrl?: string; // My Device Page only
|
||||
}
|
||||
|
||||
export const SoftwareInstallDetailsModal = ({
|
||||
export const SoftwareScriptDetailsModal = ({
|
||||
details: detailsFromProps,
|
||||
onCancel,
|
||||
hostSoftware,
|
||||
|
|
@ -341,4 +341,4 @@ export const SoftwareInstallDetailsModal = ({
|
|||
);
|
||||
};
|
||||
|
||||
export default SoftwareInstallDetailsModal;
|
||||
export default SoftwareScriptDetailsModal;
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import { IQueryStats } from "interfaces/query_stats";
|
|||
import {
|
||||
IHostSoftware,
|
||||
resolveUninstallStatus,
|
||||
SCRIPT_PACKAGE_SOURCES,
|
||||
SoftwareInstallUninstallStatus,
|
||||
} from "interfaces/software";
|
||||
import { ITeam } from "interfaces/team";
|
||||
|
|
@ -78,6 +79,7 @@ import {
|
|||
SoftwareInstallDetailsModal,
|
||||
IPackageInstallDetails,
|
||||
} from "components/ActivityDetails/InstallDetails/SoftwareInstallDetailsModal/SoftwareInstallDetailsModal";
|
||||
import { SoftwareScriptDetailsModal } from "components/ActivityDetails/InstallDetails/SoftwareScriptDetailsModal/SoftwareScriptDetailsModal";
|
||||
import {
|
||||
SoftwareIpaInstallDetailsModal,
|
||||
ISoftwareIpaInstallDetails,
|
||||
|
|
@ -226,6 +228,10 @@ const HostDetailsPage = ({
|
|||
packageInstallDetails,
|
||||
setPackageInstallDetails,
|
||||
] = useState<IPackageInstallDetails | null>(null);
|
||||
const [
|
||||
scriptPackageDetails,
|
||||
setScriptPackageDetails,
|
||||
] = useState<IPackageInstallDetails | null>(null);
|
||||
const [
|
||||
ipaPackageInstallDetails,
|
||||
setIpaPackageInstallDetails,
|
||||
|
|
@ -689,22 +695,33 @@ const HostDetailsPage = ({
|
|||
setScriptExecutiontId(details?.script_execution_id || "");
|
||||
break;
|
||||
case "installed_software":
|
||||
details?.command_uuid
|
||||
? setIpaPackageInstallDetails({
|
||||
fleetInstallStatus: details?.status as SoftwareInstallUninstallStatus,
|
||||
hostDisplayName:
|
||||
host?.display_name || details?.host_display_name || "",
|
||||
appName: details?.name || "",
|
||||
commandUuid: details?.command_uuid,
|
||||
})
|
||||
: setPackageInstallDetails({
|
||||
...details,
|
||||
// FIXME: It seems like the backend is not using the correct display name when it returns
|
||||
// upcoming install activities. As a workaround, we'll prefer the display name from
|
||||
// the host object if it's available.
|
||||
host_display_name:
|
||||
host?.display_name || details?.host_display_name || "",
|
||||
});
|
||||
if (details?.command_uuid) {
|
||||
setIpaPackageInstallDetails({
|
||||
fleetInstallStatus: details?.status as SoftwareInstallUninstallStatus,
|
||||
hostDisplayName:
|
||||
host?.display_name || details?.host_display_name || "",
|
||||
appName: details?.name || "",
|
||||
commandUuid: details?.command_uuid,
|
||||
});
|
||||
} else if (SCRIPT_PACKAGE_SOURCES.includes(details?.source || "")) {
|
||||
setScriptPackageDetails({
|
||||
...details,
|
||||
// FIXME: It seems like the backend is not using the correct display name when it returns
|
||||
// upcoming install activities. As a workaround, we'll prefer the display name from
|
||||
// the host object if it's available.
|
||||
host_display_name:
|
||||
host?.display_name || details?.host_display_name || "",
|
||||
});
|
||||
} else {
|
||||
setPackageInstallDetails({
|
||||
...details,
|
||||
// FIXME: It seems like the backend is not using the correct display name when it returns
|
||||
// upcoming install activities. As a workaround, we'll prefer the display name from
|
||||
// the host object if it's available.
|
||||
host_display_name:
|
||||
host?.display_name || details?.host_display_name || "",
|
||||
});
|
||||
}
|
||||
break;
|
||||
case "uninstalled_software":
|
||||
setPackageUninstallDetails({
|
||||
|
|
@ -1416,6 +1433,12 @@ const HostDetailsPage = ({
|
|||
onCancel={onCancelSoftwareInstallDetailsModal}
|
||||
/>
|
||||
)}
|
||||
{scriptPackageDetails && (
|
||||
<SoftwareScriptDetailsModal
|
||||
details={scriptPackageDetails}
|
||||
onCancel={() => setScriptPackageDetails(null)}
|
||||
/>
|
||||
)}
|
||||
{ipaPackageInstallDetails && (
|
||||
<SoftwareIpaInstallDetailsModal
|
||||
details={{
|
||||
|
|
|
|||
|
|
@ -373,7 +373,7 @@ describe("InstallStatusCell - component", () => {
|
|||
});
|
||||
});
|
||||
|
||||
it("renders 'Failed run' for a payload-free package that failed to run", async () => {
|
||||
it("renders 'Failed' for a payload-free package that failed to run", async () => {
|
||||
const { user } = renderWithSetup(
|
||||
<InstallStatusCell
|
||||
software={{
|
||||
|
|
@ -393,12 +393,10 @@ describe("InstallStatusCell - component", () => {
|
|||
/>
|
||||
);
|
||||
|
||||
expect(
|
||||
screen.getByRole("button", { name: /Failed run/i })
|
||||
).toBeInTheDocument();
|
||||
expect(screen.getByRole("button", { name: /Failed/i })).toBeInTheDocument();
|
||||
expect(screen.getByTestId("error-icon")).toBeInTheDocument();
|
||||
|
||||
await user.hover(screen.getByText(/Failed run/));
|
||||
await user.hover(screen.getByText(/Failed/));
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText(/The script failed to run/i)).toBeInTheDocument();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -294,7 +294,7 @@ export const INSTALL_STATUS_DISPLAY_OPTIONS: Record<
|
|||
},
|
||||
failed_script: {
|
||||
iconName: "error",
|
||||
displayText: "Failed run",
|
||||
displayText: "Failed",
|
||||
tooltip: ({ lastInstalledAt, isSelfService }) => (
|
||||
<>
|
||||
The script failed to run
|
||||
|
|
@ -501,7 +501,7 @@ const InstallStatusCell = ({
|
|||
const displayStatusConfig = [
|
||||
{
|
||||
condition: true, // Allow click even if no last install to see details modal
|
||||
statuses: ["Failed run", "Run (pending)", "Ran"],
|
||||
statuses: ["Failed", "Run (pending)", "Ran"],
|
||||
onClick: onClickScriptStatus,
|
||||
},
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue