Add UI activity templates for enable/disable end user authentication (#11634)

This commit is contained in:
gillespi314 2023-05-15 11:10:43 -05:00 committed by GitHub
parent 70f5b2e444
commit 69f79a99f3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 108 additions and 0 deletions

View file

@ -43,6 +43,8 @@ export enum ActivityType {
DeletedBootstrapPackage = "deleted_bootstrap_package",
ChangedMacOSSetupAssistant = "changed_macos_setup_assistant",
DeletedMacOSSetupAssistant = "deleted_macos_setup_assistant",
EnabledMacOSSetupEndUserAuth = "enabled_macos_setup_end_user_auth",
DisabledMacOSSetupEndUserAuth = "disabled_macos_setup_end_user_auth",
}
export interface IActivity {
created_at: string;

View file

@ -570,4 +570,68 @@ describe("Activity Feed", () => {
)
).toBeInTheDocument();
});
it("renders a 'enabled_macos_setup_end_user_auth' type activity for a team", () => {
const activity = createMockActivity({
type: ActivityType.EnabledMacOSSetupEndUserAuth,
details: { team_name: "Alphas" },
});
render(<ActivityItem activity={activity} isPremiumTier />);
expect(
screen.getByText(
"required end user authentication for macOS hosts that automatically enroll to",
{ exact: false }
)
).toBeInTheDocument();
expect(screen.getByText("Alphas")).toBeInTheDocument();
const withNoTeams = screen.queryByText("no team");
expect(withNoTeams).toBeNull();
});
it("renders a 'enabled_macos_setup_end_user_auth' type activity for hosts with no team.", () => {
const activity = createMockActivity({
type: ActivityType.EnabledMacOSSetupEndUserAuth,
});
render(<ActivityItem activity={activity} isPremiumTier />);
expect(
screen.getByText(
"required end user authentication for macOS hosts that automatically enroll to no team.",
{ exact: false }
)
).toBeInTheDocument();
});
it("renders a 'disabled_macos_setup_end_user_auth' type activity for a team", () => {
const activity = createMockActivity({
type: ActivityType.DisabledMacOSSetupEndUserAuth,
details: { team_name: "Alphas" },
});
render(<ActivityItem activity={activity} isPremiumTier />);
expect(
screen.getByText(
"removed end user authentication requirement for macOS hosts that automatically enroll to",
{ exact: false }
)
).toBeInTheDocument();
expect(screen.getByText("Alphas")).toBeInTheDocument();
const withNoTeams = screen.queryByText("no team");
expect(withNoTeams).toBeNull();
});
it("renders a 'disabled_macos_setup_end_user_auth' type activity for hosts with no team.", () => {
const activity = createMockActivity({
type: ActivityType.DisabledMacOSSetupEndUserAuth,
});
render(<ActivityItem activity={activity} isPremiumTier />);
expect(
screen.getByText(
"removed end user authentication requirement for macOS hosts that automatically enroll to no team.",
{ exact: false }
)
).toBeInTheDocument();
});
});

View file

@ -22,6 +22,8 @@ const PREMIUM_ACTIVITIES = new Set([
"read_host_disk_encryption_key",
"enabled_macos_disk_encryption",
"disabled_macos_disk_encryption",
"enabled_macos_setup_end_user_auth",
"disabled_macos_setup_end_user_auth",
]);
const getProfileMessageSuffix = (
@ -407,6 +409,40 @@ const TAGGED_TEMPLATES = {
</>
);
},
enabledMacOSSetupEndUserAuth: (activity: IActivity) => {
return (
<>
{" "}
required end user authentication for macOS hosts that automatically
enroll to{" "}
{activity.details?.team_name ? (
<>
the <b>{activity.details.team_name}</b> team
</>
) : (
"no team"
)}
.
</>
);
},
disabledMacOSSetupEndUserAuth: (activity: IActivity) => {
return (
<>
{" "}
removed end user authentication requirement for macOS hosts that
automatically enroll to{" "}
{activity.details?.team_name ? (
<>
the <b>{activity.details.team_name}</b> team
</>
) : (
"no team"
)}
.
</>
);
},
};
const getDetail = (
@ -502,6 +538,12 @@ const getDetail = (
case ActivityType.DeletedMacOSSetupAssistant: {
return TAGGED_TEMPLATES.deletedMacOSSetupAssistant(activity);
}
case ActivityType.EnabledMacOSSetupEndUserAuth: {
return TAGGED_TEMPLATES.enabledMacOSSetupEndUserAuth(activity);
}
case ActivityType.DisabledMacOSSetupEndUserAuth: {
return TAGGED_TEMPLATES.disabledMacOSSetupEndUserAuth(activity);
}
default: {
return TAGGED_TEMPLATES.defaultActivityTemplate(activity);
}