diff --git a/frontend/interfaces/label.ts b/frontend/interfaces/label.ts index 7565fca881..19e80d3cd1 100644 --- a/frontend/interfaces/label.ts +++ b/frontend/interfaces/label.ts @@ -48,6 +48,7 @@ export interface ILabel extends ILabelSummary { slug?: string; // e.g., "labels/13" | "online" target_type?: string; // e.g., "labels" platform: string; + author_id?: number; } // corresponding to fleet>server>fleet>labels.go>LabelSpec diff --git a/frontend/pages/hosts/ManageHostsPage/ManageHostsPage.tsx b/frontend/pages/hosts/ManageHostsPage/ManageHostsPage.tsx index 2d35204b42..041d218ec9 100644 --- a/frontend/pages/hosts/ManageHostsPage/ManageHostsPage.tsx +++ b/frontend/pages/hosts/ManageHostsPage/ManageHostsPage.tsx @@ -294,7 +294,9 @@ const ManageHostsPage = ({ const canEnrollHosts = isGlobalAdmin || isGlobalMaintainer || isTeamAdmin || isTeamMaintainer; const canEnrollGlobalHosts = isGlobalAdmin || isGlobalMaintainer; - const canAddNewLabels = (isGlobalAdmin || isGlobalMaintainer) ?? false; + const canAddNewLabels = + (isGlobalAdmin || isGlobalMaintainer || isTeamAdmin || isTeamMaintainer) ?? + false; const { data: labels, refetch: refetchLabels } = useQuery< ILabelsResponse, diff --git a/frontend/pages/hosts/ManageHostsPage/components/HostsFilterBlock/HostsFilterBlock.tsx b/frontend/pages/hosts/ManageHostsPage/components/HostsFilterBlock/HostsFilterBlock.tsx index f3ea242e68..3eb8e6f5c4 100644 --- a/frontend/pages/hosts/ManageHostsPage/components/HostsFilterBlock/HostsFilterBlock.tsx +++ b/frontend/pages/hosts/ManageHostsPage/components/HostsFilterBlock/HostsFilterBlock.tsx @@ -1,6 +1,7 @@ -import React from "react"; +import React, { useContext } from "react"; import { invert } from "lodash"; +import { AppContext } from "context/app"; import { ILabel } from "interfaces/label"; import { formatOperatingSystemDisplayName, @@ -140,6 +141,8 @@ const HostsFilterBlock = ({ onClickEditLabel, onClickDeleteLabel, }: IHostsFilterBlockProps) => { + const { currentUser, isOnGlobalTeam } = useContext(AppContext); + const renderLabelFilterPill = () => { if (selectedLabel) { const { description, display_text, label_type } = selectedLabel; @@ -165,16 +168,18 @@ const HostsFilterBlock = ({ tooltipDescription={description} onClear={handleClearRouteParam} /> - {label_type !== "builtin" && !isOnlyObserver && ( - <> - - - - )} + {label_type !== "builtin" && + !isOnlyObserver && + (isOnGlobalTeam || currentUser?.id === selectedLabel.author_id) && ( + <> + + + + )} ); }