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

move message "admins only can post" from welcome message to footer #41199

Merged
merged 13 commits into from
Jun 7, 2024
Merged
2 changes: 1 addition & 1 deletion src/components/ArchivedReportFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function ArchivedReportFooter({report, reportClosedAction, personalDetails = {}}

return (
<Banner
containerStyles={[styles.archivedReportFooter]}
containerStyles={[styles.chatFooterBanner]}
text={text}
shouldRenderHTML={shouldRenderHTML}
shouldShowIcon
Expand Down
4 changes: 1 addition & 3 deletions src/components/ReportWelcomeText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import Navigation from '@libs/Navigation/Navigation';
import * as OptionsListUtils from '@libs/OptionsListUtils';
import * as PolicyUtils from '@libs/PolicyUtils';
import * as ReportUtils from '@libs/ReportUtils';
import CONST from '@src/CONST';
import type {IOUType} from '@src/CONST';
Expand Down Expand Up @@ -46,8 +45,7 @@ function ReportWelcomeText({report, policy, personalDetails}: ReportWelcomeTextP
.filter((accountID) => accountID !== session?.accountID || !isOneOnOneChat);
const isMultipleParticipant = participantAccountIDs.length > 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);
const additionalText = moneyRequestOptions
.filter((item): item is Exclude<IOUType, typeof CONST.IOU.TYPE.REQUEST | typeof CONST.IOU.TYPE.SEND | typeof CONST.IOU.TYPE.INVOICE> => item !== CONST.IOU.TYPE.INVOICE)
Expand Down
2 changes: 1 addition & 1 deletion src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,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.`,
Expand All @@ -532,6 +531,7 @@ export default {
invoice: 'invoice an expense',
},
},
adminOnlyCanPost: 'Only admins can send messages in this room.',
reportAction: {
asCopilot: 'as copilot for',
},
Expand Down
2 changes: 1 addition & 1 deletion src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,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}.`,
Expand All @@ -525,6 +524,7 @@ export default {
invoice: 'facturar un gasto',
},
},
adminOnlyCanPost: 'Solo los administradores pueden enviar mensajes en esta sala.',
reportAction: {
asCopilot: 'como copiloto de',
},
Expand Down
5 changes: 1 addition & 4 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1564,7 +1564,7 @@ function canDeleteReportAction(reportAction: OnyxEntry<ReportAction>, reportID:
/**
* Get welcome message based on room type
*/
function getRoomWelcomeMessage(report: OnyxEntry<Report>, isUserPolicyAdmin: boolean): WelcomeMessage {
function getRoomWelcomeMessage(report: OnyxEntry<Report>): WelcomeMessage {
const welcomeMessage: WelcomeMessage = {showReportName: true};
const workspaceName = getPolicyName(report);

Expand All @@ -1577,9 +1577,6 @@ function getRoomWelcomeMessage(report: OnyxEntry<Report>, 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});
Expand Down
1 change: 1 addition & 0 deletions src/pages/home/ReportScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,7 @@ function ReportScreen({
onComposerBlur={() => setIsComposerFocus(false)}
report={report}
reportNameValuePairs={reportNameValuePairs}
policy={policy}
pendingAction={reportPendingAction}
isComposerFullSize={!!isComposerFullSize}
listHeight={listHeight}
Expand Down
27 changes: 26 additions & 1 deletion src/pages/home/report/ReportFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@ 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 * as Expensicons from '@components/Icon/Expensicons';
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 * as UserUtils from '@libs/UserUtils';
import variables from '@styles/variables';
Expand Down Expand Up @@ -42,6 +46,9 @@ type ReportFooterProps = ReportFooterOnyxProps & {

reportNameValuePairs?: OnyxEntry<OnyxTypes.ReportNameValuePairs>;

/** The policy of the report */
policy: OnyxEntry<OnyxTypes.Policy>;

/** The last report action */
lastReportAction?: OnyxEntry<OnyxTypes.ReportAction>;

Expand Down Expand Up @@ -73,6 +80,7 @@ function ReportFooter({
session,
report = {reportID: '0'},
reportNameValuePairs,
policy,
shouldShowComposeInput = false,
isEmptyChat = true,
isReportReadyForDisplay = true,
Expand All @@ -84,6 +92,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, reportNameValuePairs);
Expand All @@ -93,6 +102,8 @@ function ReportFooter({
const hideComposer = !ReportUtils.canUserPerformWriteAction(report, reportNameValuePairs) || blockedFromChat;
const canWriteInReport = ReportUtils.canWriteInReport(report);
const isSystemChat = ReportUtils.isSystemChat(report);
const isAdminsOnlyPostingRoom = ReportUtils.isAdminsOnlyPostingRoom(report);
const isUserPolicyAdmin = PolicyUtils.isPolicyAdmin(policy);

const allPersonalDetails = usePersonalDetails();

Expand Down Expand Up @@ -150,7 +161,13 @@ function ReportFooter({
return (
<>
{hideComposer && (
<View style={[styles.chatFooter, isArchivedRoom || isAnonymousUser || !canWriteInReport ? styles.mt4 : {}, isSmallScreenWidth ? styles.mb5 : null]}>
<View
style={[
styles.chatFooter,
isArchivedRoom || isAnonymousUser || !canWriteInReport || (isAdminsOnlyPostingRoom && !isUserPolicyAdmin) ? styles.mt4 : {},
isSmallScreenWidth ? styles.mb5 : null,
]}
>
{isAnonymousUser && !isArchivedRoom && (
<AnonymousReportFooter
report={report}
Expand All @@ -160,6 +177,14 @@ function ReportFooter({
{isArchivedRoom && <ArchivedReportFooter report={report} />}
{!isArchivedRoom && blockedFromChat && <BlockedReportFooter />}
{!isAnonymousUser && !canWriteInReport && isSystemChat && <SystemChatReportFooterMessage />}
{isAdminsOnlyPostingRoom && !isUserPolicyAdmin && !isArchivedRoom && !isAnonymousUser && !blockedFromChat && (
<Banner
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rushatgabhane while merge I found we have a new feature now called blocked users in main branch which will display <BlockedReportFooter /> in the footer, so I add !blockedFromChat to this condition to prevent display both of them at the same time.

Copy link
Member

Choose a reason for hiding this comment

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

nice catch!

containerStyles={[styles.chatFooterBanner]}
text={translate('adminOnlyCanPost')}
icon={Expensicons.Lightbulb}
shouldShowIcon
/>
)}
{!isSmallScreenWidth && <View style={styles.offlineIndicatorRow}>{hideComposer && <OfflineIndicator containerStyles={[styles.chatItemComposeSecondaryRow]} />}</View>}
</View>
)}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/report/SystemChatReportFooterMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function SystemChatReportFooterMessage({choice, policies, activePolicyID}: Syste

return (
<Banner
containerStyles={[styles.archivedReportFooter]}
containerStyles={[styles.chatFooterBanner]}
shouldShowIcon
icon={Expensicons.Lightbulb}
content={<Text suppressHighlighting>{content}</Text>}
Expand Down
2 changes: 1 addition & 1 deletion src/styles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3694,7 +3694,7 @@ const styles = (theme: ThemeColors) =>
height: variables.optionRowHeight,
},

archivedReportFooter: {
chatFooterBanner: {
borderRadius: variables.componentBorderRadius,
...wordBreak.breakWord,
},
Expand Down
Loading