From e1114b5bac304cb35135370bb51a8701507b1d5c Mon Sep 17 00:00:00 2001 From: gaber Date: Sun, 28 Apr 2024 21:04:34 +0300 Subject: [PATCH 1/8] move message "admins only can post" from welcome message to report footer --- src/components/ArchivedReportFooter.tsx | 2 +- src/components/ReportWelcomeText.tsx | 4 +-- src/languages/en.ts | 2 +- src/languages/es.ts | 2 +- src/libs/ReportUtils.ts | 5 +--- src/pages/home/ReportScreen.tsx | 1 + src/pages/home/report/ReportFooter.tsx | 26 +++++++++++++++++-- .../report/SystemChatReportFooterMessage.tsx | 2 +- src/styles/index.ts | 2 +- 9 files changed, 32 insertions(+), 14 deletions(-) diff --git a/src/components/ArchivedReportFooter.tsx b/src/components/ArchivedReportFooter.tsx index 9713e40136a2..173f84d392e5 100644 --- a/src/components/ArchivedReportFooter.tsx +++ b/src/components/ArchivedReportFooter.tsx @@ -64,7 +64,7 @@ function ArchivedReportFooter({report, reportClosedAction, personalDetails = {}} return ( 1; const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips(OptionsListUtils.getPersonalDetailsForAccountIDs(participantAccountIDs, personalDetails), isMultipleParticipant); - const isUserPolicyAdmin = PolicyUtils.isPolicyAdmin(policy); - const roomWelcomeMessage = ReportUtils.getRoomWelcomeMessage(report, isUserPolicyAdmin); + const roomWelcomeMessage = ReportUtils.getRoomWelcomeMessage(report); const moneyRequestOptions = ReportUtils.temporary_getMoneyRequestOptions(report, policy, participantAccountIDs, canUseTrackExpense); const additionalText = moneyRequestOptions.map((item) => translate(`reportActionsView.iouTypes.${item}`)).join(', '); const canEditPolicyDescription = ReportUtils.canEditPolicyDescription(policy); diff --git a/src/languages/en.ts b/src/languages/en.ts index 8b7737f00812..709821bbd3b0 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -498,7 +498,6 @@ export default { beginningOfChatHistoryDomainRoomPartTwo: ' to chat with colleagues, share tips, and ask questions.', beginningOfChatHistoryAdminRoomPartOne: ({workspaceName}: BeginningOfChatHistoryAdminRoomPartOneParams) => `Collaboration among ${workspaceName} admins starts here! 🎉\nUse `, beginningOfChatHistoryAdminRoomPartTwo: ' to chat about topics such as workspace configurations and more.', - beginningOfChatHistoryAdminOnlyPostingRoom: 'Only admins can send messages in this room.', beginningOfChatHistoryAnnounceRoomPartOne: ({workspaceName}: BeginningOfChatHistoryAnnounceRoomPartOneParams) => `Collaboration between all ${workspaceName} members starts here! 🎉\nUse `, beginningOfChatHistoryAnnounceRoomPartTwo: ({workspaceName}: BeginningOfChatHistoryAnnounceRoomPartTwo) => ` to chat about anything ${workspaceName} related.`, @@ -523,6 +522,7 @@ export default { invoice: 'invoice an expense', }, }, + adminOnlyCanPost: 'Only admins can send messages in this room.', reportAction: { asCopilot: 'as copilot for', }, diff --git a/src/languages/es.ts b/src/languages/es.ts index 82b5505b18f4..775ff672ff32 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -491,7 +491,6 @@ export default { beginningOfChatHistoryAdminRoomPartOne: ({workspaceName}: BeginningOfChatHistoryAdminRoomPartOneParams) => `¡Este es el lugar para que los administradores de ${workspaceName} colaboren! 🎉\nUsa `, beginningOfChatHistoryAdminRoomPartTwo: ' para chatear sobre temas como la configuración del espacio de trabajo y mas.', - beginningOfChatHistoryAdminOnlyPostingRoom: 'Solo los administradores pueden enviar mensajes en esta sala.', beginningOfChatHistoryAnnounceRoomPartOne: ({workspaceName}: BeginningOfChatHistoryAnnounceRoomPartOneParams) => `¡Este es el lugar para que todos los miembros de ${workspaceName} colaboren! 🎉\nUsa `, beginningOfChatHistoryAnnounceRoomPartTwo: ({workspaceName}: BeginningOfChatHistoryAnnounceRoomPartTwo) => ` para chatear sobre cualquier cosa relacionada con ${workspaceName}.`, @@ -516,6 +515,7 @@ export default { invoice: 'facturar un gasto', }, }, + adminOnlyCanPost: 'Solo los administradores pueden enviar mensajes en esta sala.', reportAction: { asCopilot: 'como copiloto de', }, diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index a0da34416aad..f21c1be67386 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1496,7 +1496,7 @@ function canDeleteReportAction(reportAction: OnyxEntry, reportID: /** * Get welcome message based on room type */ -function getRoomWelcomeMessage(report: OnyxEntry, isUserPolicyAdmin: boolean): WelcomeMessage { +function getRoomWelcomeMessage(report: OnyxEntry): WelcomeMessage { const welcomeMessage: WelcomeMessage = {showReportName: true}; const workspaceName = getPolicyName(report); @@ -1509,9 +1509,6 @@ function getRoomWelcomeMessage(report: OnyxEntry, isUserPolicyAdmin: boo } else if (isAdminRoom(report)) { welcomeMessage.phrase1 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryAdminRoomPartOne', {workspaceName}); welcomeMessage.phrase2 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryAdminRoomPartTwo'); - } else if (isAdminsOnlyPostingRoom(report) && !isUserPolicyAdmin) { - welcomeMessage.phrase1 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryAdminOnlyPostingRoom'); - welcomeMessage.showReportName = false; } else if (isAnnounceRoom(report)) { welcomeMessage.phrase1 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryAnnounceRoomPartOne', {workspaceName}); welcomeMessage.phrase2 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryAnnounceRoomPartTwo', {workspaceName}); diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index d84d610a171a..cb3159a112f1 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -719,6 +719,7 @@ function ReportScreen({ onComposerFocus={() => setIsComposerFocus(true)} onComposerBlur={() => setIsComposerFocus(false)} report={report} + policy={policy} pendingAction={reportPendingAction} isComposerFullSize={!!isComposerFullSize} listHeight={listHeight} diff --git a/src/pages/home/report/ReportFooter.tsx b/src/pages/home/report/ReportFooter.tsx index 11d9a0a4871d..0ca9ea17f4c1 100644 --- a/src/pages/home/report/ReportFooter.tsx +++ b/src/pages/home/report/ReportFooter.tsx @@ -5,12 +5,15 @@ import {withOnyx} from 'react-native-onyx'; import type {OnyxEntry} from 'react-native-onyx'; import AnonymousReportFooter from '@components/AnonymousReportFooter'; import ArchivedReportFooter from '@components/ArchivedReportFooter'; +import Banner from '@components/Banner'; import OfflineIndicator from '@components/OfflineIndicator'; import {usePersonalDetails} from '@components/OnyxProvider'; import SwipeableView from '@components/SwipeableView'; +import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; +import * as PolicyUtils from '@libs/PolicyUtils'; import * as ReportUtils from '@libs/ReportUtils'; import variables from '@styles/variables'; import * as Report from '@userActions/Report'; @@ -35,6 +38,9 @@ type ReportFooterProps = ReportFooterOnyxProps & { /** Report object for the current report */ report?: OnyxTypes.Report; + /** The policy of the report */ + policy: OnyxEntry; + /** The last report action */ lastReportAction?: OnyxEntry; @@ -65,6 +71,7 @@ function ReportFooter({ pendingAction, session, report = {reportID: '0'}, + policy, shouldShowComposeInput = false, isEmptyChat = true, isReportReadyForDisplay = true, @@ -75,6 +82,7 @@ function ReportFooter({ }: ReportFooterProps) { const styles = useThemeStyles(); const {isOffline} = useNetwork(); + const {translate} = useLocalize(); const {windowWidth, isSmallScreenWidth} = useWindowDimensions(); const chatFooterStyles = {...styles.chatFooter, minHeight: !isOffline ? CONST.CHAT_FOOTER_MIN_HEIGHT : 0}; const isArchivedRoom = ReportUtils.isArchivedRoom(report); @@ -83,7 +91,8 @@ function ReportFooter({ const isSmallSizeLayout = windowWidth - (isSmallScreenWidth ? 0 : variables.sideBarWidth) < variables.anonymousReportFooterBreakpoint; const hideComposer = !ReportUtils.canUserPerformWriteAction(report); const canWriteInReport = ReportUtils.canWriteInReport(report); - + const isAdminsOnlyPostingRoom = ReportUtils.isAdminsOnlyPostingRoom(report); + const isUserPolicyAdmin = PolicyUtils.isPolicyAdmin(policy); const allPersonalDetails = usePersonalDetails(); const handleCreateTask = useCallback( @@ -133,7 +142,13 @@ function ReportFooter({ return ( <> {hideComposer && ( - + {isAnonymousUser && !isArchivedRoom && ( )} {isArchivedRoom && } + {isAdminsOnlyPostingRoom && !isUserPolicyAdmin && !isArchivedRoom && ( + + )} {!canWriteInReport && } {!isSmallScreenWidth && {hideComposer && }} diff --git a/src/pages/home/report/SystemChatReportFooterMessage.tsx b/src/pages/home/report/SystemChatReportFooterMessage.tsx index c9ccac8f5c18..449fbb212cf1 100644 --- a/src/pages/home/report/SystemChatReportFooterMessage.tsx +++ b/src/pages/home/report/SystemChatReportFooterMessage.tsx @@ -67,7 +67,7 @@ function SystemChatReportFooterMessage({choice, policies, activePolicyID}: Syste return ( {content}} diff --git a/src/styles/index.ts b/src/styles/index.ts index 376305f0a31e..ca0fa98a595b 100644 --- a/src/styles/index.ts +++ b/src/styles/index.ts @@ -3658,7 +3658,7 @@ const styles = (theme: ThemeColors) => height: variables.optionRowHeight, }, - archivedReportFooter: { + chatFooterBanner: { borderRadius: variables.componentBorderRadius, ...wordBreak.breakWord, }, From 93f65430d2381fc3e7dfc09417e932deeca9cdeb Mon Sep 17 00:00:00 2001 From: gaber Date: Tue, 30 Apr 2024 22:08:20 +0300 Subject: [PATCH 2/8] change Banner icon to lightbulb. --- src/pages/home/report/ReportFooter.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pages/home/report/ReportFooter.tsx b/src/pages/home/report/ReportFooter.tsx index 0ca9ea17f4c1..8bf998513ccd 100644 --- a/src/pages/home/report/ReportFooter.tsx +++ b/src/pages/home/report/ReportFooter.tsx @@ -23,6 +23,7 @@ import ONYXKEYS from '@src/ONYXKEYS'; import type * as OnyxTypes from '@src/types/onyx'; import type {PendingAction} from '@src/types/onyx/OnyxCommon'; import type {EmptyObject} from '@src/types/utils/EmptyObject'; +import * as Expensicons from "@components/Icon/Expensicons"; import ReportActionCompose from './ReportActionCompose/ReportActionCompose'; import SystemChatReportFooterMessage from './SystemChatReportFooterMessage'; @@ -160,6 +161,7 @@ function ReportFooter({ )} From 295e4453a63dce39b95d2b2ab2128001f9b92127 Mon Sep 17 00:00:00 2001 From: gaber Date: Tue, 30 Apr 2024 22:12:46 +0300 Subject: [PATCH 3/8] hide "admin only can post" when is anonymous user --- src/pages/home/report/ReportFooter.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportFooter.tsx b/src/pages/home/report/ReportFooter.tsx index 8bf998513ccd..b21da9a37e35 100644 --- a/src/pages/home/report/ReportFooter.tsx +++ b/src/pages/home/report/ReportFooter.tsx @@ -157,7 +157,7 @@ function ReportFooter({ /> )} {isArchivedRoom && } - {isAdminsOnlyPostingRoom && !isUserPolicyAdmin && !isArchivedRoom && ( + {isAdminsOnlyPostingRoom && !isUserPolicyAdmin && !isArchivedRoom && !isAnonymousUser && ( Date: Tue, 30 Apr 2024 22:21:08 +0300 Subject: [PATCH 4/8] fix conflict --- src/pages/home/report/ReportFooter.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportFooter.tsx b/src/pages/home/report/ReportFooter.tsx index e811fdcb6b23..9255075e1a9b 100644 --- a/src/pages/home/report/ReportFooter.tsx +++ b/src/pages/home/report/ReportFooter.tsx @@ -95,6 +95,7 @@ function ReportFooter({ const isSystemChat = ReportUtils.isSystemChat(report); const isAdminsOnlyPostingRoom = ReportUtils.isAdminsOnlyPostingRoom(report); const isUserPolicyAdmin = PolicyUtils.isPolicyAdmin(policy); + const allPersonalDetails = usePersonalDetails(); const handleCreateTask = useCallback( @@ -167,7 +168,6 @@ function ReportFooter({ shouldShowIcon /> )} - {!canWriteInReport && } {!isSmallScreenWidth && {hideComposer && }} )} From e77ff93cb99fcddb741041bbb0a332805cf4cf43 Mon Sep 17 00:00:00 2001 From: gaber Date: Tue, 30 Apr 2024 22:22:21 +0300 Subject: [PATCH 5/8] prettier --- src/pages/home/report/ReportFooter.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportFooter.tsx b/src/pages/home/report/ReportFooter.tsx index 9255075e1a9b..a8c293e87b8f 100644 --- a/src/pages/home/report/ReportFooter.tsx +++ b/src/pages/home/report/ReportFooter.tsx @@ -6,6 +6,7 @@ import type {OnyxEntry} from 'react-native-onyx'; import AnonymousReportFooter from '@components/AnonymousReportFooter'; import ArchivedReportFooter from '@components/ArchivedReportFooter'; import Banner from '@components/Banner'; +import * as Expensicons from '@components/Icon/Expensicons'; import OfflineIndicator from '@components/OfflineIndicator'; import {usePersonalDetails} from '@components/OnyxProvider'; import SwipeableView from '@components/SwipeableView'; @@ -23,7 +24,6 @@ import ONYXKEYS from '@src/ONYXKEYS'; import type * as OnyxTypes from '@src/types/onyx'; import type {PendingAction} from '@src/types/onyx/OnyxCommon'; import type {EmptyObject} from '@src/types/utils/EmptyObject'; -import * as Expensicons from "@components/Icon/Expensicons"; import ReportActionCompose from './ReportActionCompose/ReportActionCompose'; import SystemChatReportFooterMessage from './SystemChatReportFooterMessage'; From 86870952c3f0ffde9cb77ff5e9ab73470c8766fb Mon Sep 17 00:00:00 2001 From: gaber Date: Fri, 31 May 2024 03:31:02 +0300 Subject: [PATCH 6/8] hide "admin only can post" when is blocked from chat --- src/pages/home/report/ReportFooter.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportFooter.tsx b/src/pages/home/report/ReportFooter.tsx index 309089710f9e..e5c28df03009 100644 --- a/src/pages/home/report/ReportFooter.tsx +++ b/src/pages/home/report/ReportFooter.tsx @@ -177,7 +177,7 @@ function ReportFooter({ {isArchivedRoom && } {!isArchivedRoom && blockedFromChat && } {!isAnonymousUser && !canWriteInReport && isSystemChat && } - {isAdminsOnlyPostingRoom && !isUserPolicyAdmin && !isArchivedRoom && !isAnonymousUser && ( + {isAdminsOnlyPostingRoom && !isUserPolicyAdmin && !isArchivedRoom && !isAnonymousUser && !blockedFromChat && ( Date: Fri, 31 May 2024 03:46:48 +0300 Subject: [PATCH 7/8] fix type script error 'archivedReportFooter' does not exist --- src/components/BlockedReportFooter.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/BlockedReportFooter.tsx b/src/components/BlockedReportFooter.tsx index 89290545166c..f8251c99b33d 100644 --- a/src/components/BlockedReportFooter.tsx +++ b/src/components/BlockedReportFooter.tsx @@ -11,7 +11,7 @@ function BlockedReportFooter() { return ( Date: Fri, 31 May 2024 03:48:12 +0300 Subject: [PATCH 8/8] prettier --- src/pages/home/report/ReportFooter.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportFooter.tsx b/src/pages/home/report/ReportFooter.tsx index e5c28df03009..54a5e1d8f781 100644 --- a/src/pages/home/report/ReportFooter.tsx +++ b/src/pages/home/report/ReportFooter.tsx @@ -5,8 +5,8 @@ import {withOnyx} from 'react-native-onyx'; import type {OnyxEntry} from 'react-native-onyx'; import AnonymousReportFooter from '@components/AnonymousReportFooter'; import ArchivedReportFooter from '@components/ArchivedReportFooter'; -import BlockedReportFooter from '@components/BlockedReportFooter'; import Banner from '@components/Banner'; +import BlockedReportFooter from '@components/BlockedReportFooter'; import * as Expensicons from '@components/Icon/Expensicons'; import OfflineIndicator from '@components/OfflineIndicator'; import {usePersonalDetails} from '@components/OnyxProvider';