Skip to content

Add const / permissions function for help side panel beta #58751

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,7 @@ const CONST = {
NSQS: 'nsqs',
CUSTOM_RULES: 'customRules',
TABLE_REPORT_VIEW: 'tableReportView',
HELP_SIDE_PANEL: 'newDotHelpSidePanel',
},
BUTTON_STATES: {
DEFAULT: 'default',
Expand Down
8 changes: 5 additions & 3 deletions src/hooks/useSidePane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,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';

Expand All @@ -30,10 +31,11 @@ function useSidePane() {
const {windowWidth} = useWindowDimensions();

const [sidePaneNVP] = useOnyx(ONYXKEYS.NVP_SIDE_PANE);
const {canUseHelpSidePanel} = usePermissions();
const [language] = useOnyx(ONYXKEYS.NVP_PREFERRED_LOCALE);
const [isAttachmentModalVisible = false] = useOnyx(ONYXKEYS.MODAL, {selector: (modal) => modal?.type === CONST.MODAL.MODAL_TYPE.CENTERED});
const isLanguageUnsupported = language !== CONST.LOCALES.EN;
const isPaneHidden = isSidePaneHidden(sidePaneNVP, isExtraLargeScreenWidth) || isLanguageUnsupported || isAttachmentModalVisible;
const isPaneHidden = isSidePaneHidden(sidePaneNVP, isExtraLargeScreenWidth) || isLanguageUnsupported || isAttachmentModalVisible || !canUseHelpSidePanel;

const sidePaneWidth = shouldUseNarrowLayout ? windowWidth : variables.sideBarWidth;
const shouldApplySidePaneOffset = isExtraLargeScreenWidth && !isPaneHidden;
Expand All @@ -45,10 +47,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));
Expand Down
5 changes: 5 additions & 0 deletions src/libs/Permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ function canUseTableReportView(betas: OnyxEntry<Beta[]>): boolean {
return !!betas?.includes(CONST.BETAS.TABLE_REPORT_VIEW) || canUseAllBetas(betas);
}

function canUseHelpSidePanel(betas: OnyxEntry<Beta[]>): boolean {
return !!betas?.includes(CONST.BETAS.HELP_SIDE_PANEL) || canUseAllBetas(betas);
}

export default {
canUseDefaultRooms,
canUseLinkPreviews,
Expand All @@ -71,4 +75,5 @@ export default {
canUseNSQS,
canUseCustomRules,
canUseTableReportView,
canUseHelpSidePanel,
};
Loading