Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:copy-update admin only posting rooms #24643

Merged
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 34 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,26 @@ 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(
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]}>
ishpaul777 marked this conversation as resolved.
Show resolved Hide resolved
{isAdminsOnlyPostingRoom || isAnnounceRoom
ishpaul777 marked this conversation as resolved.
Show resolved Hide resolved
? 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 +103,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>
</>
)}
Comment on lines +104 to +115
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the check should have rendered the second phrase if the room was archived

This change caused this regression: #25718

</>
)}
{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 @@ -310,8 +310,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 @@ -322,6 +321,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 @@ -309,8 +309,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 @@ -321,6 +320,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 @@ -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);

Expand All @@ -776,9 +777,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 @@ -801,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}
*/
Expand Down Expand Up @@ -3199,6 +3199,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