refactor: metadata store cleanup, SSE unification, mock metadata loading & login redirect fix (#18651)

## Summary
- **SSE unification**: Replaced 11 individual SSE effect components with
a single generic `MetadataStoreSSEEffect`
- **Metadata store cleanup**: Merged `metadataCollectionHashesState`
into `metadataStoreState` (currentCollectionHash / draftCollectionHash
per entity), moved `objectMetadataItemsSelector` to `object-metadata`
domain, converted `navigationMenuItemsState` to a derived selector
- **Naming clarity**: Renamed `isAppMetadataReadyState` →
`isMinimalMetadataReadyState`, `MetadataGater` → `MinimalMetadataGater`,
`useIsLogged` → `useHasAccessTokenPair`,
`patchMetadataStoreFromSSEEvent` now takes named object params
- **Mock metadata loading**: Added `generate-navigation-menu-items.ts`
script, rewrote `useLoadMockedMinimalMetadata` to load full
objects/fields/indexes/views/navItems from generated mock data, enabling
proper sign-in background rendering (table columns, view picker,
navigation)
- **Login/logout transitions**: `MinimalMetadataLoadEffect` manages
mocked↔real metadata transitions based on auth state,
`MainContextStoreProvider` computes context on auth pages for view
picker support
- **Login redirect fix**: `handleLoadWorkspaceAfterAuthentication` now
re-enables `isAppEffectRedirectEnabled` after `loadCurrentUser()`
completes, fixing the blocked post-login navigation
- **Dead code removal**: Deleted `useRefreshPageLayouts`,
`useApplyPageLayouts`, `useStaleMetadataEntities`,
`metadataCollectionHashesState`, and all individual SSE effects

## Test plan
- [x] Login from welcome page redirects to companies page
- [x] Logout transitions cleanly to mocked metadata on welcome page
- [x] Sign-in background shows table columns, view picker, and
navigation items
- [x] SSE events still update metadata store entries correctly
- [x] Navigation menu items persist across page refreshes
- [ ] CI: lint, typecheck, tests pass
This commit is contained in:
Charles Bochet
2026-03-16 00:38:11 +01:00
committed by GitHub
parent 06efee1eef
commit ba9aa41bba
161 changed files with 3106 additions and 4350 deletions
@@ -6,7 +6,6 @@ import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
import { CREATE_MANY_CORE_VIEW_FIELD_GROUPS } from '@/views/graphql/mutations/createManyCoreViewFieldGroups';
import { DELETE_CORE_VIEW_FIELD_GROUP } from '@/views/graphql/mutations/deleteCoreViewFieldGroup';
import { UPDATE_CORE_VIEW_FIELD_GROUP } from '@/views/graphql/mutations/updateCoreViewFieldGroup';
import { useTriggerViewFieldGroupOptimisticEffect } from '@/views/optimistic-effects/hooks/useTriggerViewFieldGroupOptimisticEffect';
import { useMutation } from '@apollo/client/react';
import { CombinedGraphQLErrors } from '@apollo/client/errors';
import { t } from '@lingui/core/macro';
@@ -32,9 +31,6 @@ type DeleteCoreViewFieldGroupMutationResult = {
};
export const usePerformViewFieldGroupAPIPersist = () => {
const { triggerViewFieldGroupOptimisticEffect } =
useTriggerViewFieldGroupOptimisticEffect();
const [createManyCoreViewFieldGroupsMutation] = useMutation<
CreateManyCoreViewFieldGroupsMutationResult,
MutationCreateManyCoreViewFieldGroupsArgs
@@ -70,16 +66,6 @@ export const usePerformViewFieldGroupAPIPersist = () => {
try {
const result = await createManyCoreViewFieldGroupsMutation({
variables: createCoreViewFieldGroupInputs,
update: (_cache, { data }) => {
const createdViewFieldGroups = data?.createManyCoreViewFieldGroups;
if (!isDefined(createdViewFieldGroups)) {
return;
}
triggerViewFieldGroupOptimisticEffect({
createdViewFieldGroups,
});
},
});
return {
@@ -103,7 +89,6 @@ export const usePerformViewFieldGroupAPIPersist = () => {
}
},
[
triggerViewFieldGroupOptimisticEffect,
createManyCoreViewFieldGroupsMutation,
handleMetadataError,
enqueueErrorSnackBar,
@@ -128,16 +113,6 @@ export const usePerformViewFieldGroupAPIPersist = () => {
updateCoreViewFieldGroupInputs.map((variables) =>
updateCoreViewFieldGroupMutation({
variables,
update: (_cache, { data }) => {
const updatedViewFieldGroup = data?.updateCoreViewFieldGroup;
if (!isDefined(updatedViewFieldGroup)) {
return;
}
triggerViewFieldGroupOptimisticEffect({
updatedViewFieldGroups: [updatedViewFieldGroup],
});
},
}),
),
);
@@ -165,7 +140,6 @@ export const usePerformViewFieldGroupAPIPersist = () => {
}
},
[
triggerViewFieldGroupOptimisticEffect,
updateCoreViewFieldGroupMutation,
handleMetadataError,
enqueueErrorSnackBar,
@@ -190,16 +164,6 @@ export const usePerformViewFieldGroupAPIPersist = () => {
deleteCoreViewFieldGroupInputs.map((variables) =>
deleteCoreViewFieldGroupMutation({
variables,
update: (_cache, { data }) => {
const deletedViewFieldGroup = data?.deleteCoreViewFieldGroup;
if (!isDefined(deletedViewFieldGroup)) {
return;
}
triggerViewFieldGroupOptimisticEffect({
deletedViewFieldGroups: [deletedViewFieldGroup],
});
},
}),
),
);
@@ -227,7 +191,6 @@ export const usePerformViewFieldGroupAPIPersist = () => {
}
},
[
triggerViewFieldGroupOptimisticEffect,
deleteCoreViewFieldGroupMutation,
handleMetadataError,
enqueueErrorSnackBar,