From d70987653b552aadf4422e65f5e81a4ef3742f0a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rapha=C3=ABl=20Bosi?=
<71827178+bosiraphael@users.noreply.github.com>
Date: Tue, 10 Dec 2024 10:56:28 +0100
Subject: [PATCH] 8964 add feature flag is page header v2 enabled (#8995)
Closes #8964
---
.../components/PageFavoriteButton.tsx | 39 +++++++++++-----
.../components/RecordIndexPageHeader.tsx | 7 ++-
.../PageHeaderOpenCommandMenuButton.tsx | 40 +++++++++++-----
.../layout/page/components/PageAddButton.tsx | 46 +++++++++++++------
.../ui/layout/page/components/PageHeader.tsx | 25 +++++++++-
.../components/ShowPageAddButton.tsx | 42 +++++++++++++----
.../modules/workspace/types/FeatureFlagKey.ts | 3 +-
.../typeorm-seeds/core/feature-flags.ts | 5 ++
.../enums/feature-flag-key.enum.ts | 1 +
9 files changed, 160 insertions(+), 48 deletions(-)
diff --git a/packages/twenty-front/src/modules/favorites/components/PageFavoriteButton.tsx b/packages/twenty-front/src/modules/favorites/components/PageFavoriteButton.tsx
index d5c739df00..a286b984c5 100644
--- a/packages/twenty-front/src/modules/favorites/components/PageFavoriteButton.tsx
+++ b/packages/twenty-front/src/modules/favorites/components/PageFavoriteButton.tsx
@@ -1,4 +1,5 @@
-import { Button, IconHeart } from 'twenty-ui';
+import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
+import { Button, IconButton, IconHeart } from 'twenty-ui';
type PageFavoriteButtonProps = {
isFavorite: boolean;
@@ -10,16 +11,32 @@ export const PageFavoriteButton = ({
onClick,
}: PageFavoriteButtonProps) => {
const title = isFavorite ? 'Remove from favorites' : 'Add to favorites';
+ const isPageHeaderV2Enabled = useIsFeatureEnabled(
+ 'IS_PAGE_HEADER_V2_ENABLED',
+ );
return (
-
+ <>
+ {isPageHeaderV2Enabled ? (
+
+ ) : (
+
+ )}
+ >
);
};
diff --git a/packages/twenty-front/src/modules/object-record/record-index/components/RecordIndexPageHeader.tsx b/packages/twenty-front/src/modules/object-record/record-index/components/RecordIndexPageHeader.tsx
index 41e832883e..9a194576e3 100644
--- a/packages/twenty-front/src/modules/object-record/record-index/components/RecordIndexPageHeader.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-index/components/RecordIndexPageHeader.tsx
@@ -8,6 +8,7 @@ import { PageAddButton } from '@/ui/layout/page/components/PageAddButton';
import { PageHeader } from '@/ui/layout/page/components/PageHeader';
import { PageHotkeysEffect } from '@/ui/layout/page/components/PageHotkeysEffect';
import { ViewType } from '@/views/types/ViewType';
+import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
import { useContext } from 'react';
import { useRecoilValue } from 'recoil';
import { useIcons } from 'twenty-ui';
@@ -44,6 +45,10 @@ export const RecordIndexPageHeader = () => {
onCreateRecord();
};
+ const isPageHeaderV2Enabled = useIsFeatureEnabled(
+ 'IS_PAGE_HEADER_V2_ENABLED',
+ );
+
return (
@@ -53,7 +58,7 @@ export const RecordIndexPageHeader = () => {
) : (
))}
-
+ {isPageHeaderV2Enabled && }
);
};
diff --git a/packages/twenty-front/src/modules/ui/layout/page-header/components/PageHeaderOpenCommandMenuButton.tsx b/packages/twenty-front/src/modules/ui/layout/page-header/components/PageHeaderOpenCommandMenuButton.tsx
index 6553fc5eb2..5ae26134f5 100644
--- a/packages/twenty-front/src/modules/ui/layout/page-header/components/PageHeaderOpenCommandMenuButton.tsx
+++ b/packages/twenty-front/src/modules/ui/layout/page-header/components/PageHeaderOpenCommandMenuButton.tsx
@@ -1,20 +1,38 @@
-import { Button, IconDotsVertical } from 'twenty-ui';
+import { Button, IconButton, IconDotsVertical } from 'twenty-ui';
import { useCommandMenu } from '@/command-menu/hooks/useCommandMenu';
+import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
export const PageHeaderOpenCommandMenuButton = () => {
const { openCommandMenu } = useCommandMenu();
+ const isPageHeaderV2Enabled = useIsFeatureEnabled(
+ 'IS_PAGE_HEADER_V2_ENABLED',
+ );
+
return (
-
+ <>
+ {isPageHeaderV2Enabled ? (
+
+ ) : (
+
+ )}
+ >
);
};
diff --git a/packages/twenty-front/src/modules/ui/layout/page/components/PageAddButton.tsx b/packages/twenty-front/src/modules/ui/layout/page/components/PageAddButton.tsx
index 12dd70926e..05ecb17a61 100644
--- a/packages/twenty-front/src/modules/ui/layout/page/components/PageAddButton.tsx
+++ b/packages/twenty-front/src/modules/ui/layout/page/components/PageAddButton.tsx
@@ -1,18 +1,38 @@
-import { Button, IconPlus } from 'twenty-ui';
+import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
+import { Button, IconButton, IconPlus } from 'twenty-ui';
type PageAddButtonProps = {
onClick?: () => void;
};
-export const PageAddButton = ({ onClick }: PageAddButtonProps) => (
-
-);
+export const PageAddButton = ({ onClick }: PageAddButtonProps) => {
+ const isPageHeaderV2Enabled = useIsFeatureEnabled(
+ 'IS_PAGE_HEADER_V2_ENABLED',
+ );
+ return (
+ <>
+ {isPageHeaderV2Enabled ? (
+
+ ) : (
+
+ )}
+ >
+ );
+};
diff --git a/packages/twenty-front/src/modules/ui/layout/page/components/PageHeader.tsx b/packages/twenty-front/src/modules/ui/layout/page/components/PageHeader.tsx
index 92ad7d505b..a9a4d9c526 100644
--- a/packages/twenty-front/src/modules/ui/layout/page/components/PageHeader.tsx
+++ b/packages/twenty-front/src/modules/ui/layout/page/components/PageHeader.tsx
@@ -17,6 +17,7 @@ import { NavigationDrawerCollapseButton } from '@/ui/navigation/navigation-drawe
import { isNavigationDrawerExpandedState } from '@/ui/navigation/states/isNavigationDrawerExpanded';
import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
export const PAGE_BAR_MIN_HEIGHT = 40;
@@ -111,6 +112,10 @@ export const PageHeader = ({
isNavigationDrawerExpandedState,
);
+ const isPageHeaderV2Enabled = useIsFeatureEnabled(
+ 'IS_PAGE_HEADER_V2_ENABLED',
+ );
+
return (
@@ -129,6 +134,24 @@ export const PageHeader = ({
)}
+ {!isPageHeaderV2Enabled && hasPaginationButtons && (
+ <>
+ navigateToPreviousRecord?.()}
+ />
+ navigateToNextRecord?.()}
+ />
+ >
+ )}
{Icon && }
{title && (
@@ -143,7 +166,7 @@ export const PageHeader = ({
- {hasPaginationButtons && (
+ {isPageHeaderV2Enabled && hasPaginationButtons && (
<>
+ isPageHeaderV2Enabled ? (
+
+ ) : (
+
+ )
}
dropdownComponents={
diff --git a/packages/twenty-front/src/modules/workspace/types/FeatureFlagKey.ts b/packages/twenty-front/src/modules/workspace/types/FeatureFlagKey.ts
index e22e683584..e8ae5e7d70 100644
--- a/packages/twenty-front/src/modules/workspace/types/FeatureFlagKey.ts
+++ b/packages/twenty-front/src/modules/workspace/types/FeatureFlagKey.ts
@@ -18,4 +18,5 @@ export type FeatureFlagKey =
| 'IS_ADVANCED_FILTERS_ENABLED'
| 'IS_AGGREGATE_QUERY_ENABLED'
| 'IS_FAVORITE_FOLDER_ENABLED'
- | 'IS_VIEW_GROUPS_ENABLED';
+ | 'IS_VIEW_GROUPS_ENABLED'
+ | 'IS_PAGE_HEADER_V2_ENABLED';
diff --git a/packages/twenty-server/src/database/typeorm-seeds/core/feature-flags.ts b/packages/twenty-server/src/database/typeorm-seeds/core/feature-flags.ts
index ec6810676f..4855f1451c 100644
--- a/packages/twenty-server/src/database/typeorm-seeds/core/feature-flags.ts
+++ b/packages/twenty-server/src/database/typeorm-seeds/core/feature-flags.ts
@@ -95,6 +95,11 @@ export const seedFeatureFlags = async (
workspaceId: workspaceId,
value: true,
},
+ {
+ key: FeatureFlagKey.IsPageHeaderV2Enabled,
+ workspaceId: workspaceId,
+ value: true,
+ },
])
.execute();
};
diff --git a/packages/twenty-server/src/engine/core-modules/feature-flag/enums/feature-flag-key.enum.ts b/packages/twenty-server/src/engine/core-modules/feature-flag/enums/feature-flag-key.enum.ts
index 8f2f8ee9b6..e917baffe9 100644
--- a/packages/twenty-server/src/engine/core-modules/feature-flag/enums/feature-flag-key.enum.ts
+++ b/packages/twenty-server/src/engine/core-modules/feature-flag/enums/feature-flag-key.enum.ts
@@ -18,4 +18,5 @@ export enum FeatureFlagKey {
IsFavoriteFolderEnabled = 'IS_FAVORITE_FOLDER_ENABLED',
IsFavoriteFolderEntityEnabled = 'IS_FAVORITE_FOLDER_ENTITY_ENABLED',
IsViewGroupsEnabled = 'IS_VIEW_GROUPS_ENABLED',
+ IsPageHeaderV2Enabled = 'IS_PAGE_HEADER_V2_ENABLED',
}