From 6551545b3217edb85a519790e5086d0a85a18aa0 Mon Sep 17 00:00:00 2001 From: Gabriel Hernandez Date: Fri, 10 Jan 2025 15:03:53 +0000 Subject: [PATCH] add canceled script and software install activities --- frontend/interfaces/activity.ts | 6 ++++- .../details/cards/Activity/ActivityConfig.tsx | 18 ++++++++------ .../CanceledScriptActivityItem.tsx | 24 +++++++++++++++++++ .../CanceledScriptActivityItem/index.ts | 1 + .../CanceledSoftwareInstallActivityItem.tsx | 21 ++++++++++++++++ .../index.ts | 1 + 6 files changed, 63 insertions(+), 8 deletions(-) create mode 100644 frontend/pages/hosts/details/cards/Activity/ActivityItems/CanceledScriptActivityItem/CanceledScriptActivityItem.tsx create mode 100644 frontend/pages/hosts/details/cards/Activity/ActivityItems/CanceledScriptActivityItem/index.ts create mode 100644 frontend/pages/hosts/details/cards/Activity/ActivityItems/CanceledSoftwareInstallActivityItem/CanceledSoftwareInstallActivityItem.tsx create mode 100644 frontend/pages/hosts/details/cards/Activity/ActivityItems/CanceledSoftwareInstallActivityItem/index.ts diff --git a/frontend/interfaces/activity.ts b/frontend/interfaces/activity.ts index 21235563a61e..e2f9d4797301 100644 --- a/frontend/interfaces/activity.ts +++ b/frontend/interfaces/activity.ts @@ -97,6 +97,8 @@ export enum ActivityType { EnabledActivityAutomations = "enabled_activity_automations", EditedActivityAutomations = "edited_activity_automations", DisabledActivityAutomations = "disabled_activity_automations", + CanceledScript = "canceled_script", + CanceledSoftwareInstall = "canceled_software_install", } /** This is a subset of ActivityType that are shown only for the host past activities */ @@ -106,7 +108,9 @@ export type IHostPastActivityType = | ActivityType.UnlockedHost | ActivityType.InstalledSoftware | ActivityType.UninstalledSoftware - | ActivityType.InstalledAppStoreApp; + | ActivityType.InstalledAppStoreApp + | ActivityType.CanceledScript + | ActivityType.CanceledSoftwareInstall; /** This is a subset of ActivityType that are shown only for the host upcoming activities */ export type IHostUpcomingActivityType = diff --git a/frontend/pages/hosts/details/cards/Activity/ActivityConfig.tsx b/frontend/pages/hosts/details/cards/Activity/ActivityConfig.tsx index 6c2e05211c93..97c60efbef9a 100644 --- a/frontend/pages/hosts/details/cards/Activity/ActivityConfig.tsx +++ b/frontend/pages/hosts/details/cards/Activity/ActivityConfig.tsx @@ -14,18 +14,13 @@ import RanScriptActivityItem from "./ActivityItems/RanScriptActivityItem"; import LockedHostActivityItem from "./ActivityItems/LockedHostActivityItem"; import UnlockedHostActivityItem from "./ActivityItems/UnlockedHostActivityItem"; import InstalledSoftwareActivityItem from "./ActivityItems/InstalledSoftwareActivityItem"; +import CanceledScriptActivityItem from "./ActivityItems/CanceledScriptActivityItem"; +import CanceledSoftwareInstallActivityItem from "./ActivityItems/CanceledSoftwareInstallActivityItem"; /** The component props that all host activity items must adhere to */ export interface IHostActivityItemComponentProps { activity: IHostPastActivity | IHostUpcomingActivity; tab: "past" | "upcoming"; -} - -/** Used for activity items component that need a show details handler */ -export interface IHostActivityItemComponentPropsWithShowDetails - extends IHostActivityItemComponentProps { - onShowDetails: ShowActivityDetailsHandler; - onCancel?: () => void; /** Set this to `true` when rendering only this activity by itself. This will * change the styles for the activity item for solo rendering. * @default false */ @@ -36,6 +31,13 @@ export interface IHostActivityItemComponentPropsWithShowDetails hideClose?: boolean; } +/** Used for activity items component that need a show details handler */ +export interface IHostActivityItemComponentPropsWithShowDetails + extends IHostActivityItemComponentProps { + onShowDetails: ShowActivityDetailsHandler; + onCancel?: () => void; +} + export const pastActivityComponentMap: Record< IHostPastActivityType, | React.FC @@ -47,6 +49,8 @@ export const pastActivityComponentMap: Record< [ActivityType.InstalledSoftware]: InstalledSoftwareActivityItem, [ActivityType.UninstalledSoftware]: InstalledSoftwareActivityItem, [ActivityType.InstalledAppStoreApp]: InstalledSoftwareActivityItem, + [ActivityType.CanceledScript]: CanceledScriptActivityItem, + [ActivityType.CanceledSoftwareInstall]: CanceledSoftwareInstallActivityItem, }; export const upcomingActivityComponentMap: Record< diff --git a/frontend/pages/hosts/details/cards/Activity/ActivityItems/CanceledScriptActivityItem/CanceledScriptActivityItem.tsx b/frontend/pages/hosts/details/cards/Activity/ActivityItems/CanceledScriptActivityItem/CanceledScriptActivityItem.tsx new file mode 100644 index 000000000000..67d16d64e6d4 --- /dev/null +++ b/frontend/pages/hosts/details/cards/Activity/ActivityItems/CanceledScriptActivityItem/CanceledScriptActivityItem.tsx @@ -0,0 +1,24 @@ +import React from "react"; + +import { formatScriptNameForActivityItem } from "utilities/helpers"; + +import HostActivityItem from "../../HostActivityItem"; +import { IHostActivityItemComponentProps } from "../../ActivityConfig"; + +const baseClass = "canceled-script-activity-item"; + +const CanceledScriptActivityItem = ({ + activity, +}: IHostActivityItemComponentProps) => { + return ( + + <> + {activity.actor_full_name} canceled{" "} + {formatScriptNameForActivityItem(activity.details?.script_name)}{" "} + script on this host. + + + ); +}; + +export default CanceledScriptActivityItem; diff --git a/frontend/pages/hosts/details/cards/Activity/ActivityItems/CanceledScriptActivityItem/index.ts b/frontend/pages/hosts/details/cards/Activity/ActivityItems/CanceledScriptActivityItem/index.ts new file mode 100644 index 000000000000..b0d5e965b396 --- /dev/null +++ b/frontend/pages/hosts/details/cards/Activity/ActivityItems/CanceledScriptActivityItem/index.ts @@ -0,0 +1 @@ +export { default } from "./CanceledScriptActivityItem"; diff --git a/frontend/pages/hosts/details/cards/Activity/ActivityItems/CanceledSoftwareInstallActivityItem/CanceledSoftwareInstallActivityItem.tsx b/frontend/pages/hosts/details/cards/Activity/ActivityItems/CanceledSoftwareInstallActivityItem/CanceledSoftwareInstallActivityItem.tsx new file mode 100644 index 000000000000..f078bb5fee55 --- /dev/null +++ b/frontend/pages/hosts/details/cards/Activity/ActivityItems/CanceledSoftwareInstallActivityItem/CanceledSoftwareInstallActivityItem.tsx @@ -0,0 +1,21 @@ +import React from "react"; + +import HostActivityItem from "../../HostActivityItem"; +import { IHostActivityItemComponentProps } from "../../ActivityConfig"; + +const baseClass = "canceled-software-install-activity-item"; + +const CanceledSoftwareInstallActivityItem = ({ + activity, +}: IHostActivityItemComponentProps) => { + return ( + + <> + {activity.actor_full_name} canceled{" "} + {activity.details?.software_title} install on this host. + + + ); +}; + +export default CanceledSoftwareInstallActivityItem; diff --git a/frontend/pages/hosts/details/cards/Activity/ActivityItems/CanceledSoftwareInstallActivityItem/index.ts b/frontend/pages/hosts/details/cards/Activity/ActivityItems/CanceledSoftwareInstallActivityItem/index.ts new file mode 100644 index 000000000000..d769467c5aa5 --- /dev/null +++ b/frontend/pages/hosts/details/cards/Activity/ActivityItems/CanceledSoftwareInstallActivityItem/index.ts @@ -0,0 +1 @@ +export { default } from "./CanceledSoftwareInstallActivityItem";