The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Fix deactivated tabs not visible in new tab action (#19811)
Weikoa18840f3cdbb
diff --git a/packages/twenty-front/src/modules/page-layout/components/PageLayoutTabListNewTabDropdownContent.tsx b/packages/twenty-front/src/modules/page-layout/components/PageLayoutTabListNewTabDropdownContent.tsxindex 9ba1c871f69..f9cbb8f9f24 100644--- a/packages/twenty-front/src/modules/page-layout/components/PageLayoutTabListNewTabDropdownContent.tsx+++ b/packages/twenty-front/src/modules/page-layout/components/PageLayoutTabListNewTabDropdownContent.tsx@@ -1,7 +1,6 @@import { STANDARD_PAGE_LAYOUT_TAB_TITLE_TRANSLATIONS } from '@/page-layout/constants/StandardPageLayoutTabTitleTranslations';import { useCurrentPageLayoutOrThrow } from '@/page-layout/hooks/useCurrentPageLayoutOrThrow';import { useIsCurrentObjectCustom } from '@/page-layout/hooks/useIsCurrentObjectCustom';-import { useRecordPageLayoutObjectApplicationId } from '@/page-layout/hooks/useRecordPageLayoutObjectApplicationId';import { useUpdatePageLayoutTab } from '@/page-layout/hooks/useUpdatePageLayoutTab';import { pageLayoutTabSettingsOpenTabIdComponentState } from '@/page-layout/states/pageLayoutTabSettingsOpenTabIdComponentState';import { isReactivatableTab } from '@/page-layout/utils/isReactivatableTab';@@ -39,7 +38,6 @@ export const PageLayoutTabListNewTabDropdownContent = ({const shouldTranslateTabTitles = !isCustom;const { currentPageLayout } = useCurrentPageLayoutOrThrow();- const { objectApplicationId } = useRecordPageLayoutObjectApplicationId();const { updatePageLayoutTab } = useUpdatePageLayoutTab();const setActiveTabId = useSetAtomComponentState(activeTabIdComponentState);@@ -49,13 +47,8 @@ export const PageLayoutTabListNewTabDropdownContent = ({const { navigatePageLayoutSidePanel } = useNavigatePageLayoutSidePanel();const inactiveTabs = useMemo(- () =>- sortTabsByPosition(- currentPageLayout.tabs.filter((tab) =>- isReactivatableTab({ tab, objectApplicationId }),- ),- ),- [currentPageLayout.tabs, objectApplicationId],+ () => sortTabsByPosition(currentPageLayout.tabs.filter(isReactivatableTab)),+ [currentPageLayout.tabs],);const handleCreateEmptyTab = useCallback(() => {diff --git a/packages/twenty-front/src/modules/page-layout/hooks/usePageLayoutAddTabStrategy.ts b/packages/twenty-front/src/modules/page-layout/hooks/usePageLayoutAddTabStrategy.tsindex 172f976bb90..0223c2fb15b 100644--- a/packages/twenty-front/src/modules/page-layout/hooks/usePageLayoutAddTabStrategy.ts+++ b/packages/twenty-front/src/modules/page-layout/hooks/usePageLayoutAddTabStrategy.ts@@ -1,7 +1,6 @@import { useCreatePageLayoutTab } from '@/page-layout/hooks/useCreatePageLayoutTab';import { useCurrentPageLayoutOrThrow } from '@/page-layout/hooks/useCurrentPageLayoutOrThrow';import { useIsPageLayoutInEditMode } from '@/page-layout/hooks/useIsPageLayoutInEditMode';-import { useRecordPageLayoutObjectApplicationId } from '@/page-layout/hooks/useRecordPageLayoutObjectApplicationId';import { pageLayoutTabSettingsOpenTabIdComponentState } from '@/page-layout/states/pageLayoutTabSettingsOpenTabIdComponentState';import { type PageLayoutAddTabStrategy } from '@/page-layout/types/PageLayoutAddTabStrategy';import { isReactivatableTab } from '@/page-layout/utils/isReactivatableTab';@@ -25,7 +24,6 @@ export const usePageLayoutAddTabStrategy = ({}): PageLayoutAddTabStrategy | undefined => {const { currentPageLayout } = useCurrentPageLayoutOrThrow();const isPageLayoutInEditMode = useIsPageLayoutInEditMode();- const { objectApplicationId } = useRecordPageLayoutObjectApplicationId();const isRecordPageGlobalEditionEnabled = useIsFeatureEnabled(FeatureFlagKey.IS_RECORD_PAGE_LAYOUT_GLOBAL_EDITION_ENABLED,@@ -77,9 +75,7 @@ export const usePageLayoutAddTabStrategy = ({return undefined;}- const hasInactiveTabs = currentPageLayout.tabs.some((tab) =>- isReactivatableTab({ tab, objectApplicationId }),- );+ const hasInactiveTabs = currentPageLayout.tabs.some(isReactivatableTab);const mode =currentPageLayout.type === PageLayoutType.RECORD_PAGE && hasInactiveTabsdiff --git a/packages/twenty-front/src/modules/page-layout/hooks/useRecordPageLayoutObjectApplicationId.ts b/packages/twenty-front/src/modules/page-layout/hooks/useRecordPageLayoutObjectApplicationId.tsdeleted file mode 100644index ad03e7d0590..00000000000--- a/packages/twenty-front/src/modules/page-layout/hooks/useRecordPageLayoutObjectApplicationId.ts+++ /dev/null@@ -1,25 +0,0 @@-import { objectMetadataItemsSelector } from '@/object-metadata/states/objectMetadataItemsSelector';-import { useCurrentPageLayoutOrThrow } from '@/page-layout/hooks/useCurrentPageLayoutOrThrow';-import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';-import { isDefined } from 'twenty-shared/utils';--export const useRecordPageLayoutObjectApplicationId = (): {- objectApplicationId: string | undefined;-} => {- const { currentPageLayout } = useCurrentPageLayoutOrThrow();- const objectMetadataItems = useAtomStateValue(objectMetadataItemsSelector);-- const objectMetadataId = currentPageLayout.objectMetadataId;-- if (!isDefined(objectMetadataId)) {- return { objectApplicationId: undefined };- }-- const objectMetadataItem = objectMetadataItems.find(- (item) => item.id === objectMetadataId,- );-- return {- objectApplicationId: objectMetadataItem?.applicationId,- };-};diff --git a/packages/twenty-front/src/modules/page-layout/utils/__tests__/isReactivatableTab.test.ts b/packages/twenty-front/src/modules/page-layout/utils/__tests__/isReactivatableTab.test.tsindex 0272442e648..3e339a772f3 100644--- a/packages/twenty-front/src/modules/page-layout/utils/__tests__/isReactivatableTab.test.ts+++ b/packages/twenty-front/src/modules/page-layout/utils/__tests__/isReactivatableTab.test.ts@@ -17,35 +17,15 @@ const makeTab = (overrides: Partial<PageLayoutTab> = {}): PageLayoutTab =>}) as unknown as PageLayoutTab;describe('isReactivatableTab', () => {- it('should return true when tab is inactive and applicationId matches', () => {- const tab = makeTab({ isActive: false, applicationId: 'app-1' });+ it('should return true when tab is inactive', () => {+ const tab = makeTab({ isActive: false });- expect(isReactivatableTab({ tab, objectApplicationId: 'app-1' })).toBe(- true,- );+ expect(isReactivatableTab(tab)).toBe(true);});it('should return false when tab is active', () => {- const tab = makeTab({ isActive: true, applicationId: 'app-1' });+ const tab = makeTab({ isActive: true });- expect(isReactivatableTab({ tab, objectApplicationId: 'app-1' })).toBe(- false,- );- });-- it('should return false when applicationId does not match', () => {- const tab = makeTab({ isActive: false, applicationId: 'app-1' });-- expect(isReactivatableTab({ tab, objectApplicationId: 'app-2' })).toBe(- false,- );- });-- it('should return false when objectApplicationId is undefined', () => {- const tab = makeTab({ isActive: false, applicationId: 'app-1' });-- expect(isReactivatableTab({ tab, objectApplicationId: undefined })).toBe(- false,- );+ expect(isReactivatableTab(tab)).toBe(false);});});diff --git a/packages/twenty-front/src/modules/page-layout/utils/isReactivatableTab.ts b/packages/twenty-front/src/modules/page-layout/utils/isReactivatableTab.tsindex 842ac6fff67..68ad09604d8 100644--- a/packages/twenty-front/src/modules/page-layout/utils/isReactivatableTab.ts+++ b/packages/twenty-front/src/modules/page-layout/utils/isReactivatableTab.ts@@ -1,11 +1,4 @@import { type PageLayoutTab } from '@/page-layout/types/PageLayoutTab';-export const isReactivatableTab = ({- tab,- objectApplicationId,-}: {- tab: PageLayoutTab;- objectApplicationId: string | undefined;-}): boolean => {- return !tab.isActive && tab.applicationId === objectApplicationId;-};+export const isReactivatableTab = (tab: PageLayoutTab): boolean =>+ !tab.isActive;