Skip to content

Commit

Permalink
Hide user info actions
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriellsh committed Dec 7, 2023
1 parent fa98d77 commit 2534b5e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
13 changes: 13 additions & 0 deletions apps/meteor/client/providers/LayoutProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ const messageToolbox = [

const composerToolbox = ['video-message' /* 'audio-message' */, 'file-upload', /* 'create-discussion', */ 'webdav-add', 'share-location'];

const userToolbox = [
'openDirectMessage',
'changeOwner',
'changeLeader',
'changeModerator',
'openModerationConsole',
'ignoreUser',
'muteUser',
'reportUser',
'removeUser',
];

const LayoutProvider: FC = ({ children }) => {
const showTopNavbarEmbeddedLayout = Boolean(useSetting('UI_Show_top_navbar_embedded_layout'));
const [isCollapsed, setIsCollapsed] = useState(false);
Expand Down Expand Up @@ -91,6 +103,7 @@ const LayoutProvider: FC = ({ children }) => {
roomToolbox,
messageToolbox,
composerToolbox,
userToolbox,
},
}),
[isMobile, isEmbedded, showTopNavbarEmbeddedLayout, isCollapsed, breakpoints, router],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { IRoom, IUser } from '@rocket.chat/core-typings';
import type { Icon } from '@rocket.chat/fuselage';
import { useLayoutHiddenActions } from '@rocket.chat/ui-contexts';
import type { ComponentProps } from 'react';
import { useMemo } from 'react';

Expand Down Expand Up @@ -51,6 +52,7 @@ export const useUserInfoActions = (
const call = useCallAction(user);
const reportUserOption = useReportUser(user);
const isLayoutEmbedded = useEmbeddedLayout();
const { userToolbox: hiddenActions } = useLayoutHiddenActions();

const userinfoActions = useMemo(
() => ({
Expand Down Expand Up @@ -83,7 +85,7 @@ export const useUserInfoActions = (
);

const actionSpread = useMemo(() => {
const entries = Object.entries(userinfoActions);
const entries = Object.entries(userinfoActions).filter(([key]) => !hiddenActions.includes(key));

const options = entries.slice(0, size);
const slicedOptions = entries.slice(size, entries.length);
Expand All @@ -105,7 +107,7 @@ export const useUserInfoActions = (
}, [] as UserMenuAction);

return { actions: options, menuActions };
}, [size, userinfoActions]);
}, [size, userinfoActions, hiddenActions]);

return actionSpread;
};
2 changes: 2 additions & 0 deletions packages/ui-contexts/src/LayoutContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export type LayoutContextValue = {
roomToolbox: Array<string>;
messageToolbox: Array<string>;
composerToolbox: Array<string>;
userToolbox: Array<string>;
};
};

Expand All @@ -49,5 +50,6 @@ export const LayoutContext = createContext<LayoutContextValue>({
roomToolbox: [],
messageToolbox: [],
composerToolbox: [],
userToolbox: [],
},
});

0 comments on commit 2534b5e

Please sign in to comment.