UI: Implement new activity types for macOS profiles (#9894)

# Addresses #9595

# Implements

- new Activity types:
    - CreatedMacOSProfile
    - DeletedMacOSProfile
    - EditedMacOSProfile
- Activity message depends on isPremium:
- true: '...macOS hosts with no team' or '...macOS hosts assigned to the
**Team Name** team {?via fleetctl}.'
    - false: '...{to | from | for} all macOS hosts.'
# Checklist for submitter

If some of the following don't apply, delete the relevant line.

- [x] Changes file added for user-visible changes in `changes/`
- [ ] Manual QA for all new/changed functionality

---------

Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
This commit is contained in:
Jacob Shandling 2023-02-22 10:42:40 -08:00 committed by GitHub
parent d4463bcb88
commit ba34351f4b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 68 additions and 0 deletions

View file

@ -0,0 +1 @@
* Create activity feed types for the creation, update, and deletion of macOS profiles (settings) via MDM

View file

@ -33,6 +33,9 @@ export enum ActivityType {
MdmUnenrolled = "mdm_unenrolled",
EditedMacosMinVersion = "edited_macos_min_version",
ReadHostDiskEncryptionKey = "read_host_disk_encryption_key",
CreatedMacOSProfile = "created_macos_profile",
DeletedMacOSProfile = "deleted_macos_profile",
EditedMacOSProfile = "edited_macos_profile",
}
export interface IActivity {
created_at: string;
@ -67,4 +70,6 @@ export interface IActivityDetails {
installed_from_dep?: boolean;
minimum_version?: string;
deadline?: string;
profile_name?: string;
profile_identifier?: string;
}

View file

@ -9,9 +9,27 @@ import Avatar from "components/Avatar";
import Button from "components/buttons/Button";
import Icon from "components/Icon";
import ReactTooltip from "react-tooltip";
import { actions } from "react-table";
const baseClass = "activity-item";
const getProfileMessageSuffix = (
isPremiumTier: boolean,
teamName?: string | null
) => {
let messageSuffix = <>all macOS hosts</>;
if (isPremiumTier) {
messageSuffix = teamName ? (
<>
macOS hosts assigned to the <b>{teamName}</b> team
</>
) : (
<>macOS hosts with no team</>
);
}
return messageSuffix;
};
const TAGGED_TEMPLATES = {
liveQueryActivityTemplate: (
activity: IActivity,
@ -210,6 +228,41 @@ const TAGGED_TEMPLATES = {
);
},
createMacOSProfile: (activity: IActivity, isPremiumTier: boolean) => {
return (
<>
{" "}
added configuration profile {activity.details?.profile_name} to{" "}
{getProfileMessageSuffix(isPremiumTier, activity.details?.team_name)}.
</>
);
},
deleteMacOSProfile: (activity: IActivity, isPremiumTier: boolean) => {
return (
<>
{" "}
deleted configuration profile {
activity.details?.host_display_name
} from{" "}
{getProfileMessageSuffix(isPremiumTier, activity.details?.team_name)}.
</>
);
},
editMacOSProfile: (activity: IActivity, isPremiumTier: boolean) => {
return (
<>
{" "}
edited configuration profiles for{" "}
{getProfileMessageSuffix(
isPremiumTier,
activity.details?.team_name
)}{" "}
via fleetctl.
</>
);
},
defaultActivityTemplate: (activity: IActivity) => {
const entityName = find(activity.details, (_, key) =>
key.includes("_name")
@ -293,6 +346,15 @@ const getDetail = (
case ActivityType.ReadHostDiskEncryptionKey: {
return TAGGED_TEMPLATES.readHostDiskEncryptionKey(activity);
}
case ActivityType.CreatedMacOSProfile: {
return TAGGED_TEMPLATES.createMacOSProfile(activity, isPremiumTier);
}
case ActivityType.DeletedMacOSProfile: {
return TAGGED_TEMPLATES.createMacOSProfile(activity, isPremiumTier);
}
case ActivityType.EditedMacOSProfile: {
return TAGGED_TEMPLATES.createMacOSProfile(activity, isPremiumTier);
}
default: {
return TAGGED_TEMPLATES.defaultActivityTemplate(activity);
}