From 13e5e14a2f98059c903bf0770d6d4921d2d62729 Mon Sep 17 00:00:00 2001 From: Sarah Gillespie <73313222+gillespi314@users.noreply.github.com> Date: Wed, 31 Jul 2024 10:03:10 -0500 Subject: [PATCH] Update UI to allow for showing software install details from activities related to deleted hosts (#20866) --- .../AppInstallDetails/AppInstallDetails.tsx | 11 ++++-- .../SoftwareInstallDetails.tsx | 37 +++++++++++++------ .../cards/ActivityFeed/ActivityFeed.tsx | 16 ++++---- .../HostDetailsPage/HostDetailsPage.tsx | 18 ++++++--- .../SoftwareDetailsModal.tsx | 3 +- 5 files changed, 57 insertions(+), 28 deletions(-) diff --git a/frontend/components/ActivityDetails/InstallDetails/AppInstallDetails/AppInstallDetails.tsx b/frontend/components/ActivityDetails/InstallDetails/AppInstallDetails/AppInstallDetails.tsx index c4991f0fd7..dd1de5a727 100644 --- a/frontend/components/ActivityDetails/InstallDetails/AppInstallDetails/AppInstallDetails.tsx +++ b/frontend/components/ActivityDetails/InstallDetails/AppInstallDetails/AppInstallDetails.tsx @@ -90,6 +90,12 @@ export const AppInstallDetails = ({ subordinate = status === "pending" ? " when it comes online" : ""; } + const formattedHost = host_display_name ? ( + {host_display_name} + ) : ( + "the host" + ); + const showCommandResponse = isStatusNotNow || status !== "pending"; return ( @@ -98,8 +104,7 @@ export const AppInstallDetails = ({
{!!iconName && } - Fleet {predicate} {software_title} on{" "} - {host_display_name} + Fleet {predicate} {software_title} on {formattedHost} {subordinate}.
@@ -111,7 +116,7 @@ export const AppInstallDetails = ({ {showCommandResponse && (
- The response from {host_display_name}: + The response from {formattedHost}: diff --git a/frontend/components/ActivityDetails/InstallDetails/SoftwareInstallDetails/SoftwareInstallDetails.tsx b/frontend/components/ActivityDetails/InstallDetails/SoftwareInstallDetails/SoftwareInstallDetails.tsx index 27480cd8e5..61c2d5f04f 100644 --- a/frontend/components/ActivityDetails/InstallDetails/SoftwareInstallDetails/SoftwareInstallDetails.tsx +++ b/frontend/components/ActivityDetails/InstallDetails/SoftwareInstallDetails/SoftwareInstallDetails.tsx @@ -1,6 +1,7 @@ import React from "react"; import { useQuery } from "react-query"; +import { IActivityDetails } from "interfaces/activity"; import { ISoftwareInstallResult, ISoftwareInstallResults, @@ -21,17 +22,28 @@ import { const baseClass = "software-install-details"; +// TODO: Expand to include more details as needed +export type IPackageInstallDetails = Pick< + IActivityDetails, + "install_uuid" | "host_display_name" +>; + const StatusMessage = ({ result: { host_display_name, software_package, software_title, status }, }: { result: ISoftwareInstallResult; }) => { + const formattedHost = host_display_name ? ( + {host_display_name} + ) : ( + "the host" + ); return (
Fleet {getInstallDetailsStatusPredicate(status)} {software_title}{" "} - ({software_package}) on {host_display_name} + ({software_package}) on {formattedHost} {status === "pending" ? " when it comes online" : ""}.
@@ -56,18 +68,17 @@ const Output = ({ }; export const SoftwareInstallDetails = ({ - installUuid, -}: { - installUuid: string; -}) => { + host_display_name = "", + install_uuid = "", +}: IPackageInstallDetails) => { const { data: result, isLoading, isError } = useQuery< ISoftwareInstallResults, Error, ISoftwareInstallResult >( - ["softwareInstallResults", installUuid], + ["softwareInstallResults", install_uuid], () => { - return softwareAPI.getSoftwareInstallResult(installUuid); + return softwareAPI.getSoftwareInstallResult(install_uuid); }, { refetchOnWindowFocus: false, @@ -88,7 +99,11 @@ export const SoftwareInstallDetails = ({ return ( <>
- + {result.status !== "pending" && ( <> {result.pre_install_query_output && ( @@ -106,10 +121,10 @@ export const SoftwareInstallDetails = ({ }; export const SoftwareInstallDetailsModal = ({ - installUuid, + details, onCancel, }: { - installUuid: string; + details: IPackageInstallDetails; onCancel: () => void; }) => { return ( @@ -121,7 +136,7 @@ export const SoftwareInstallDetailsModal = ({ > <>
- +