From fd40f3ddf79ddf3cba44d421344aed63b661c5a6 Mon Sep 17 00:00:00 2001 From: Gabriel Hernandez Date: Tue, 21 Nov 2023 17:11:32 +0000 Subject: [PATCH] add activities for windows profiles (#15246) relates to #14359 Add activities to fleet UI for windows profiles create, delete, and edit. - [x] Manual QA for all new/changed functionality --- frontend/interfaces/activity.ts | 3 + .../ActivityItem/ActivityItem.tsx | 91 +++++++++++++++++-- 2 files changed, 86 insertions(+), 8 deletions(-) diff --git a/frontend/interfaces/activity.ts b/frontend/interfaces/activity.ts index 1cb7bfc6a5..41ce556d98 100644 --- a/frontend/interfaces/activity.ts +++ b/frontend/interfaces/activity.ts @@ -38,6 +38,9 @@ export enum ActivityType { CreatedMacOSProfile = "created_macos_profile", DeletedMacOSProfile = "deleted_macos_profile", EditedMacOSProfile = "edited_macos_profile", + CreatedWindowsProfile = "created_windows_profile", + DeletedWindowsProfile = "deleted_windows_profile", + EditedWindowsProfile = "edited_windows_profile", EnabledMacDiskEncryption = "enabled_macos_disk_encryption", DisabledMacDiskEncryption = "disabled_macos_disk_encryption", AddedBootstrapPackage = "added_bootstrap_package", diff --git a/frontend/pages/DashboardPage/cards/ActivityFeed/ActivityItem/ActivityItem.tsx b/frontend/pages/DashboardPage/cards/ActivityFeed/ActivityItem/ActivityItem.tsx index 996ab5f760..20b63c270a 100644 --- a/frontend/pages/DashboardPage/cards/ActivityFeed/ActivityItem/ActivityItem.tsx +++ b/frontend/pages/DashboardPage/cards/ActivityFeed/ActivityItem/ActivityItem.tsx @@ -32,16 +32,18 @@ const PREMIUM_ACTIVITIES = new Set([ const getProfileMessageSuffix = ( isPremiumTier: boolean, + platform: "darwin" | "windows", teamName?: string | null ) => { - let messageSuffix = <>all macOS hosts; + const platformDisplayName = platform === "darwin" ? "macOS" : "Windows"; + let messageSuffix = <>all {platformDisplayName} hosts; if (isPremiumTier) { messageSuffix = teamName ? ( <> - macOS hosts assigned to the {teamName} team + {platformDisplayName} hosts assigned to the {teamName} team ) : ( - <>macOS hosts with no team + <>{platformDisplayName} hosts with no team ); } return messageSuffix; @@ -318,7 +320,6 @@ const TAGGED_TEMPLATES = { ); }, - createMacOSProfile: (activity: IActivity, isPremiumTier: boolean) => { const profileName = activity.details?.profile_name; return ( @@ -330,12 +331,16 @@ const TAGGED_TEMPLATES = { ) : ( <>a configuration profile )}{" "} - to {getProfileMessageSuffix(isPremiumTier, activity.details?.team_name)} + to{" "} + {getProfileMessageSuffix( + isPremiumTier, + "darwin", + activity.details?.team_name + )} . ); }, - deleteMacOSProfile: (activity: IActivity, isPremiumTier: boolean) => { const profileName = activity.details?.profile_name; return ( @@ -348,11 +353,15 @@ const TAGGED_TEMPLATES = { <>a configuration profile )}{" "} from{" "} - {getProfileMessageSuffix(isPremiumTier, activity.details?.team_name)}. + {getProfileMessageSuffix( + isPremiumTier, + "darwin", + activity.details?.team_name + )} + . ); }, - editMacOSProfile: (activity: IActivity, isPremiumTier: boolean) => { return ( <> @@ -360,6 +369,63 @@ const TAGGED_TEMPLATES = { edited configuration profiles for{" "} {getProfileMessageSuffix( isPremiumTier, + "darwin", + activity.details?.team_name + )}{" "} + via fleetctl. + + ); + }, + createWindowsProfile: (activity: IActivity, isPremiumTier: boolean) => { + const profileName = activity.details?.profile_name; + return ( + <> + {" "} + added{" "} + {profileName ? ( + <>configuration profile {profileName} + ) : ( + <>a configuration profile + )}{" "} + to{" "} + {getProfileMessageSuffix( + isPremiumTier, + "windows", + activity.details?.team_name + )} + . + + ); + }, + deleteWindowsProfile: (activity: IActivity, isPremiumTier: boolean) => { + const profileName = activity.details?.profile_name; + return ( + <> + {" "} + deleted{" "} + {profileName ? ( + <>configuration profile {profileName} + ) : ( + <>a configuration profile + )}{" "} + from{" "} + {getProfileMessageSuffix( + isPremiumTier, + "windows", + activity.details?.team_name + )} + . + + ); + }, + editWindowsProfile: (activity: IActivity, isPremiumTier: boolean) => { + return ( + <> + {" "} + edited configuration profiles for{" "} + {getProfileMessageSuffix( + isPremiumTier, + "windows", activity.details?.team_name )}{" "} via fleetctl. @@ -692,6 +758,15 @@ const getDetail = ( case ActivityType.EditedMacOSProfile: { return TAGGED_TEMPLATES.editMacOSProfile(activity, isPremiumTier); } + case ActivityType.CreatedWindowsProfile: { + return TAGGED_TEMPLATES.createWindowsProfile(activity, isPremiumTier); + } + case ActivityType.DeletedWindowsProfile: { + return TAGGED_TEMPLATES.deleteWindowsProfile(activity, isPremiumTier); + } + case ActivityType.EditedWindowsProfile: { + return TAGGED_TEMPLATES.editWindowsProfile(activity, isPremiumTier); + } case ActivityType.EnabledMacDiskEncryption: { return TAGGED_TEMPLATES.enableMacDiskEncryption(activity); }