Skip to content

Commit

Permalink
Merge pull request #8330 from Santhosh-Sellavel/santhosh_room_welcome…
Browse files Browse the repository at this point in the history
…_message_update

Updated Room Welcome Message
  • Loading branch information
stitesExpensify authored Mar 28, 2022
2 parents be71221 + af90ec5 commit 3da9974
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 16 deletions.
11 changes: 3 additions & 8 deletions src/components/ReportWelcomeText.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ const ReportWelcomeText = (props) => {
};
},
);
const isResctrictedRoom = lodashGet(props, 'report.visibility', '') === CONST.REPORT.VISIBILITY.RESTRICTED;

const roomWelcomeMessage = ReportUtils.getRoomWelcomeMessage(props.report, props.policies);
return (
<Text style={[styles.mt3, styles.mw100, styles.textAlignCenter]}>
{isPolicyExpenseChat && (
Expand Down Expand Up @@ -103,17 +102,13 @@ const ReportWelcomeText = (props) => {
<>
{/* Add align center style individually because of limited style inheritance in React Native https://reactnative.dev/docs/text#limited-style-inheritance */}
<Text style={styles.textAlignCenter}>
{isResctrictedRoom
? `${props.translate('reportActionsView.beginningOfChatHistoryRestrictedPartOne')}`
: `${props.translate('reportActionsView.beginningOfChatHistoryPrivatePartOne')}`}
{roomWelcomeMessage.phrase1}
</Text>
<Text style={[styles.textStrong]}>
{props.report.reportName}
</Text>
<Text>
{isResctrictedRoom
? `${props.translate('reportActionsView.beginningOfChatHistoryRestrictedPartTwo')}`
: `${props.translate('reportActionsView.beginningOfChatHistoryPrivatePartTwo')}`}
{roomWelcomeMessage.phrase2}
</Text>
</>
)}
Expand Down
10 changes: 6 additions & 4 deletions src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,13 @@ export default {
deleteConfirmation: 'Are you sure you want to delete this comment?',
},
reportActionsView: {
beginningOfChatHistoryAdminRoomPartOne: ({workspaceName}) => `Collaboration among ${workspaceName} admins starts here! 🎉\nUse `,
beginningOfChatHistoryAdminRoomPartTwo: ' to chat about topics such as workspace configurations and more.',
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 ',
beginningOfChatHistoryUserRoomPartTwo: ' related.',
beginningOfChatHistory: 'This is the beginning of your chat history with ',
beginningOfChatHistoryPrivatePartOne: 'This is the beginning of the private ',
beginningOfChatHistoryRestrictedPartOne: 'This is the beginning of ',
beginningOfChatHistoryPrivatePartTwo: ' room, invite others by @mentioning them.',
beginningOfChatHistoryRestrictedPartTwo: ', invite others by @mentioning them.',
beginningOfChatHistoryPolicyExpenseChatPartOne: 'Collaboration between ',
beginningOfChatHistoryPolicyExpenseChatPartTwo: ' and ',
beginningOfChatHistoryPolicyExpenseChatPartThree: ' starts here! 🎉 This is the place to chat, request money and settle up.',
Expand Down
10 changes: 6 additions & 4 deletions src/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,13 @@ export default {
deleteConfirmation: '¿Estás seguro de que quieres eliminar este comentario?',
},
reportActionsView: {
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.',
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 ',
beginningOfChatHistoryUserRoomPartTwo: '.',
beginningOfChatHistory: 'Aquí comienza tu historial de conversaciones con ',
beginningOfChatHistoryPrivatePartOne: 'Este es el principio de la sala privada ',
beginningOfChatHistoryRestrictedPartOne: 'Este es el principio de ',
beginningOfChatHistoryPrivatePartTwo: ', invita a otros @mencionándolos.',
beginningOfChatHistoryRestrictedPartTwo: ', invita a otros @mencionándolos.',
beginningOfChatHistoryPolicyExpenseChatPartOne: '¡La colaboración entre ',
beginningOfChatHistoryPolicyExpenseChatPartTwo: ' y ',
beginningOfChatHistoryPolicyExpenseChatPartThree: ' empieza aquí! :tada: Este es el lugar donde chatear, pedir dinero y pagar.',
Expand Down
32 changes: 32 additions & 0 deletions src/libs/reportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,37 @@ function getChatRoomSubtitle(report, policiesMap) {
);
}

/**
* Get welcome message based on room type
* @param {Object} report
* @param {Object} policiesMap must have Onyxkey prefix (i.e 'policy_') for keys
* @returns {Object}
*/

function getRoomWelcomeMessage(report, policiesMap) {
const welcomeMessage = {};

const workspaceName = lodashGet(
policiesMap,
[`${ONYXKEYS.COLLECTION.POLICY}${report.policyID}`, 'name'],
Localize.translateLocal('workspace.common.unavailable'),
);

if (isAdminRoom(report)) {
welcomeMessage.phrase1 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryAdminRoomPartOne', {workspaceName});
welcomeMessage.phrase2 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryAdminRoomPartTwo');
} else if (isAnnounceRoom(report)) {
welcomeMessage.phrase1 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryAnnounceRoomPartOne', {workspaceName});
welcomeMessage.phrase2 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryAnnounceRoomPartTwo', {workspaceName});
} else {
// Message for user created rooms or other room types.
welcomeMessage.phrase1 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryUserRoomPartOne');
welcomeMessage.phrase2 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryUserRoomPartTwo');
}

return welcomeMessage;
}

/**
* Only returns true if this is our main 1:1 DM report with Concierge
*
Expand Down Expand Up @@ -290,4 +321,5 @@ export {
formatReportLastMessageText,
chatIncludesConcierge,
isPolicyExpenseChat,
getRoomWelcomeMessage,
};

0 comments on commit 3da9974

Please sign in to comment.