Block edit teams action in VPP table when in GitOps mode (#33345)

<!-- Add the related story/sub-task/bug number, like Resolves #123, or
remove if NA -->
**Related issue:** Resolves #32379 

# 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/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-changes.md#changes-files)
for more information.

## Testing

- [x] QA'd all new/changed functionality manually

## Media

<img width="293" height="493" alt="image"
src="https://github.com/user-attachments/assets/5b23075a-b856-4df9-9106-0e684c03bc15"
/>
This commit is contained in:
Magnus Jensen
2025-09-25 14:45:27 +03:00
committed by GitHub
parent c3bb14bac4
commit 8e5bac79ca
3 changed files with 33 additions and 6 deletions
@@ -0,0 +1 @@
* Correctly block edit teams action in VPP table dropdown when Fleet is in GitOps mode.
@@ -1,8 +1,9 @@
import React from "react";
import React, { useContext } from "react";
import { IMdmVppToken } from "interfaces/mdm";
import TableContainer from "components/TableContainer";
import { AppContext } from "context/app";
import { generateTableConfig } from "./VppTableConfig";
@@ -21,6 +22,10 @@ const VppTable = ({
onRenewToken,
onDeleteToken,
}: IVppTableProps) => {
const { config } = useContext(AppContext); // We load gitops context here, since we can't use the default gitops wrapper since it's on a nested dropdown option
const gitOpsModeEnabled = config?.gitops.gitops_mode_enabled;
const repoURL = config?.gitops.repository_url;
const onSelectAction = (action: string, abmToken: IMdmVppToken) => {
switch (action) {
case "editTeams":
@@ -37,7 +42,11 @@ const VppTable = ({
}
};
const tableConfig = generateTableConfig(onSelectAction);
const tableConfig = generateTableConfig(
onSelectAction,
gitOpsModeEnabled ?? false,
repoURL ?? ""
);
return (
<TableContainer<IMdmVppToken>
@@ -8,6 +8,7 @@ import { IDropdownOption } from "interfaces/dropdownOption";
import HeaderCell from "components/TableContainer/DataTable/HeaderCell";
import ActionsDropdown from "components/ActionsDropdown";
import TextCell from "components/TableContainer/DataTable/TextCell";
import { getGitOpsModeTipContent } from "utilities/helpers";
import RenewDateCell from "../../../components/RenewDateCell";
import { IRenewDateCellStatusConfig } from "../../../components/RenewDateCell/RenewDateCell";
@@ -26,8 +27,22 @@ const DEFAULT_ACTION_OPTIONS: IDropdownOption[] = [
{ value: "delete", label: "Delete", disabled: false },
];
const generateActions = () => {
return DEFAULT_ACTION_OPTIONS;
const generateActions = (gitopsModeEnabled: boolean, repoURL: string) => {
if (!gitopsModeEnabled) {
return DEFAULT_ACTION_OPTIONS;
}
return DEFAULT_ACTION_OPTIONS.map((option) => {
if (option.value !== "editTeams") {
return option;
}
return {
...option,
disabled: true,
tooltipContent: getGitOpsModeTipContent(repoURL),
};
});
};
const RENEW_DATE_CELL_STATUS_CONFIG: IRenewDateCellStatusConfig = {
@@ -52,7 +67,9 @@ const RENEW_DATE_CELL_STATUS_CONFIG: IRenewDateCellStatusConfig = {
};
export const generateTableConfig = (
actionSelectHandler: (value: string, team: IMdmVppToken) => void
actionSelectHandler: (value: string, team: IMdmVppToken) => void,
gitopsModeEnabled: boolean,
repoURL: string
): IAbmTableConfig[] => {
return [
{
@@ -105,7 +122,7 @@ export const generateTableConfig = (
accessor: "id",
Cell: (cellProps) => (
<ActionsDropdown
options={generateActions()}
options={generateActions(gitopsModeEnabled, repoURL)}
onChange={(value: string) =>
actionSelectHandler(value, cellProps.row.original)
}