Skip to content

Commit

Permalink
FIX[#14565]: container and ml models custom property apis are sending…
Browse files Browse the repository at this point in the history
… wrong payload (#14566)

(cherry picked from commit 7223398)
  • Loading branch information
Sachin-chaurasiya committed Jan 4, 2024
1 parent 0af7d14 commit 0627d2d
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,17 @@ const ContainerPage = () => {
}
};

const handleUpdateContainerData = (updatedData: Container) => {
const jsonPatch = compare(omitBy(containerData, isUndefined), updatedData);
const handleUpdateContainerData = useCallback(
(updatedData: Container) => {
const jsonPatch = compare(
omitBy(containerData, isUndefined),
updatedData
);

return patchContainerDetails(containerData?.id ?? '', jsonPatch);
};
return patchContainerDetails(containerData?.id ?? '', jsonPatch);
},
[containerData]
);

const handleUpdateDescription = async (updatedDescription: string) => {
try {
Expand Down Expand Up @@ -420,18 +426,33 @@ const ContainerPage = () => {
}
};

const handleExtensionUpdate = async (updatedContainer: Container) => {
try {
const response = await handleUpdateContainerData(updatedContainer);
setContainerData({
...response,
tags: sortTagsCaseInsensitive(response.tags ?? []),
});
getEntityFeedCount();
} catch (error) {
showErrorToast(error as AxiosError);
}
};
const handleExtensionUpdate = useCallback(
async (updatedContainer: Container) => {
if (isUndefined(containerData)) {
return;
}

try {
const response = await handleUpdateContainerData({
...containerData,
extension: updatedContainer.extension,
});
setContainerData({
...response,
tags: sortTagsCaseInsensitive(response.tags ?? []),
});
getEntityFeedCount();
} catch (error) {
showErrorToast(error as AxiosError);
}
},
[
containerData,
handleUpdateContainerData,
getEntityFeedCount,
setContainerData,
]
);

const handleUpdateDataModel = async (
updatedDataModel: Container['dataModel']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,17 @@ const MlModelPage = () => {
}
}, [mlModelPermissions, mlModelFqn]);

const saveUpdatedMlModelData = (updatedData: Mlmodel) => {
const jsonPatch = compare(omitBy(mlModelDetail, isUndefined), updatedData);
const saveUpdatedMlModelData = useCallback(
(updatedData: Mlmodel) => {
const jsonPatch = compare(
omitBy(mlModelDetail, isUndefined),
updatedData
);

return patchMlModelDetails(mlModelDetail.id, jsonPatch);
};
return patchMlModelDetails(mlModelDetail.id, jsonPatch);
},
[mlModelDetail]
);

const descriptionUpdateHandler = async (updatedMlModel: Mlmodel) => {
try {
Expand Down Expand Up @@ -230,19 +236,25 @@ const MlModelPage = () => {
}
};

const handleExtensionUpdate = async (updatedMlModel: Mlmodel) => {
try {
const data = await saveUpdatedMlModelData(updatedMlModel);
setMlModelDetail(data);
} catch (error) {
showErrorToast(
error as AxiosError,
t('server.entity-updating-error', {
entity: getEntityName(mlModelDetail),
})
);
}
};
const handleExtensionUpdate = useCallback(
async (updatedMlModel: Mlmodel) => {
try {
const data = await saveUpdatedMlModelData({
...mlModelDetail,
extension: updatedMlModel.extension,
});
setMlModelDetail(data);
} catch (error) {
showErrorToast(
error as AxiosError,
t('server.entity-updating-error', {
entity: getEntityName(mlModelDetail),
})
);
}
},
[saveUpdatedMlModelData, setMlModelDetail, mlModelDetail]
);

const createThread = async (data: CreateThread) => {
try {
Expand Down

0 comments on commit 0627d2d

Please sign in to comment.