Fix pluralization in the "delete multiple queries" activity log (#15099)

### Checklist for submitter

- [x] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [x] Added/updated tests
- [x] Manual QA for all new/changed functionality

### Summary 

This PR creates a pluralized activity log in the case where a user
deletes multiple saved queries.

I had considered updating the default template to better support
pluralization, but when reviewing the various activity log types, I
think queries are the only type that would benefit from this. So I chose
the easier option here which felt less risky.

cc @sharon-fdm as the currently assigned person on the issue (just
trying to save y'all some cycles by contributing and slowly ramping up
on the codebase 😄)

ref: #15050 

### Test Plan

I added a unit test for this.

Additionally, I deleted multiple saved queries in my local installation.
Here's the resulting log, showing the proper pluralization:

<img width="1381" alt="Screenshot 2023-11-10 at 9 54 40 PM"
src="https://github.com/fleetdm/fleet/assets/1317288/f40414e2-7a9b-4478-b6cf-bb9d4ab6d8f0">
This commit is contained in:
Jordan Wright 2023-11-17 14:22:47 -06:00 committed by GitHub
parent 597dafa187
commit 04a572f542
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1 @@
- * Pluralize the activity log rendered when multiple queries were deleted

View File

@ -12,6 +12,7 @@ export enum ActivityType {
EditedPolicy = "edited_policy",
CreatedSavedQuery = "created_saved_query",
DeletedSavedQuery = "deleted_saved_query",
DeletedMultipleSavedQuery = "deleted_multiple_saved_query",
EditedSavedQuery = "edited_saved_query",
CreatedTeam = "created_team",
DeletedTeam = "deleted_team",
@ -71,6 +72,7 @@ export interface IActivityDetails {
query_id?: number;
query_name?: string;
query_sql?: string;
query_ids?: number[];
team_id?: number | null;
team_name?: string | null;
teams?: ITeamSummary[];

View File

@ -882,4 +882,17 @@ describe("Activity Feed", () => {
screen.getByText("for no team via fleetctl.", { exact: false })
).toBeInTheDocument();
});
it("renders a pluralized 'deleted_multiple_saved_query' type activity when deleting multiple queries.", () => {
const activity = createMockActivity({
type: ActivityType.DeletedMultipleSavedQuery,
details: {
query_ids: [1, 2, 3],
},
});
render(<ActivityItem activity={activity} isPremiumTier />);
expect(
screen.getByText("deleted multiple queries", { exact: false })
).toBeInTheDocument();
});
});

View File

@ -584,6 +584,9 @@ const TAGGED_TEMPLATES = {
</>
);
},
deletedMultipleSavedQuery: (activity: IActivity) => {
return <> deleted multiple queries.</>;
},
};
const getDetail = (
@ -709,6 +712,9 @@ const getDetail = (
case ActivityType.EditedScript: {
return TAGGED_TEMPLATES.editedScript(activity);
}
case ActivityType.DeletedMultipleSavedQuery: {
return TAGGED_TEMPLATES.deletedMultipleSavedQuery(activity);
}
default: {
return TAGGED_TEMPLATES.defaultActivityTemplate(activity);
}