From 89c4eaacbbff9dee075c9d67bb67cbb75d13a760 Mon Sep 17 00:00:00 2001 From: Francois Laithier Date: Wed, 19 Mar 2025 10:15:47 -0700 Subject: [PATCH 1/2] Add beta const / permissions function for help side panel beta --- src/CONST.ts | 1 + src/libs/Permissions.ts | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/CONST.ts b/src/CONST.ts index 8da7fada9589..1526fac5552f 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -782,6 +782,7 @@ const CONST = { NSQS: 'nsqs', CUSTOM_RULES: 'customRules', TABLE_REPORT_VIEW: 'tableReportView', + HELP_SIDE_PANEL: 'newDotHelpSidePanel', }, BUTTON_STATES: { DEFAULT: 'default', diff --git a/src/libs/Permissions.ts b/src/libs/Permissions.ts index 635e996c322f..67b124bceaa5 100644 --- a/src/libs/Permissions.ts +++ b/src/libs/Permissions.ts @@ -58,6 +58,10 @@ function canUseTableReportView(betas: OnyxEntry): boolean { return !!betas?.includes(CONST.BETAS.TABLE_REPORT_VIEW) || canUseAllBetas(betas); } +function canUseHelpSidePanel(betas: OnyxEntry): boolean { + return !!betas?.includes(CONST.BETAS.HELP_SIDE_PANEL) || canUseAllBetas(betas); +} + export default { canUseDefaultRooms, canUseLinkPreviews, @@ -71,4 +75,5 @@ export default { canUseNSQS, canUseCustomRules, canUseTableReportView, + canUseHelpSidePanel, }; From 9a02023250330506cd19e20930e2b3d3fefed1e4 Mon Sep 17 00:00:00 2001 From: Francois Laithier Date: Wed, 19 Mar 2025 13:09:48 -0700 Subject: [PATCH 2/2] Update `useSidePane` hook to use the new beta --- src/hooks/useSidePane.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/hooks/useSidePane.ts b/src/hooks/useSidePane.ts index a879696359fc..875dbcd8e1c1 100644 --- a/src/hooks/useSidePane.ts +++ b/src/hooks/useSidePane.ts @@ -9,6 +9,7 @@ import variables from '@styles/variables'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type * as OnyxTypes from '@src/types/onyx'; +import usePermissions from './usePermissions'; import useResponsiveLayout from './useResponsiveLayout'; import useWindowDimensions from './useWindowDimensions'; @@ -28,9 +29,10 @@ function useSidePane() { const {windowWidth} = useWindowDimensions(); const [sidePaneNVP] = useOnyx(ONYXKEYS.NVP_SIDE_PANE); + const {canUseHelpSidePanel} = usePermissions(); const [language] = useOnyx(ONYXKEYS.NVP_PREFERRED_LOCALE); const isLanguageUnsupported = language !== CONST.LOCALES.EN; - const isPaneHidden = isSidePaneHidden(sidePaneNVP, isExtraLargeScreenWidth) || isLanguageUnsupported; + const isPaneHidden = isSidePaneHidden(sidePaneNVP, isExtraLargeScreenWidth) || isLanguageUnsupported || !canUseHelpSidePanel; const sidePaneWidth = shouldUseNarrowLayout ? windowWidth : variables.sideBarWidth; const shouldApplySidePaneOffset = isExtraLargeScreenWidth && !isPaneHidden; @@ -42,10 +44,10 @@ function useSidePane() { const shouldHideToolTip = isExtraLargeScreenWidth ? isAnimatingExtraLargeScree : !shouldHideSidePane; // The help button is hidden when: - // - side pane nvp is not set + // - the user is not part of the corresponding beta // - side pane is displayed currently // - language is unsupported - const shouldHideHelpButton = !sidePaneNVP || !isPaneHidden || isLanguageUnsupported; + const shouldHideHelpButton = !canUseHelpSidePanel || !isPaneHidden || isLanguageUnsupported; const sidePaneOffset = useRef(new Animated.Value(shouldApplySidePaneOffset ? variables.sideBarWidth : 0)); const sidePaneTranslateX = useRef(new Animated.Value(isPaneHidden ? sidePaneWidth : 0));