Skip to content
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

feat: add accounts setting to reorganize sections #32744

Merged
merged 5 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions .changeset/selfish-emus-sing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@rocket.chat/meteor": minor
"@rocket.chat/i18n": minor
---

Added account setting `Accounts_Default_User_Preferences_sidebarSectionsOrder` to allow users to reorganize sidebar sections
41 changes: 39 additions & 2 deletions apps/meteor/client/sidebar/hooks/useRoomList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,39 @@ const query = { open: { $ne: false } };

const emptyQueue: ILivechatInquiryRecord[] = [];

const order: (
| 'Incoming_Calls'
| 'Incoming_Livechats'
| 'Open_Livechats'
| 'On_Hold_Chats'
| 'Unread'
| 'Favorites'
| 'Teams'
| 'Discussions'
| 'Channels'
| 'Direct_Messages'
| 'Conversations'
)[] = [
'Incoming_Calls',
'Incoming_Livechats',
'Open_Livechats',
'On_Hold_Chats',
'Unread',
'Favorites',
'Teams',
'Discussions',
'Channels',
'Direct_Messages',
'Conversations',
];

export const useRoomList = (): Array<ISubscription & IRoom> => {
const [roomList, setRoomList] = useDebouncedState<(ISubscription & IRoom)[]>([], 150);

const showOmnichannel = useOmnichannelEnabled();
const sidebarGroupByType = useUserPreference('sidebarGroupByType');
const favoritesEnabled = useUserPreference('sidebarShowFavorites');
const sidebarOrder = useUserPreference<typeof order>('sidebarSectionsOrder') ?? order;
const isDiscussionEnabled = useSetting('Discussion_enabled');
const sidebarShowUnread = useUserPreference('sidebarShowUnread');

Expand Down Expand Up @@ -92,7 +119,7 @@ export const useRoomList = (): Array<ISubscription & IRoom> => {
});

const groups = new Map();
incomingCall.size && groups.set('Incoming Calls', incomingCall);
incomingCall.size && groups.set('Incoming_Calls', incomingCall);
showOmnichannel && inquiries.enabled && queue.length && groups.set('Incoming_Livechats', queue);
showOmnichannel && omnichannel.size && groups.set('Open_Livechats', omnichannel);
showOmnichannel && onHold.size && groups.set('On_Hold_Chats', onHold);
Expand All @@ -103,7 +130,16 @@ export const useRoomList = (): Array<ISubscription & IRoom> => {
sidebarGroupByType && channels.size && groups.set('Channels', channels);
sidebarGroupByType && direct.size && groups.set('Direct_Messages', direct);
!sidebarGroupByType && groups.set('Conversations', conversation);
return [...groups.entries()].flatMap(([key, group]) => [key, ...group]);
return sidebarOrder
.map((key) => {
const group = groups.get(key);
if (!group) {
return [];
}

return [key, ...group];
})
.flat();
});
}, [
rooms,
Expand All @@ -116,6 +152,7 @@ export const useRoomList = (): Array<ISubscription & IRoom> => {
sidebarGroupByType,
setRoomList,
isDiscussionEnabled,
sidebarOrder,
]);

return roomList;
Expand Down
22 changes: 22 additions & 0 deletions apps/meteor/server/settings/accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,28 @@ export const createAccountSettings = () =>
public: true,
i18nLabel: 'VideoConf_Mobile_Ringing',
});

const defaultUserPreferencesSidebarSectionsOrder = [
'Incoming_Calls',
'Incoming_Livechats',
'Open_Livechats',
'On_Hold_Chats',
'Unread',
'Favorites',
'Teams',
'Discussions',
'Channels',
'Direct_Messages',
'Conversations',
];

await this.add('Accounts_Default_User_Preferences_sidebarSectionsOrder', defaultUserPreferencesSidebarSectionsOrder, {
type: 'multiSelect',
public: true,
values: defaultUserPreferencesSidebarSectionsOrder.map((key) => ({ key, i18nLabel: key })),
i18nLabel: 'Sidebar_Sections_Order',
i18nDescription: 'Sidebar_Sections_Order_Description',
});
});

await this.section('Avatar', async function () {
Expand Down
1 change: 1 addition & 0 deletions apps/meteor/tests/end-to-end/api/miscellaneous.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ describe('miscellaneous', () => {
'sidebarViewMode',
'sidebarDisplayAvatar',
'sidebarGroupByType',
'sidebarSectionsOrder',
'muteFocusedConversations',
'notifyCalendarEvents',
'enableMobileRinging',
Expand Down
11 changes: 7 additions & 4 deletions packages/i18n/src/locales/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -2699,7 +2699,7 @@
"Inclusive": "Inclusive",
"Incoming": "Incoming",
"Incoming_call_from": "Incoming call from",
"Incoming_Livechats": "Queued Chats",
"Incoming_Livechats": "Queued chats",
"Incoming_WebHook": "Incoming WebHook",
"Industry": "Industry",
"Info": "Info",
Expand Down Expand Up @@ -4016,7 +4016,7 @@
"on-hold-others-livechat-room": "On Hold Others Omnichannel Room",
"on-hold-others-livechat-room_description": "Permission to on hold others omnichannel room",
"On_Hold": "On hold",
"On_Hold_Chats": "On Hold",
"On_Hold_Chats": "On hold",
"On_Hold_conversations": "On hold conversations",
"online": "online",
"Online": "Online",
Expand All @@ -4040,7 +4040,7 @@
"Open_days_of_the_week": "Open Days of the Week",
"Open_Dialpad": "Open Dialpad",
"Open_directory": "Open directory",
"Open_Livechats": "Chats in Progress",
"Open_Livechats": "Chats in progress",
"Open_Outlook": "Open Outlook",
"Open_settings": "Open settings",
"Open_sidebar": "Open sidebar",
Expand Down Expand Up @@ -6480,5 +6480,8 @@
"You_cant_take_chats_offline": "You cannot take new conversations because you're offline",
"New_navigation": "Enhanced navigation experience",
"New_navigation_description": "Explore our improved navigation, designed with clear scopes for easy access to what you need. This change serves as the foundation for future advancements in navigation management.",
"Workspace_and_user_settings": "Workspace and user settings"
"Workspace_and_user_settings": "Workspace and user settings",
"Sidebar_Sections_Order": "Sidebar sections order",
"Sidebar_Sections_Order_Description": "Select the categories in your preferred order",
"Incoming_Calls": "Incoming calls"
}
Loading