Feat: Navbar customization (#17728)

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Co-authored-by: Devessier <baptiste@devessier.fr>
This commit is contained in:
Abdul Rahman
2026-02-11 21:03:51 +05:30
committed by GitHub
parent 52e57e70fd
commit 0902579fbe
166 changed files with 7716 additions and 667 deletions
@@ -0,0 +1,61 @@
import { useSetRecoilState } from 'recoil';
import { v4 } from 'uuid';
import { isDefined } from 'twenty-shared/utils';
import type { NavigationMenuItem } from '~/generated-metadata/graphql';
import { navigationMenuItemsDraftState } from '@/navigation-menu-item/states/navigationMenuItemsDraftState';
import { computeInsertIndexAndPosition } from '@/navigation-menu-item/utils/add-to-navigation-draft.utils';
export const useAddFolderToNavigationMenuDraft = () => {
const setNavigationMenuItemsDraft = useSetRecoilState(
navigationMenuItemsDraftState,
);
const addFolderToDraft = (
name: string,
currentDraft: NavigationMenuItem[],
targetFolderId?: string | null,
targetIndex?: number,
): string => {
const folderId = targetFolderId ?? null;
const itemsInFolder = currentDraft.filter(
(item) =>
(item.folderId ?? null) === folderId &&
!isDefined(item.userWorkspaceId),
);
const index = targetIndex ?? itemsInFolder.length;
const { flatIndex, position } = computeInsertIndexAndPosition(
currentDraft,
folderId,
index,
);
const newItemId = v4();
const newItem: NavigationMenuItem = {
__typename: 'NavigationMenuItem',
id: newItemId,
viewId: undefined,
targetObjectMetadataId: undefined,
targetRecordId: undefined,
folderId: folderId ?? undefined,
position,
userWorkspaceId: undefined,
name: name.trim(),
applicationId: undefined,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
};
const newDraft = [
...currentDraft.slice(0, flatIndex),
newItem,
...currentDraft.slice(flatIndex),
];
setNavigationMenuItemsDraft(newDraft);
return newItemId;
};
return { addFolderToDraft };
};