Core view migration fixes (#14166)

Bugs found with feature flag IS_CORE_VIEW_ENABLED:
- Switching a view type does switches but does not update the option
dropdown selected menu item, we have to refresh ==> **fixed**
- Reordering a field in the option dropdown causes a bug because it
tries to update with a decimal position like 1.5 but the position field
on core views is integer ==> **fixed**
Hidding a field triggers the update, but making it visible again right
after that does not trigger the DB update, we have to refresh the app
==> **not fixed, medium bug**
Reordering core view groups in option dropdown fails ==> **fixed**
Showing / hidding core view groups fails ==> **fixed**
Creating a table group view works but if we select kanban right after it
fails ==> **fixed**
Move right / move left on kanban core view group doesn’t do anything ==>
**fixed**
Deleting a view from the view dropdown fails ==> **fixed**
Creating a view from another view does not copy the view groups ==>
**not fixed, medium bug**
Move left / right has a strange behavior, not working consistently, it
sends always the same position ==> **not fixed, medium bug**
View re-order optimistic update is broken, but the DB update works ==>
**now it's dancing not fixed, medium bug**


Next steps:
- we should re-work the optimistic behaviors of view updates but let's
clean the code first
This commit is contained in:
Charles Bochet
2025-08-29 20:01:12 +02:00
committed by GitHub
parent c1870c3990
commit a132a0e88b
7 changed files with 76 additions and 34 deletions
@@ -3,7 +3,9 @@ import { useRecoilCallback } from 'recoil';
import { contextStoreCurrentViewIdComponentState } from '@/context-store/states/contextStoreCurrentViewIdComponentState';
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
import { useUpdateOneRecord } from '@/object-record/hooks/useUpdateOneRecord';
import { prefetchViewFromViewIdFamilySelector } from '@/prefetch/states/selector/prefetchViewFromViewIdFamilySelector';
import { useRecoilComponentCallbackState } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentCallbackState';
import { useRefreshCoreViews } from '@/views/hooks/useRefreshCoreViews';
import { type GraphQLView } from '@/views/types/GraphQLView';
import { convertUpdateViewInputToCore } from '@/views/utils/convertUpdateViewInputToCore';
import { useFeatureFlagsMap } from '@/workspace/hooks/useFeatureFlagsMap';
@@ -22,6 +24,7 @@ export const useUpdateCurrentView = () => {
const { updateOneRecord } = useUpdateOneRecord({
objectNameSingular: CoreObjectNameSingular.View,
});
const { refreshCoreViews } = useRefreshCoreViews();
const [updateOneCoreView] = useUpdateCoreViewMutation();
@@ -32,6 +35,18 @@ export const useUpdateCurrentView = () => {
.getLoadable(currentViewIdCallbackState)
.getValue();
const currentView = snapshot
.getLoadable(
prefetchViewFromViewIdFamilySelector({
viewId: currentViewId ?? '',
}),
)
.getValue();
if (!isDefined(currentView)) {
return;
}
if (isDefined(currentViewId)) {
if (isCoreViewEnabled) {
const input = convertUpdateViewInputToCore(view);
@@ -42,6 +57,7 @@ export const useUpdateCurrentView = () => {
input,
},
});
await refreshCoreViews(currentView.objectMetadataId);
} else {
await updateOneRecord({
idToUpdate: currentViewId,
@@ -53,6 +69,7 @@ export const useUpdateCurrentView = () => {
[
currentViewIdCallbackState,
isCoreViewEnabled,
refreshCoreViews,
updateOneCoreView,
updateOneRecord,
],