From 6a29198c5cf5cabb510e1b027ce5bfe14eae9bfd Mon Sep 17 00:00:00 2001 From: Prabhat Khera <91852476+prabhat-org@users.noreply.github.com> Date: Wed, 10 May 2023 10:42:56 +1200 Subject: [PATCH] fix note patching for Pod (#8915) --- .../DetailsView/ApplicationSummaryWidget.tsx | 12 ++++++++---- app/react/kubernetes/applications/pod.service.ts | 9 +++++++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/app/react/kubernetes/applications/DetailsView/ApplicationSummaryWidget.tsx b/app/react/kubernetes/applications/DetailsView/ApplicationSummaryWidget.tsx index bab59611b..e657cd440 100644 --- a/app/react/kubernetes/applications/DetailsView/ApplicationSummaryWidget.tsx +++ b/app/react/kubernetes/applications/DetailsView/ApplicationSummaryWidget.tsx @@ -1,6 +1,6 @@ import { User, Clock, Edit, ChevronDown, ChevronUp } from 'lucide-react'; import moment from 'moment'; -import { useState } from 'react'; +import { useEffect, useState } from 'react'; import { Pod } from 'kubernetes-types/core/v1'; import { useCurrentStateAndParams } from '@uirouter/react'; @@ -60,9 +60,13 @@ export function ApplicationSummaryWidget() { application?.metadata?.annotations?.[appNoteAnnotation]; const [isNoteOpen, setIsNoteOpen] = useState(true); - const [applicationNoteFormValues, setApplicationNoteFormValues] = useState( - applicationNote || '' - ); + const [applicationNoteFormValues, setApplicationNoteFormValues] = + useState(''); + + useEffect(() => { + setApplicationNoteFormValues(applicationNote || ''); + }, [applicationNote]); + const patchApplicationMutation = usePatchApplicationMutation( environmentId, namespace, diff --git a/app/react/kubernetes/applications/pod.service.ts b/app/react/kubernetes/applications/pod.service.ts index 8236df163..34d83e607 100644 --- a/app/react/kubernetes/applications/pod.service.ts +++ b/app/react/kubernetes/applications/pod.service.ts @@ -44,9 +44,14 @@ export async function patchPod( }, ]; try { - return await axios.put( + return await axios.patch( buildUrl(environmentId, namespace, name), - payload + payload, + { + headers: { + 'Content-Type': 'application/json-patch+json', + }, + } ); } catch (e) { throw parseAxiosError(e as Error, 'Unable to update pod');