fix: unit pages ux bugs [FC-0083] (#1884)

This PR fixes some UX bugs related to the unit pages:

* Sort for "recently modified" on unit tab does not update after adding new components to units
* Change component delete warning message
This commit is contained in:
Rômulo Penido
2025-05-06 22:34:07 -03:00
committed by GitHub
parent 208b0c9195
commit d7173036a5
7 changed files with 61 additions and 47 deletions

View File

@@ -642,13 +642,22 @@ export const useAddComponentsToContainer = (containerId?: string) => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: async (componentIds: string[]) => {
if (containerId !== undefined) {
return api.addComponentsToContainer(containerId, componentIds);
// istanbul ignore if: this should never happen
if (!containerId) {
return undefined;
}
return undefined;
return api.addComponentsToContainer(containerId, componentIds);
},
onSettled: () => {
queryClient.invalidateQueries({ queryKey: libraryAuthoringQueryKeys.containerChildren(containerId!) });
// istanbul ignore if: this should never happen
if (!containerId) {
return;
}
// NOTE: We invalidate the library query here because we need to update the library's
// container list.
const libraryId = getLibraryId(containerId);
queryClient.invalidateQueries({ queryKey: libraryAuthoringQueryKeys.containerChildren(containerId) });
queryClient.invalidateQueries({ predicate: (query) => libraryQueryPredicate(query, libraryId) });
},
});
};