Skip to content

Commit

Permalink
Merge pull request #24643 from ishpaul777/copy-update-admin-only-post…
Browse files Browse the repository at this point in the history
…ing-rooms

fix:copy-update admin only posting rooms
  • Loading branch information
Joel Bettner authored Aug 21, 2023
2 parents 4a156bc + 441a76b commit c053381
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 20 deletions.
41 changes: 31 additions & 10 deletions src/components/ReportWelcomeText.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 */
Expand All @@ -46,6 +56,7 @@ const propTypes = {

const defaultProps = {
report: {},
policy: {},
personalDetails: {},
betas: [],
};
Expand All @@ -54,18 +65,23 @@ 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 participantAccountIDs = lodashGet(props.report, 'participantAccountIDs', []);
const isMultipleParticipant = participantAccountIDs.length > 1;
const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips(
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 (
<>
<View>
<Text style={[styles.textHero]}>{props.translate('reportActionsView.sayHello')}</Text>
<Text style={[styles.textHero]}>
{isChatRoom ? props.translate('reportActionsView.welcomeToRoom', {roomName: ReportUtils.getReportName(props.report)}) : props.translate('reportActionsView.sayHello')}
</Text>
</View>
<Text style={[styles.mt3, styles.mw100]}>
{isPolicyExpenseChat && (
Expand All @@ -84,14 +100,19 @@ function ReportWelcomeText(props) {
{isChatRoom && (
<>
<Text>{roomWelcomeMessage.phrase1}</Text>
<Text
style={[styles.textStrong]}
onPress={() => Navigation.navigate(ROUTES.getReportDetailsRoute(props.report.reportID))}
suppressHighlighting
>
{ReportUtils.getReportName(props.report)}
</Text>
<Text>{roomWelcomeMessage.phrase2}</Text>
{/* for rooms in which only admins can post we dont need room name and phrase two */}
{(!isAdminsOnlyPostingRoom || isUserPolicyAdmin) && (
<>
<Text
style={[styles.textStrong]}
onPress={() => Navigation.navigate(ROUTES.getReportDetailsRoute(props.report.reportID))}
suppressHighlighting
>
{ReportUtils.getReportName(props.report)}
</Text>
<Text>{roomWelcomeMessage.phrase2}</Text>
</>
)}
</>
)}
{isDefault && (
Expand Down
4 changes: 2 additions & 2 deletions src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,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 ',
Expand All @@ -324,6 +323,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: {
Expand Down
4 changes: 2 additions & 2 deletions src/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,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 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 ',
Expand All @@ -323,6 +322,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: {
Expand Down
11 changes: 6 additions & 5 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -761,10 +761,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);

Expand All @@ -777,9 +778,8 @@ function getRoomWelcomeMessage(report) {
} else if (isAdminRoom(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});
} else if (isAdminsOnlyPostingRoom(report) && !isUserPolicyAdmin) {
welcomeMessage.phrase1 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryAdminOnlyPostingRoom');
} else if (isAnnounceRoom(report)) {
welcomeMessage.phrase1 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryAnnounceRoomPartOne', {workspaceName});
welcomeMessage.phrase2 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryAnnounceRoomPartTwo', {workspaceName});
Expand All @@ -802,7 +802,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}
*/
Expand Down Expand Up @@ -3284,6 +3284,7 @@ export {
sortReportsByLastRead,
isDefaultRoom,
isAdminRoom,
isAdminsOnlyPostingRoom,
isAnnounceRoom,
isUserCreatedPolicyRoom,
isChatRoom,
Expand Down
5 changes: 4 additions & 1 deletion src/pages/home/report/ReportActionItemCreated.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ function ReportActionItemCreated(props) {
/>
</PressableWithoutFeedback>
<View style={[styles.ph5]}>
<ReportWelcomeText report={props.report} />
<ReportWelcomeText
report={props.report}
policy={props.policy}
/>
</View>
</View>
</View>
Expand Down

0 comments on commit c053381

Please sign in to comment.