f7cde28dd6
## Problem **CRITICAL:** Two PRs were accidentally reverted when PR #14347 "Prevent csv export injections" was merged: 1. **PR #14348** "[Page Layout] - Review Refactor" - ✅ **RESTORED** 2. **PR #14352** "Fix wrong path used by backend" - ✅ **RESTORED** ## Root Cause Analysis During the merge of PR #14347, there was a complex merge conflict with PR #14352 "Fix wrong path used by backend". The merge commit `324d7204bb` in the PR #14347 branch brought in changes from PR #14352, but during the conflict resolution, **BOTH PR #14348 and PR #14352's changes were accidentally overwritten**. ## What This PR Restores This PR restores **BOTH** PRs by cherry-picking their commits: ### ✅ PR #14348 Changes Restored: - `GraphWidgetRenderer.tsx` - was deleted, now restored - `WidgetRenderer.tsx` - was missing, now restored - `SettingsPageLayoutTabsInstanceId.ts` - was deleted, now restored - `useUpdatePageLayoutWidget.ts` - was renamed back, now restored with correct name - Multiple test files that were deleted - Several hook files that were renamed/reverted - File renames: `usePageLayoutWidgetUpdate.ts` → `useUpdatePageLayoutWidget.ts` - Hook refactoring and test file organization - Page layout component improvements ### ✅ PR #14352 Changes Restored: - **Types moved to twenty-shared:** - `packages/twenty-shared/src/types/AppBasePath.ts` ✅ RESTORED - `packages/twenty-shared/src/types/AppPath.ts` ✅ RESTORED - `packages/twenty-shared/src/types/SettingsPath.ts` ✅ RESTORED - **Navigation utilities moved to twenty-shared:** - `packages/twenty-shared/src/utils/navigation/getAppPath.ts` ✅ RESTORED - `packages/twenty-shared/src/utils/navigation/getSettingsPath.ts` ✅ RESTORED - **200+ import statements updated** across the codebase to use twenty-shared - **Old type files deleted** from twenty-front/src/modules/types/ ## Evidence of Complete Restoration **Before (reverted state):** - ❌ Types were in `packages/twenty-front/src/modules/types/` - ❌ Page layout files missing - ❌ Hook files incorrectly named **After (this PR):** - ✅ Types correctly in `packages/twenty-shared/src/types/` - ✅ All page layout files restored - ✅ Hook files correctly named - ✅ All import statements updated ## Verification **Total changes:** - PR #14348: 36 files changed, 863 insertions(+), 442 deletions(-) - PR #14352: 243 files changed, 492 insertions(+), 461 deletions(-) - **Combined: 279 files changed, 1355 insertions(+), 903 deletions(-)** ## Impact This completely restores both PRs that were accidentally lost, ensuring: 1. Page layout refactoring work is back 2. Type organization and path utilities are correctly in twenty-shared 3. Backend email paths work correctly again 4. No functionality is lost Fixes the reversion caused by the merge conflict in PR #14347. --------- Co-authored-by: nitin <142569587+ehconitin@users.noreply.github.com>
117 lines
4.5 KiB
TypeScript
117 lines
4.5 KiB
TypeScript
import { AdvancedSettingsWrapper } from '@/settings/components/AdvancedSettingsWrapper';
|
|
import { SettingsNavigationDrawerItem } from '@/settings/components/SettingsNavigationDrawerItem';
|
|
import {
|
|
type SettingsNavigationItem,
|
|
type SettingsNavigationSection,
|
|
useSettingsNavigationItems,
|
|
} from '@/settings/hooks/useSettingsNavigationItems';
|
|
import { NavigationDrawerItemGroup } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerItemGroup';
|
|
import { NavigationDrawerSection } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerSection';
|
|
import { NavigationDrawerSectionTitle } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerSectionTitle';
|
|
import { getNavigationSubItemLeftAdornment } from '@/ui/navigation/navigation-drawer/utils/getNavigationSubItemLeftAdornment';
|
|
import { matchPath, resolvePath, useLocation } from 'react-router-dom';
|
|
import { getSettingsPath } from 'twenty-shared/utils';
|
|
|
|
export const SettingsNavigationDrawerItems = () => {
|
|
const settingsNavigationItems: SettingsNavigationSection[] =
|
|
useSettingsNavigationItems();
|
|
|
|
const currentPathName = useLocation().pathname;
|
|
|
|
const getSelectedIndexForSubItems = (subItems: SettingsNavigationItem[]) => {
|
|
return subItems.findIndex((subItem) => {
|
|
const href = subItem.path ? getSettingsPath(subItem.path) : '';
|
|
const pathName = resolvePath(href).pathname;
|
|
|
|
return matchPath(
|
|
{
|
|
path: pathName,
|
|
end: subItem.matchSubPages === false,
|
|
},
|
|
currentPathName,
|
|
);
|
|
});
|
|
};
|
|
|
|
return (
|
|
<>
|
|
{settingsNavigationItems.map((section) => {
|
|
const allItemsHidden = section.items.every((item) => item.isHidden);
|
|
if (allItemsHidden) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<NavigationDrawerSection key={section.label}>
|
|
{section.isAdvanced ? (
|
|
<AdvancedSettingsWrapper hideDot>
|
|
<NavigationDrawerSectionTitle label={section.label} />
|
|
</AdvancedSettingsWrapper>
|
|
) : (
|
|
<NavigationDrawerSectionTitle label={section.label} />
|
|
)}
|
|
{section.items.map((item, index) => {
|
|
const subItems = item.subItems;
|
|
if (Array.isArray(subItems) && subItems.length > 0) {
|
|
const selectedSubItemIndex =
|
|
getSelectedIndexForSubItems(subItems);
|
|
const hasActiveSubItem = selectedSubItemIndex !== -1;
|
|
|
|
return (
|
|
<NavigationDrawerItemGroup
|
|
key={item.path || `group-${index}`}
|
|
>
|
|
<SettingsNavigationDrawerItem
|
|
item={item}
|
|
hasActiveSubItem={hasActiveSubItem}
|
|
subItemState={
|
|
item.indentationLevel
|
|
? getNavigationSubItemLeftAdornment({
|
|
arrayLength: section.items.length,
|
|
index,
|
|
selectedIndex: selectedSubItemIndex,
|
|
})
|
|
: undefined
|
|
}
|
|
/>
|
|
{subItems.map((subItem, subIndex) => (
|
|
<SettingsNavigationDrawerItem
|
|
key={subItem.path || `subitem-${subIndex}`}
|
|
item={subItem}
|
|
subItemState={
|
|
subItem.indentationLevel
|
|
? getNavigationSubItemLeftAdornment({
|
|
arrayLength: subItems.length,
|
|
index: subIndex,
|
|
selectedIndex: selectedSubItemIndex,
|
|
})
|
|
: undefined
|
|
}
|
|
/>
|
|
))}
|
|
</NavigationDrawerItemGroup>
|
|
);
|
|
}
|
|
return (
|
|
<SettingsNavigationDrawerItem
|
|
key={item.path || `item-${index}`}
|
|
item={item}
|
|
subItemState={
|
|
item.indentationLevel
|
|
? getNavigationSubItemLeftAdornment({
|
|
arrayLength: section.items.length,
|
|
index,
|
|
selectedIndex: index,
|
|
})
|
|
: undefined
|
|
}
|
|
/>
|
|
);
|
|
})}
|
|
</NavigationDrawerSection>
|
|
);
|
|
})}
|
|
</>
|
|
);
|
|
};
|