b27a97f2c5
## Summary This PR enforces the use of `@/` alias for imports instead of relative parent imports (`../`). ## Changes ### ESLint Configuration - Added `no-restricted-imports` pattern in `eslint.config.react.mjs` to block `../*` imports with the message "Relative parent imports are not allowed. Use @/ alias instead." - Removed the non-working `import/no-relative-parent-imports` rule (doesn't work properly in ESLint flat config) ### VS Code Settings - Added `javascript.preferences.importModuleSpecifier: non-relative` to `.vscode/settings.json` (TypeScript setting was already there) ### Code Fixes - Fixed **941 relative parent imports** across **706 files** in `packages/twenty-front` - All `../` imports converted to use `@/` alias ## Why - Consistent import style across the codebase - Easier to move files without breaking imports - Better IDE support for auto-imports - Clearer understanding of where imports come from
71 lines
2.2 KiB
TypeScript
71 lines
2.2 KiB
TypeScript
import { useRecoilCallback } from 'recoil';
|
|
import { v4 } from 'uuid';
|
|
|
|
import { DIALOG_FOCUS_ID } from '@/ui/feedback/dialog-manager/constants/DialogFocusId';
|
|
import { useRemoveFocusItemFromFocusStackById } from '@/ui/utilities/focus/hooks/useRemoveFocusItemFromFocusStackById';
|
|
|
|
import { DialogComponentInstanceContext } from '@/ui/feedback/dialog-manager/contexts/DialogComponentInstanceContext';
|
|
import { useAvailableComponentInstanceIdOrThrow } from '@/ui/utilities/state/component-state/hooks/useAvailableComponentInstanceIdOrThrow';
|
|
import { dialogInternalComponentState } from '@/ui/feedback/dialog-manager/states/dialogInternalComponentState';
|
|
import { type DialogOptions } from '@/ui/feedback/dialog-manager/types/DialogOptions';
|
|
|
|
export const useDialogManager = () => {
|
|
const componentInstanceId = useAvailableComponentInstanceIdOrThrow(
|
|
DialogComponentInstanceContext,
|
|
);
|
|
|
|
const { removeFocusItemFromFocusStackById } =
|
|
useRemoveFocusItemFromFocusStackById();
|
|
|
|
const closeDialog = useRecoilCallback(
|
|
({ set }) =>
|
|
(id: string) => {
|
|
set(
|
|
dialogInternalComponentState.atomFamily({
|
|
instanceId: componentInstanceId,
|
|
}),
|
|
(prevState) => ({
|
|
...prevState,
|
|
queue: prevState.queue.filter((dialog) => dialog.id !== id),
|
|
}),
|
|
);
|
|
|
|
removeFocusItemFromFocusStackById({ focusId: DIALOG_FOCUS_ID });
|
|
},
|
|
[componentInstanceId, removeFocusItemFromFocusStackById],
|
|
);
|
|
|
|
const setDialogQueue = useRecoilCallback(
|
|
({ set }) =>
|
|
(newValue) =>
|
|
set(
|
|
dialogInternalComponentState.atomFamily({
|
|
instanceId: componentInstanceId,
|
|
}),
|
|
(prev) => {
|
|
if (prev.queue.length >= prev.maxQueue) {
|
|
return {
|
|
...prev,
|
|
queue: [...prev.queue.slice(1), newValue] as DialogOptions[],
|
|
};
|
|
}
|
|
|
|
return {
|
|
...prev,
|
|
queue: [...prev.queue, newValue] as DialogOptions[],
|
|
};
|
|
},
|
|
),
|
|
[componentInstanceId],
|
|
);
|
|
|
|
const enqueueDialog = (options?: Omit<DialogOptions, 'id'>) => {
|
|
setDialogQueue({
|
|
id: v4(),
|
|
...options,
|
|
});
|
|
};
|
|
|
|
return { closeDialog, enqueueDialog };
|
|
};
|