Skip to content

Commit

Permalink
regression: SIDE-174
Browse files Browse the repository at this point in the history
  • Loading branch information
ggazzo committed Sep 19, 2024
1 parent e9a06e6 commit 54a6b8a
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { FeaturePreview } from '@rocket.chat/ui-client';
import type { ReactElement } from 'react';
import React from 'react';

import { useSidePanelNavigationScreenSize } from '../hooks/useSidePanelNavigation';

export const FeaturePreviewSidePanelNavigation = ({ children }: { children: ReactElement[] }) => {
const disabled = !useSidePanelNavigationScreenSize();
return <FeaturePreview feature='sidepanelNavigation' disabled={disabled} children={children} />;
};
14 changes: 14 additions & 0 deletions apps/meteor/client/hooks/useSidePanelNavigation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { useBreakpoints } from '@rocket.chat/fuselage-hooks';
import { useFeaturePreview } from '@rocket.chat/ui-client';

export const useSidePanelNavigation = () => {
const isSidepanelFeatureEnabled = useFeaturePreview('sidepanelNavigation');
// ["xs", "sm", "md", "lg", "xl", xxl"]
return useSidePanelNavigationScreenSize() && isSidepanelFeatureEnabled;
};

export const useSidePanelNavigationScreenSize = () => {
const breakpoints = useBreakpoints();
// ["xs", "sm", "md", "lg", "xl", xxl"]
return breakpoints.includes('lg');
};
7 changes: 4 additions & 3 deletions apps/meteor/client/views/room/RoomOpener.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import type { RoomType } from '@rocket.chat/core-typings';
import { Box, States, StatesIcon, StatesSubtitle, StatesTitle } from '@rocket.chat/fuselage';
import { FeaturePreview, FeaturePreviewOff, FeaturePreviewOn } from '@rocket.chat/ui-client';
import { FeaturePreviewOff, FeaturePreviewOn } from '@rocket.chat/ui-client';
import type { ReactElement } from 'react';
import React, { lazy, Suspense } from 'react';
import { useTranslation } from 'react-i18next';

import { FeaturePreviewSidePanelNavigation } from '../../components/FeaturePreviewSidePanelNavigation';
import { Header } from '../../components/Header';
import { getErrorMessage } from '../../lib/errorHandling';
import { NotAuthorizedError } from '../../lib/errors/NotAuthorizedError';
Expand Down Expand Up @@ -34,12 +35,12 @@ const RoomOpener = ({ type, reference }: RoomOpenerProps): ReactElement => {
return (
<Box display='flex' w='full' h='full'>
{!isDirectOrOmnichannelRoom(type) && (
<FeaturePreview feature='sidepanelNavigation'>
<FeaturePreviewSidePanelNavigation>
<FeaturePreviewOff>{null}</FeaturePreviewOff>
<FeaturePreviewOn>
<RoomSidepanel />
</FeaturePreviewOn>
</FeaturePreview>
</FeaturePreviewSidePanelNavigation>
)}

<Suspense fallback={<RoomSkeleton />}>
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/client/views/room/providers/RoomProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { IRoom } from '@rocket.chat/core-typings';
import { useFeaturePreview } from '@rocket.chat/ui-client';
import { useRouter } from '@rocket.chat/ui-contexts';
import type { ReactNode, ContextType, ReactElement } from 'react';
import React, { useMemo, memo, useEffect, useCallback } from 'react';
Expand All @@ -10,6 +9,7 @@ import { UserAction } from '../../../../app/ui/client/lib/UserAction';
import { useReactiveQuery } from '../../../hooks/useReactiveQuery';
import { useReactiveValue } from '../../../hooks/useReactiveValue';
import { useRoomInfoEndpoint } from '../../../hooks/useRoomInfoEndpoint';
import { useSidePanelNavigation } from '../../../hooks/useSidePanelNavigation';
import { RoomManager } from '../../../lib/RoomManager';
import { roomCoordinator } from '../../../lib/rooms/roomCoordinator';
import ImageGalleryProvider from '../../../providers/ImageGalleryProvider';
Expand Down Expand Up @@ -92,7 +92,7 @@ const RoomProvider = ({ rid, children }: RoomProviderProps): ReactElement => {
};
}, [hasMoreNextMessages, hasMorePreviousMessages, isLoadingMoreMessages, pseudoRoom, rid, subscriptionQuery.data]);

const isSidepanelFeatureEnabled = useFeaturePreview('sidepanelNavigation');
const isSidepanelFeatureEnabled = useSidePanelNavigation();

useEffect(() => {
if (isSidepanelFeatureEnabled) {
Expand Down

0 comments on commit 54a6b8a

Please sign in to comment.