From 6a6ac53882ce8f26d823a23e9d3f9155b07481fd Mon Sep 17 00:00:00 2001 From: Marcos Defendi Date: Mon, 4 Jul 2022 14:23:40 -0300 Subject: [PATCH 1/3] fix: do not show federated tooltip on non-federated rooms --- apps/meteor/app/discussion/client/tabBar.ts | 2 +- .../server/infrastructure/rocket-chat/slash-commands/index.ts | 2 +- apps/meteor/app/livestream/client/tabBar.tsx | 2 +- apps/meteor/app/message-pin/client/tabBar.ts | 2 +- apps/meteor/app/threads/client/flextab/threadlist.tsx | 2 +- apps/meteor/app/ui-clean-history/client/lib/tabBar.ts | 2 +- apps/meteor/app/videobridge/client/tabBar.tsx | 4 ++-- apps/meteor/app/webrtc/client/tabBar.tsx | 2 +- apps/meteor/client/views/room/lib/Toolbox/defaultActions.ts | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/apps/meteor/app/discussion/client/tabBar.ts b/apps/meteor/app/discussion/client/tabBar.ts index 217f7452778b..75cc4c12ba0f 100644 --- a/apps/meteor/app/discussion/client/tabBar.ts +++ b/apps/meteor/app/discussion/client/tabBar.ts @@ -21,7 +21,7 @@ addAction('discussions', ({ room }) => { template, 'full': true, 'disabled': federated, - 'data-tooltip': 'Discussions_unavailable_for_federation', + 'data-tooltip': federated ? 'Discussions_unavailable_for_federation' : '', 'order': 3, } : null, diff --git a/apps/meteor/app/federation-v2/server/infrastructure/rocket-chat/slash-commands/index.ts b/apps/meteor/app/federation-v2/server/infrastructure/rocket-chat/slash-commands/index.ts index 89edbdaceeb0..2aa502c3ee88 100644 --- a/apps/meteor/app/federation-v2/server/infrastructure/rocket-chat/slash-commands/index.ts +++ b/apps/meteor/app/federation-v2/server/infrastructure/rocket-chat/slash-commands/index.ts @@ -14,7 +14,7 @@ const FEDERATION_COMMANDS: Record = { export const normalizeUserId = (rawUserId: string): string => `@${rawUserId.replace('@', '')}`; -const validateUserIdFormat = async (rawUserId: string, inviterId: string) => { +const validateUserIdFormat = async (rawUserId: string, inviterId: string): Promise => { const inviter = await Users.findOneById(inviterId); const isInviterExternal = inviter?.federated === true || inviter?.username?.includes(':'); if (!rawUserId.includes(':') && !isInviterExternal) { diff --git a/apps/meteor/app/livestream/client/tabBar.tsx b/apps/meteor/app/livestream/client/tabBar.tsx index f2c8fd5ad3f0..7dfa35a2f761 100644 --- a/apps/meteor/app/livestream/client/tabBar.tsx +++ b/apps/meteor/app/livestream/client/tabBar.tsx @@ -23,7 +23,7 @@ addAction('livestream', ({ room }) => { 'template': 'liveStreamTab', 'order': isLive ? -1 : 15, 'disabled': federated, - 'data-tooltip': 'Discussions_unavailable_for_federation', + 'data-tooltip': federated ? 'Livestream_unavailable_for_federation' : '', 'renderAction': (props): ReactNode => ( {isLive ? ( diff --git a/apps/meteor/app/message-pin/client/tabBar.ts b/apps/meteor/app/message-pin/client/tabBar.ts index f1a810b9dc15..1308c6d5198a 100644 --- a/apps/meteor/app/message-pin/client/tabBar.ts +++ b/apps/meteor/app/message-pin/client/tabBar.ts @@ -16,7 +16,7 @@ addAction('pinned-messages', ({ room }) => { 'title': 'Pinned_Messages', 'icon': 'pin', 'template': 'pinnedMessages', - 'data-tooltip': 'Pinned_messages_unavailable_for_federation', + 'data-tooltip': federated ? 'Pinned_messages_unavailable_for_federation' : '', 'disabled': federated, 'order': 11, } diff --git a/apps/meteor/app/threads/client/flextab/threadlist.tsx b/apps/meteor/app/threads/client/flextab/threadlist.tsx index 9895bdba649d..626ffa2e416b 100644 --- a/apps/meteor/app/threads/client/flextab/threadlist.tsx +++ b/apps/meteor/app/threads/client/flextab/threadlist.tsx @@ -32,7 +32,7 @@ addAction('thread', (options) => { 'title': 'Threads', 'icon': 'thread', template, - 'data-tooltip': 'Threads_unavailable_for_federation', + 'data-tooltip': federated ? 'Threads_unavailable_for_federation' : '', 'disabled': federated, 'renderAction': (props): ReactNode => { const tunread = room.tunread?.length || 0; diff --git a/apps/meteor/app/ui-clean-history/client/lib/tabBar.ts b/apps/meteor/app/ui-clean-history/client/lib/tabBar.ts index 196e02f418d9..75267ce0cb7d 100644 --- a/apps/meteor/app/ui-clean-history/client/lib/tabBar.ts +++ b/apps/meteor/app/ui-clean-history/client/lib/tabBar.ts @@ -20,7 +20,7 @@ addAction('clean-history', ({ room }) => { 'title': 'Prune_Messages', 'icon': 'eraser', 'disabled': federated, - 'data-tooltip': 'Clean_History_unavailable_for_federation', + 'data-tooltip': federated ? 'Clean_History_unavailable_for_federation' : '', template, 'order': 250, } diff --git a/apps/meteor/app/videobridge/client/tabBar.tsx b/apps/meteor/app/videobridge/client/tabBar.tsx index 38898d95daae..238f561f6dbb 100644 --- a/apps/meteor/app/videobridge/client/tabBar.tsx +++ b/apps/meteor/app/videobridge/client/tabBar.tsx @@ -22,7 +22,7 @@ addAction('calls', ({ room }) => { 'icon': 'phone', 'title': 'Calls', 'disabled': federated, - 'data-tooltip': 'Video_Call_unavailable_for_federation', + 'data-tooltip': federated ? 'Video_Call_unavailable_for_federation' : '', 'template': lazy(() => import('../../../client/views/room/contextualBar/VideoConference/VideoConfList')), 'order': 999, } @@ -87,7 +87,7 @@ addAction('start-call', ({ room }) => { 'icon': 'phone', 'action': handleOpenVideoConf, 'disabled': federated, - 'data-tooltip': 'Video_Call_unavailable_for_federation', + 'data-tooltip': federated ? 'Video_Call_unavailable_for_federation' : '', 'full': true, 'order': live ? -1 : 4, } diff --git a/apps/meteor/app/webrtc/client/tabBar.tsx b/apps/meteor/app/webrtc/client/tabBar.tsx index 12e92ca30e78..6512ed4526a9 100644 --- a/apps/meteor/app/webrtc/client/tabBar.tsx +++ b/apps/meteor/app/webrtc/client/tabBar.tsx @@ -25,7 +25,7 @@ addAction('webRTCVideo', ({ room }) => { 'title': 'WebRTC_Call', 'icon': 'phone', 'disabled': federated, - 'data-tooltip': 'Call_unavailable_for_federation', + 'data-tooltip': federated ? 'Call_unavailable_for_federation' : '', 'action': handleClick, 'full': true, 'order': 4, diff --git a/apps/meteor/client/views/room/lib/Toolbox/defaultActions.ts b/apps/meteor/client/views/room/lib/Toolbox/defaultActions.ts index f02e8ced5ba1..16e1e4d8abe9 100644 --- a/apps/meteor/client/views/room/lib/Toolbox/defaultActions.ts +++ b/apps/meteor/client/views/room/lib/Toolbox/defaultActions.ts @@ -67,7 +67,7 @@ addAction('uploaded-files-list', ({ room }) => { 'title': 'Files', 'icon': 'clip', 'disabled': federated, - 'data-tooltip': 'Files_unavailable_for_federation', + 'data-tooltip': federated ? 'Files_unavailable_for_federation' : '', 'template': lazy(() => import('../../contextualBar/RoomFiles')), 'order': 7, }; From e0ea4183e7eba9507674e400f1f5f21139f67fff Mon Sep 17 00:00:00 2001 From: Guilherme Gazzo Date: Mon, 4 Jul 2022 22:36:33 -0300 Subject: [PATCH 2/3] fix review --- apps/meteor/app/discussion/client/tabBar.ts | 6 ++++-- apps/meteor/app/livestream/client/tabBar.tsx | 6 ++++-- apps/meteor/app/message-pin/client/tabBar.ts | 6 ++++-- apps/meteor/app/threads/client/flextab/threadlist.tsx | 6 ++++-- apps/meteor/app/ui-clean-history/client/lib/tabBar.ts | 6 ++++-- apps/meteor/app/videobridge/client/tabBar.tsx | 6 ++++-- apps/meteor/app/webrtc/client/tabBar.tsx | 6 ++++-- apps/meteor/client/views/room/lib/Toolbox/defaultActions.ts | 6 ++++-- 8 files changed, 32 insertions(+), 16 deletions(-) diff --git a/apps/meteor/app/discussion/client/tabBar.ts b/apps/meteor/app/discussion/client/tabBar.ts index 75cc4c12ba0f..b5f4aaaa82a0 100644 --- a/apps/meteor/app/discussion/client/tabBar.ts +++ b/apps/meteor/app/discussion/client/tabBar.ts @@ -20,8 +20,10 @@ addAction('discussions', ({ room }) => { 'icon': 'discussion', template, 'full': true, - 'disabled': federated, - 'data-tooltip': federated ? 'Discussions_unavailable_for_federation' : '', + ...federated && { + disabled: true, + 'data-tooltip': 'Discussions_unavailable_for_federation', + }, 'order': 3, } : null, diff --git a/apps/meteor/app/livestream/client/tabBar.tsx b/apps/meteor/app/livestream/client/tabBar.tsx index 7dfa35a2f761..22cf46bee54c 100644 --- a/apps/meteor/app/livestream/client/tabBar.tsx +++ b/apps/meteor/app/livestream/client/tabBar.tsx @@ -22,8 +22,10 @@ addAction('livestream', ({ room }) => { 'icon': 'podcast', 'template': 'liveStreamTab', 'order': isLive ? -1 : 15, - 'disabled': federated, - 'data-tooltip': federated ? 'Livestream_unavailable_for_federation' : '', + ...federated && { + 'data-tooltip': federated ? 'Livestream_unavailable_for_federation' : '', + disabled: true, + }, 'renderAction': (props): ReactNode => ( {isLive ? ( diff --git a/apps/meteor/app/message-pin/client/tabBar.ts b/apps/meteor/app/message-pin/client/tabBar.ts index 1308c6d5198a..9bb231a2f4cb 100644 --- a/apps/meteor/app/message-pin/client/tabBar.ts +++ b/apps/meteor/app/message-pin/client/tabBar.ts @@ -16,8 +16,10 @@ addAction('pinned-messages', ({ room }) => { 'title': 'Pinned_Messages', 'icon': 'pin', 'template': 'pinnedMessages', - 'data-tooltip': federated ? 'Pinned_messages_unavailable_for_federation' : '', - 'disabled': federated, + ...federated && { + 'data-tooltip': 'Pinned_messages_unavailable_for_federation', + disabled: true, + }, 'order': 11, } : null, diff --git a/apps/meteor/app/threads/client/flextab/threadlist.tsx b/apps/meteor/app/threads/client/flextab/threadlist.tsx index 626ffa2e416b..e9a0c3f9ac31 100644 --- a/apps/meteor/app/threads/client/flextab/threadlist.tsx +++ b/apps/meteor/app/threads/client/flextab/threadlist.tsx @@ -32,8 +32,10 @@ addAction('thread', (options) => { 'title': 'Threads', 'icon': 'thread', template, - 'data-tooltip': federated ? 'Threads_unavailable_for_federation' : '', - 'disabled': federated, + ...federated && { + 'data-tooltip': 'Threads_unavailable_for_federation', + disabled: true, + }, 'renderAction': (props): ReactNode => { const tunread = room.tunread?.length || 0; const tunreadUser = room.tunreadUser?.length || 0; diff --git a/apps/meteor/app/ui-clean-history/client/lib/tabBar.ts b/apps/meteor/app/ui-clean-history/client/lib/tabBar.ts index 75267ce0cb7d..4e8fca7285fb 100644 --- a/apps/meteor/app/ui-clean-history/client/lib/tabBar.ts +++ b/apps/meteor/app/ui-clean-history/client/lib/tabBar.ts @@ -19,8 +19,10 @@ addAction('clean-history', ({ room }) => { 'full': true, 'title': 'Prune_Messages', 'icon': 'eraser', - 'disabled': federated, - 'data-tooltip': federated ? 'Clean_History_unavailable_for_federation' : '', + ...federated && { + 'data-tooltip': 'Clean_History_unavailable_for_federation', + disabled: true, + }, template, 'order': 250, } diff --git a/apps/meteor/app/videobridge/client/tabBar.tsx b/apps/meteor/app/videobridge/client/tabBar.tsx index 238f561f6dbb..1948f995ea80 100644 --- a/apps/meteor/app/videobridge/client/tabBar.tsx +++ b/apps/meteor/app/videobridge/client/tabBar.tsx @@ -21,8 +21,10 @@ addAction('calls', ({ room }) => { 'id': 'calls', 'icon': 'phone', 'title': 'Calls', - 'disabled': federated, - 'data-tooltip': federated ? 'Video_Call_unavailable_for_federation' : '', + ...federated && { + 'data-tooltip': 'Video_Call_unavailable_for_federation', + disabled: true, + }, 'template': lazy(() => import('../../../client/views/room/contextualBar/VideoConference/VideoConfList')), 'order': 999, } diff --git a/apps/meteor/app/webrtc/client/tabBar.tsx b/apps/meteor/app/webrtc/client/tabBar.tsx index 6512ed4526a9..cbd58f67e357 100644 --- a/apps/meteor/app/webrtc/client/tabBar.tsx +++ b/apps/meteor/app/webrtc/client/tabBar.tsx @@ -24,8 +24,10 @@ addAction('webRTCVideo', ({ room }) => { 'id': 'webRTCVideo', 'title': 'WebRTC_Call', 'icon': 'phone', - 'disabled': federated, - 'data-tooltip': federated ? 'Call_unavailable_for_federation' : '', + ...federated && { + 'data-tooltip': 'Call_unavailable_for_federation', + disabled: true, + }, 'action': handleClick, 'full': true, 'order': 4, diff --git a/apps/meteor/client/views/room/lib/Toolbox/defaultActions.ts b/apps/meteor/client/views/room/lib/Toolbox/defaultActions.ts index 16e1e4d8abe9..0797473a732a 100644 --- a/apps/meteor/client/views/room/lib/Toolbox/defaultActions.ts +++ b/apps/meteor/client/views/room/lib/Toolbox/defaultActions.ts @@ -66,8 +66,10 @@ addAction('uploaded-files-list', ({ room }) => { 'id': 'uploaded-files-list', 'title': 'Files', 'icon': 'clip', - 'disabled': federated, - 'data-tooltip': federated ? 'Files_unavailable_for_federation' : '', + ...federated && { + disabled: true, + 'data-tooltip': 'Files_unavailable_for_federation', + }, 'template': lazy(() => import('../../contextualBar/RoomFiles')), 'order': 7, }; From c3a330e58a8646a76e33b568a62ff8a1d7de7f39 Mon Sep 17 00:00:00 2001 From: Guilherme Gazzo Date: Mon, 4 Jul 2022 22:51:51 -0300 Subject: [PATCH 3/3] lint --- apps/meteor/app/discussion/client/tabBar.ts | 18 +++++++-------- apps/meteor/app/livestream/client/tabBar.tsx | 22 +++++++++---------- apps/meteor/app/message-pin/client/tabBar.ts | 18 +++++++-------- .../app/threads/client/flextab/threadlist.tsx | 20 ++++++++--------- .../app/ui-clean-history/client/lib/tabBar.ts | 18 +++++++-------- apps/meteor/app/videobridge/client/tabBar.tsx | 18 +++++++-------- apps/meteor/app/webrtc/client/tabBar.tsx | 20 ++++++++--------- .../views/room/lib/Toolbox/defaultActions.ts | 18 +++++++-------- 8 files changed, 76 insertions(+), 76 deletions(-) diff --git a/apps/meteor/app/discussion/client/tabBar.ts b/apps/meteor/app/discussion/client/tabBar.ts index b5f4aaaa82a0..a9bece626e54 100644 --- a/apps/meteor/app/discussion/client/tabBar.ts +++ b/apps/meteor/app/discussion/client/tabBar.ts @@ -14,17 +14,17 @@ addAction('discussions', ({ room }) => { () => discussionEnabled && !room.prid ? { - 'groups': ['channel', 'group', 'direct', 'direct_multiple', 'team'], - 'id': 'discussions', - 'title': 'Discussions', - 'icon': 'discussion', + groups: ['channel', 'group', 'direct', 'direct_multiple', 'team'], + id: 'discussions', + title: 'Discussions', + icon: 'discussion', template, - 'full': true, - ...federated && { - disabled: true, + full: true, + ...(federated && { + 'disabled': true, 'data-tooltip': 'Discussions_unavailable_for_federation', - }, - 'order': 3, + }), + order: 3, } : null, [discussionEnabled, room.prid, federated], diff --git a/apps/meteor/app/livestream/client/tabBar.tsx b/apps/meteor/app/livestream/client/tabBar.tsx index 22cf46bee54c..8d81cf78a915 100644 --- a/apps/meteor/app/livestream/client/tabBar.tsx +++ b/apps/meteor/app/livestream/client/tabBar.tsx @@ -16,17 +16,17 @@ addAction('livestream', ({ room }) => { () => enabled ? { - 'groups': ['channel', 'group', 'team'], - 'id': 'livestream', - 'title': 'Livestream', - 'icon': 'podcast', - 'template': 'liveStreamTab', - 'order': isLive ? -1 : 15, - ...federated && { + groups: ['channel', 'group', 'team'], + id: 'livestream', + title: 'Livestream', + icon: 'podcast', + template: 'liveStreamTab', + order: isLive ? -1 : 15, + ...(federated && { 'data-tooltip': federated ? 'Livestream_unavailable_for_federation' : '', - disabled: true, - }, - 'renderAction': (props): ReactNode => ( + 'disabled': true, + }), + renderAction: (props): ReactNode => ( {isLive ? ( @@ -35,7 +35,7 @@ addAction('livestream', ({ room }) => { ) : null} ), - 'renderOption': ({ label: { title, icon }, ...props }: any): ReactNode => ( + renderOption: ({ label: { title, icon }, ...props }: any): ReactNode => ( ); }, - 'order': 2, + order: 2, } : null, [threadsEnabled, room.tunread?.length, room.tunreadUser?.length, room.tunreadGroup?.length, federated], diff --git a/apps/meteor/app/ui-clean-history/client/lib/tabBar.ts b/apps/meteor/app/ui-clean-history/client/lib/tabBar.ts index 4e8fca7285fb..72fcbf22f598 100644 --- a/apps/meteor/app/ui-clean-history/client/lib/tabBar.ts +++ b/apps/meteor/app/ui-clean-history/client/lib/tabBar.ts @@ -14,17 +14,17 @@ addAction('clean-history', ({ room }) => { () => hasPermission ? { - 'groups': ['channel', 'group', 'team', 'direct_multiple', 'direct'], - 'id': 'clean-history', - 'full': true, - 'title': 'Prune_Messages', - 'icon': 'eraser', - ...federated && { + groups: ['channel', 'group', 'team', 'direct_multiple', 'direct'], + id: 'clean-history', + full: true, + title: 'Prune_Messages', + icon: 'eraser', + ...(federated && { 'data-tooltip': 'Clean_History_unavailable_for_federation', - disabled: true, - }, + 'disabled': true, + }), template, - 'order': 250, + order: 250, } : null, [hasPermission, federated], diff --git a/apps/meteor/app/videobridge/client/tabBar.tsx b/apps/meteor/app/videobridge/client/tabBar.tsx index 1948f995ea80..6633819551cb 100644 --- a/apps/meteor/app/videobridge/client/tabBar.tsx +++ b/apps/meteor/app/videobridge/client/tabBar.tsx @@ -17,16 +17,16 @@ addAction('calls', ({ room }) => { () => hasLicense ? { - 'groups': ['channel', 'group', 'team'], - 'id': 'calls', - 'icon': 'phone', - 'title': 'Calls', - ...federated && { + groups: ['channel', 'group', 'team'], + id: 'calls', + icon: 'phone', + title: 'Calls', + ...(federated && { 'data-tooltip': 'Video_Call_unavailable_for_federation', - disabled: true, - }, - 'template': lazy(() => import('../../../client/views/room/contextualBar/VideoConference/VideoConfList')), - 'order': 999, + 'disabled': true, + }), + template: lazy(() => import('../../../client/views/room/contextualBar/VideoConference/VideoConfList')), + order: 999, } : null, [hasLicense, federated], diff --git a/apps/meteor/app/webrtc/client/tabBar.tsx b/apps/meteor/app/webrtc/client/tabBar.tsx index cbd58f67e357..22fa7bd9d1a0 100644 --- a/apps/meteor/app/webrtc/client/tabBar.tsx +++ b/apps/meteor/app/webrtc/client/tabBar.tsx @@ -20,17 +20,17 @@ addAction('webRTCVideo', ({ room }) => { () => enabled ? { - 'groups': ['live'], - 'id': 'webRTCVideo', - 'title': 'WebRTC_Call', - 'icon': 'phone', - ...federated && { + groups: ['live'], + id: 'webRTCVideo', + title: 'WebRTC_Call', + icon: 'phone', + ...(federated && { 'data-tooltip': 'Call_unavailable_for_federation', - disabled: true, - }, - 'action': handleClick, - 'full': true, - 'order': 4, + 'disabled': true, + }), + action: handleClick, + full: true, + order: 4, } : null, [enabled, handleClick, federated], diff --git a/apps/meteor/client/views/room/lib/Toolbox/defaultActions.ts b/apps/meteor/client/views/room/lib/Toolbox/defaultActions.ts index 0797473a732a..3f581e5b5aad 100644 --- a/apps/meteor/client/views/room/lib/Toolbox/defaultActions.ts +++ b/apps/meteor/client/views/room/lib/Toolbox/defaultActions.ts @@ -62,16 +62,16 @@ addAction('uploaded-files-list', ({ room }) => { const federated = isRoomFederated(room); return { - 'groups': ['channel', 'group', 'direct', 'direct_multiple', 'live', 'team'], - 'id': 'uploaded-files-list', - 'title': 'Files', - 'icon': 'clip', - ...federated && { - disabled: true, + groups: ['channel', 'group', 'direct', 'direct_multiple', 'live', 'team'], + id: 'uploaded-files-list', + title: 'Files', + icon: 'clip', + ...(federated && { + 'disabled': true, 'data-tooltip': 'Files_unavailable_for_federation', - }, - 'template': lazy(() => import('../../contextualBar/RoomFiles')), - 'order': 7, + }), + template: lazy(() => import('../../contextualBar/RoomFiles')), + order: 7, }; });