mirror of
https://github.com/fleetdm/fleet
synced 2026-05-23 08:58:41 +00:00
Dashboard: Fix activity feed verbage (#2540)
This commit is contained in:
parent
d58d9507b8
commit
fda757a700
3 changed files with 25 additions and 4 deletions
1
changes/issue-2419-human-readable-activities
Normal file
1
changes/issue-2419-human-readable-activities
Normal file
|
|
@ -0,0 +1 @@
|
|||
* Update activity feed verbage
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
import PropTypes from "prop-types";
|
||||
import { IQuery } from "./query";
|
||||
|
||||
export enum ActivityType {
|
||||
CreatedPack = "created_pack",
|
||||
|
|
@ -10,8 +11,8 @@ export enum ActivityType {
|
|||
CreatedTeam = "created_team",
|
||||
DeletedTeam = "deleted_team",
|
||||
LiveQuery = "live_query",
|
||||
AppliedPackSpec = "applied_pack_spec",
|
||||
AppliedQuerySpec = "applied_query_spec",
|
||||
AppliedSpecPack = "applied_spec_pack",
|
||||
AppliedSpecSavedQuery = "applied_spec_saved_query",
|
||||
}
|
||||
export interface IActivity {
|
||||
created_at: string;
|
||||
|
|
@ -31,6 +32,7 @@ export interface IActivityDetails {
|
|||
team_id?: number;
|
||||
team_name?: string;
|
||||
targets_count?: number;
|
||||
specs?: IQuery[];
|
||||
}
|
||||
|
||||
export default PropTypes.shape({
|
||||
|
|
|
|||
|
|
@ -29,15 +29,27 @@ const TAGGED_TEMPLATES = {
|
|||
? "ran a live query"
|
||||
: `ran a live query on ${count} ${count === 1 ? "host" : "hosts"}`;
|
||||
},
|
||||
editPackCtlActivityTemplate: () => {
|
||||
return "edited a pack using fleetctl";
|
||||
},
|
||||
editQueryCtlActivityTemplate: (activity: IActivity) => {
|
||||
const count = activity.details?.specs?.length;
|
||||
return typeof count === "undefined" || typeof count !== "number"
|
||||
? "edited a query using fleetctl"
|
||||
: `edited ${count === 1 ? "a query" : "queries"} using fleetctl`;
|
||||
},
|
||||
defaultActivityTemplate: (activity: IActivity) => {
|
||||
const entityName = find(activity.details, (_, key) =>
|
||||
key.includes("_name")
|
||||
);
|
||||
|
||||
const activityType = lowerCase(activity.type).replace(" saved", "");
|
||||
|
||||
return !entityName ? (
|
||||
`${lowerCase(activity.type)}`
|
||||
`${activityType}`
|
||||
) : (
|
||||
<span>
|
||||
{lowerCase(activity.type)} <b>{entityName}</b>
|
||||
{activityType} <b>{entityName}</b>
|
||||
</span>
|
||||
);
|
||||
},
|
||||
|
|
@ -88,6 +100,12 @@ const ActivityFeed = (): JSX.Element => {
|
|||
if (activity.type === ActivityType.LiveQuery) {
|
||||
return TAGGED_TEMPLATES.liveQueryActivityTemplate(activity);
|
||||
}
|
||||
if (activity.type === ActivityType.AppliedSpecPack) {
|
||||
return TAGGED_TEMPLATES.editPackCtlActivityTemplate();
|
||||
}
|
||||
if (activity.type === ActivityType.AppliedSpecSavedQuery) {
|
||||
return TAGGED_TEMPLATES.editQueryCtlActivityTemplate(activity);
|
||||
}
|
||||
return TAGGED_TEMPLATES.defaultActivityTemplate(activity);
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue