diff --git a/.changeset/fifty-laws-count.md b/.changeset/fifty-laws-count.md new file mode 100644 index 0000000000..f20e41fc20 --- /dev/null +++ b/.changeset/fifty-laws-count.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-kubernetes': patch +--- + +Omit managed fields in the Kubernetes resource YAML display. diff --git a/plugins/kubernetes/src/components/KubernetesDrawer/KubernetesDrawer.tsx b/plugins/kubernetes/src/components/KubernetesDrawer/KubernetesDrawer.tsx index 7e194c3ec2..9be30debf3 100644 --- a/plugins/kubernetes/src/components/KubernetesDrawer/KubernetesDrawer.tsx +++ b/plugins/kubernetes/src/components/KubernetesDrawer/KubernetesDrawer.tsx @@ -25,6 +25,7 @@ import { Drawer, Switch, FormControlLabel, + FormGroup, Grid, } from '@material-ui/core'; import Close from '@material-ui/icons/Close'; @@ -150,6 +151,11 @@ const KubernetesDrawerContent = ({ }: KubernetesDrawerContentProps) => { const [isYaml, setIsYaml] = useState(false); + // Toggle whether the Kubernetes resource managed fields should be shown in + // the YAML display. This toggle is only available when the YAML is being + // shown because managed fields are never visible in the structured display. + const [managedFields, setManagedFields] = useState(false); + const classes = useDrawerContentStyles(); const cluster = useContext(ClusterContext); const { clusterLink, errorMessage } = tryFormatClusterLink({ @@ -208,21 +214,49 @@ const KubernetesDrawerContent = ({ )} - { - setIsYaml(event.target.checked); - }} - name="YAML" - /> - } - label="YAML" - /> + + { + setIsYaml(event.target.checked); + }} + name="YAML" + /> + } + label="YAML" + /> + { + if (isYaml) { + setManagedFields(event.target.checked); + } + }} + name="Managed Fields" + /> + } + label="Managed Fields" + /> +
- {isYaml && } + {isYaml && ( + { + if (!managedFields) { + return key === 'managedFields' ? undefined : value; + } + return value; + }, + })} + /> + )} {!isYaml && (