From 44fe68de26de27d6c9fb8f4becfa97b305c86586 Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Thu, 17 Aug 2023 01:16:18 +0530 Subject: [PATCH 1/6] fix:copy-update admin only posting rooms --- src/components/ReportWelcomeText.js | 28 +++++++++++++++++++--------- src/languages/en.js | 4 ++-- src/languages/es.js | 4 ++-- src/libs/ReportUtils.js | 4 ++-- 4 files changed, 25 insertions(+), 15 deletions(-) diff --git a/src/components/ReportWelcomeText.js b/src/components/ReportWelcomeText.js index e0e5d25a1643..4c08d090d167 100644 --- a/src/components/ReportWelcomeText.js +++ b/src/components/ReportWelcomeText.js @@ -54,6 +54,8 @@ function ReportWelcomeText(props) { const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(props.report); const isChatRoom = ReportUtils.isChatRoom(props.report); const isDefault = !(isChatRoom || isPolicyExpenseChat); + const isAdminsOnlyPostingRoom = ReportUtils.isAdminsOnlyPostingRoom(props.report); + const isAnnounceRoom = ReportUtils.isAnnounceRoom(props.report); const participantAccountIDs = lodashGet(props.report, 'participantAccountIDs', []); const isMultipleParticipant = participantAccountIDs.length > 1; const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips( @@ -65,7 +67,11 @@ function ReportWelcomeText(props) { return ( <> - {props.translate('reportActionsView.sayHello')} + + {isAdminsOnlyPostingRoom || isAnnounceRoom + ? props.translate('reportActionsView.welcomeToRoom', {roomName: ReportUtils.getReportName(props.report)}) + : props.translate('reportActionsView.sayHello')} + {isPolicyExpenseChat && ( @@ -84,14 +90,18 @@ function ReportWelcomeText(props) { {isChatRoom && ( <> {roomWelcomeMessage.phrase1} - Navigation.navigate(ROUTES.getReportDetailsRoute(props.report.reportID))} - suppressHighlighting - > - {ReportUtils.getReportName(props.report)} - - {roomWelcomeMessage.phrase2} + {!isAdminsOnlyPostingRoom && ( + <> + Navigation.navigate(ROUTES.getReportDetailsRoute(props.report.reportID))} + suppressHighlighting + > + {ReportUtils.getReportName(props.report)} + + {roomWelcomeMessage.phrase2} + + )} )} {isDefault && ( diff --git a/src/languages/en.js b/src/languages/en.js index 229166a3f858..7453deefffa2 100755 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -291,8 +291,7 @@ export default { beginningOfChatHistoryDomainRoomPartTwo: ' to chat with colleagues, share tips, and ask questions.', beginningOfChatHistoryAdminRoomPartOne: ({workspaceName}) => `Collaboration among ${workspaceName} admins starts here! 🎉\nUse `, beginningOfChatHistoryAdminRoomPartTwo: ' to chat about topics such as workspace configurations and more.', - beginningOfChatHistoryAdminOnlyPostingRoomPartOne: 'Use ', - beginningOfChatHistoryAdminOnlyPostingRoomPartTwo: ({workspaceName}) => ` to hear about important announcements related to ${workspaceName}`, + beginningOfChatHistoryAdminOnlyPostingRoom: 'Only admins can send messages in this room.', beginningOfChatHistoryAnnounceRoomPartOne: ({workspaceName}) => `Collaboration between all ${workspaceName} members starts here! 🎉\nUse `, beginningOfChatHistoryAnnounceRoomPartTwo: ({workspaceName}) => ` to chat about anything ${workspaceName} related.`, beginningOfChatHistoryUserRoomPartOne: 'Collaboration starts here! 🎉\nUse this space to chat about anything ', @@ -303,6 +302,7 @@ export default { beginningOfChatHistoryPolicyExpenseChatPartThree: ' starts here! 🎉 This is the place to chat, request money and settle up.', chatWithAccountManager: 'Chat with your account manager here', sayHello: 'Say hello!', + welcomeToRoom: ({roomName}) => `Welcome to ${roomName}!`, usePlusButton: '\n\nYou can also use the + button below to request money or assign a task!', }, reportAction: { diff --git a/src/languages/es.js b/src/languages/es.js index 0e24a386cd14..7f211422a0c9 100644 --- a/src/languages/es.js +++ b/src/languages/es.js @@ -290,8 +290,7 @@ export default { beginningOfChatHistoryDomainRoomPartTwo: ' para chatear con compañeros, compartir consejos o hacer una pregunta.', beginningOfChatHistoryAdminRoomPartOne: ({workspaceName}) => `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.', - beginningOfChatHistoryAdminOnlyPostingRoomPartOne: 'Utiliza ', - beginningOfChatHistoryAdminOnlyPostingRoomPartTwo: ({workspaceName}) => ` para enterarte de anuncios importantes relacionados con ${workspaceName}`, + beginningOfChatHistoryAdminOnlyPostingRoom: 'Solo los administrators pueden enviar mensajes en esta sala.', beginningOfChatHistoryAnnounceRoomPartOne: ({workspaceName}) => `Este es el lugar para que todos los miembros de ${workspaceName} colaboren! 🎉\nUsa `, beginningOfChatHistoryAnnounceRoomPartTwo: ({workspaceName}) => ` para chatear sobre cualquier cosa relacionada con ${workspaceName}.`, beginningOfChatHistoryUserRoomPartOne: 'Este es el lugar para colaborar! 🎉\nUsa este espacio para chatear sobre cualquier cosa relacionada con ', @@ -302,6 +301,7 @@ export default { beginningOfChatHistoryPolicyExpenseChatPartThree: ' empieza aquí! 🎉 Este es el lugar donde chatear, pedir dinero y pagar.', chatWithAccountManager: 'Chatea con tu gestor de cuenta aquí', sayHello: '¡Saluda!', + welcomeToRoom: ({roomName}) => `¡Bienvenido a ${roomName}!`, usePlusButton: '\n\n¡También puedes usar el botón + de abajo para pedir dinero o asignar una tarea!', }, reportAction: { diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 0b5158e49f88..85201212769a 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -773,8 +773,7 @@ function getRoomWelcomeMessage(report) { welcomeMessage.phrase1 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryAdminRoomPartOne', {workspaceName}); welcomeMessage.phrase2 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryAdminRoomPartTwo'); } else if (isAdminsOnlyPostingRoom(report)) { - welcomeMessage.phrase1 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryAdminOnlyPostingRoomPartOne'); - welcomeMessage.phrase2 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryAdminOnlyPostingRoomPartTwo', {workspaceName}); + welcomeMessage.phrase1 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryAdminOnlyPostingRoom'); } else if (isAnnounceRoom(report)) { welcomeMessage.phrase1 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryAnnounceRoomPartOne', {workspaceName}); welcomeMessage.phrase2 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryAnnounceRoomPartTwo', {workspaceName}); @@ -3168,6 +3167,7 @@ export { sortReportsByLastRead, isDefaultRoom, isAdminRoom, + isAdminsOnlyPostingRoom, isAnnounceRoom, isUserCreatedPolicyRoom, isChatRoom, From 7181476bb46169089eeefacf36a595c6727a1d32 Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Thu, 17 Aug 2023 01:24:12 +0530 Subject: [PATCH 2/6] code formatting --- src/components/ReportWelcomeText.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ReportWelcomeText.js b/src/components/ReportWelcomeText.js index 4c08d090d167..3a177cbfb94b 100644 --- a/src/components/ReportWelcomeText.js +++ b/src/components/ReportWelcomeText.js @@ -95,7 +95,7 @@ function ReportWelcomeText(props) { Navigation.navigate(ROUTES.getReportDetailsRoute(props.report.reportID))} - suppressHighlighting + suppressHighlighting > {ReportUtils.getReportName(props.report)} From 24fdf8c046b1f9e73634e50878e26fc297cb1997 Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Fri, 18 Aug 2023 01:03:25 +0530 Subject: [PATCH 3/6] fix spanish copy --- src/languages/es.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/languages/es.js b/src/languages/es.js index 7f211422a0c9..80f95a118201 100644 --- a/src/languages/es.js +++ b/src/languages/es.js @@ -290,7 +290,7 @@ export default { beginningOfChatHistoryDomainRoomPartTwo: ' para chatear con compañeros, compartir consejos o hacer una pregunta.', beginningOfChatHistoryAdminRoomPartOne: ({workspaceName}) => `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 administrators pueden enviar mensajes en esta sala.', + beginningOfChatHistoryAdminOnlyPostingRoom: 'Solo los administradores pueden enviar mensajes en esta sala.', beginningOfChatHistoryAnnounceRoomPartOne: ({workspaceName}) => `Este es el lugar para que todos los miembros de ${workspaceName} colaboren! 🎉\nUsa `, beginningOfChatHistoryAnnounceRoomPartTwo: ({workspaceName}) => ` para chatear sobre cualquier cosa relacionada con ${workspaceName}.`, beginningOfChatHistoryUserRoomPartOne: 'Este es el lugar para colaborar! 🎉\nUsa este espacio para chatear sobre cualquier cosa relacionada con ', From ee977aa70c030c49d70af6d9d351a3ff2999c1f8 Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Tue, 22 Aug 2023 00:25:08 +0530 Subject: [PATCH 4/6] fix room welcome message if user is admin --- src/components/ReportWelcomeText.js | 18 ++++++++++++++++-- src/languages/en.js | 2 ++ src/libs/ReportUtils.js | 7 ++++--- .../home/report/ReportActionItemCreated.js | 5 ++++- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/components/ReportWelcomeText.js b/src/components/ReportWelcomeText.js index 3a177cbfb94b..118c966d34a8 100644 --- a/src/components/ReportWelcomeText.js +++ b/src/components/ReportWelcomeText.js @@ -10,6 +10,7 @@ import Text from './Text'; import withLocalize, {withLocalizePropTypes} from './withLocalize'; import compose from '../libs/compose'; import * as ReportUtils from '../libs/ReportUtils'; +import * as PolicyUtils from '../libs/PolicyUtils'; import * as OptionsListUtils from '../libs/OptionsListUtils'; import ONYXKEYS from '../ONYXKEYS'; import Navigation from '../libs/Navigation/Navigation'; @@ -33,6 +34,15 @@ const propTypes = { /** The report currently being looked at */ report: reportPropTypes, + /** The policy object for the current route */ + policy: PropTypes.shape({ + /** The name of the policy */ + name: PropTypes.string, + + /** The URL for the policy avatar */ + avatar: PropTypes.string, + }), + /* Onyx Props */ /** All of the personal details for everyone */ @@ -46,6 +56,7 @@ const propTypes = { const defaultProps = { report: {}, + policy: {}, personalDetails: {}, betas: [], }; @@ -62,8 +73,10 @@ function ReportWelcomeText(props) { OptionsListUtils.getPersonalDetailsForAccountIDs(participantAccountIDs, props.personalDetails), isMultipleParticipant, ); - const roomWelcomeMessage = ReportUtils.getRoomWelcomeMessage(props.report); + const isUserPolicyAdmin = PolicyUtils.isPolicyAdmin(props.policy); + const roomWelcomeMessage = ReportUtils.getRoomWelcomeMessage(props.report, isUserPolicyAdmin); const moneyRequestOptions = ReportUtils.getMoneyRequestOptions(props.report, participantAccountIDs, props.betas); + return ( <> @@ -90,7 +103,8 @@ function ReportWelcomeText(props) { {isChatRoom && ( <> {roomWelcomeMessage.phrase1} - {!isAdminsOnlyPostingRoom && ( + {/* for rooms in which only admins can post we dont need room name and phrase two */} + {(!isAdminsOnlyPostingRoom || isUserPolicyAdmin) && ( <> `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.', + beginningOfChatHistoryAdminOnlyPostingRoomUserIsAdminPartOne: "You're an admin in this workspace. Use ", + beginningOfChatHistoryAdminOnlyPostingRoomUserIsAdminPartTwo: ' to announce important updates in this room.', beginningOfChatHistoryAnnounceRoomPartOne: ({workspaceName}) => `Collaboration between all ${workspaceName} members starts here! 🎉\nUse `, beginningOfChatHistoryAnnounceRoomPartTwo: ({workspaceName}) => ` to chat about anything ${workspaceName} related.`, beginningOfChatHistoryUserRoomPartOne: 'Collaboration starts here! 🎉\nUse this space to chat about anything ', diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 0b96c1d1120b..a9755486e156 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -760,10 +760,11 @@ function canDeleteReportAction(reportAction, reportID) { /** * Get welcome message based on room type * @param {Object} report + * @param {Boolean} isUserPolicyAdmin * @returns {Object} */ -function getRoomWelcomeMessage(report) { +function getRoomWelcomeMessage(report, isUserPolicyAdmin) { const welcomeMessage = {}; const workspaceName = getPolicyName(report); @@ -776,7 +777,7 @@ function getRoomWelcomeMessage(report) { } else if (isAdminRoom(report)) { welcomeMessage.phrase1 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryAdminRoomPartOne', {workspaceName}); welcomeMessage.phrase2 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryAdminRoomPartTwo'); - } else if (isAdminsOnlyPostingRoom(report)) { + } else if (isAdminsOnlyPostingRoom(report) && !isUserPolicyAdmin) { welcomeMessage.phrase1 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryAdminOnlyPostingRoom'); } else if (isAnnounceRoom(report)) { welcomeMessage.phrase1 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryAnnounceRoomPartOne', {workspaceName}); @@ -800,7 +801,7 @@ function chatIncludesConcierge(report) { } /** - * Returns true if there is any automated expensify account in accountIDs + * Returns true if there is any automated expensify account `in accountIDs * @param {Array} accountIDs * @returns {Boolean} */ diff --git a/src/pages/home/report/ReportActionItemCreated.js b/src/pages/home/report/ReportActionItemCreated.js index b7716e22a851..4ae4fe81e4ac 100644 --- a/src/pages/home/report/ReportActionItemCreated.js +++ b/src/pages/home/report/ReportActionItemCreated.js @@ -89,7 +89,10 @@ function ReportActionItemCreated(props) { /> - + From d7aebbf100064ddac56eed82c83ebff1000e6c06 Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Tue, 22 Aug 2023 00:34:28 +0530 Subject: [PATCH 5/6] remove unneccessary translation keys --- src/languages/en.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/languages/en.js b/src/languages/en.js index c09e5a0a91f3..902efeb156b9 100755 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -311,8 +311,6 @@ export default { beginningOfChatHistoryAdminRoomPartOne: ({workspaceName}) => `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.', - beginningOfChatHistoryAdminOnlyPostingRoomUserIsAdminPartOne: "You're an admin in this workspace. Use ", - beginningOfChatHistoryAdminOnlyPostingRoomUserIsAdminPartTwo: ' to announce important updates in this room.', beginningOfChatHistoryAnnounceRoomPartOne: ({workspaceName}) => `Collaboration between all ${workspaceName} members starts here! 🎉\nUse `, beginningOfChatHistoryAnnounceRoomPartTwo: ({workspaceName}) => ` to chat about anything ${workspaceName} related.`, beginningOfChatHistoryUserRoomPartOne: 'Collaboration starts here! 🎉\nUse this space to chat about anything ', From 441a76bf9c7a963427be6760b61a56cde82dd5a8 Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Tue, 22 Aug 2023 02:07:00 +0530 Subject: [PATCH 6/6] fix: update hero text for all rooms --- src/components/ReportWelcomeText.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/components/ReportWelcomeText.js b/src/components/ReportWelcomeText.js index 118c966d34a8..9fc446df31e3 100644 --- a/src/components/ReportWelcomeText.js +++ b/src/components/ReportWelcomeText.js @@ -66,7 +66,6 @@ function ReportWelcomeText(props) { const isChatRoom = ReportUtils.isChatRoom(props.report); const isDefault = !(isChatRoom || isPolicyExpenseChat); const isAdminsOnlyPostingRoom = ReportUtils.isAdminsOnlyPostingRoom(props.report); - const isAnnounceRoom = ReportUtils.isAnnounceRoom(props.report); const participantAccountIDs = lodashGet(props.report, 'participantAccountIDs', []); const isMultipleParticipant = participantAccountIDs.length > 1; const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips( @@ -81,9 +80,7 @@ function ReportWelcomeText(props) { <> - {isAdminsOnlyPostingRoom || isAnnounceRoom - ? props.translate('reportActionsView.welcomeToRoom', {roomName: ReportUtils.getReportName(props.report)}) - : props.translate('reportActionsView.sayHello')} + {isChatRoom ? props.translate('reportActionsView.welcomeToRoom', {roomName: ReportUtils.getReportName(props.report)}) : props.translate('reportActionsView.sayHello')}