Skip to content

Commit

Permalink
add canceled script and software install activities
Browse files Browse the repository at this point in the history
  • Loading branch information
ghernandez345 committed Jan 10, 2025
1 parent 8c2560a commit 6551545
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 8 deletions.
6 changes: 5 additions & 1 deletion frontend/interfaces/activity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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 =
Expand Down
18 changes: 11 additions & 7 deletions frontend/pages/hosts/details/cards/Activity/ActivityConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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<IHostActivityItemComponentProps>
Expand All @@ -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<
Expand Down
Original file line number Diff line number Diff line change
@@ -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 (
<HostActivityItem className={baseClass} activity={activity}>
<>
<b>{activity.actor_full_name}</b> canceled{" "}
<b>{formatScriptNameForActivityItem(activity.details?.script_name)}</b>{" "}
script on this host.
</>
</HostActivityItem>
);
};

export default CanceledScriptActivityItem;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from "./CanceledScriptActivityItem";
Original file line number Diff line number Diff line change
@@ -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 (
<HostActivityItem className={baseClass} activity={activity}>
<>
<b>{activity.actor_full_name}</b> canceled{" "}
<b>{activity.details?.software_title}</b> install on this host.
</>
</HostActivityItem>
);
};

export default CanceledSoftwareInstallActivityItem;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from "./CanceledSoftwareInstallActivityItem";

0 comments on commit 6551545

Please sign in to comment.