-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Support read only messages #40010
Support read only messages #40010
Changes from 31 commits
7f4f512
297a231
cd7a95f
26bcce6
de29862
e2ad69d
471a02a
b4aed0f
0c1efc3
d72ceab
287fbe1
7adce5f
c386da0
8243a2b
3896162
af3b05f
09a118c
cd25155
15478c0
c5da50e
6b41cde
84c583b
1b7d32a
990e3cb
8fa54e6
a93647a
23b0ba0
ace67dc
517253c
c98a79f
68bcbd2
ab9b7f2
5eb36c8
a35ea06
cfc1231
a85b757
4a92c91
2f17417
ae9af7f
3512f7c
0c80ad7
9076bc0
62b193a
90a72e9
907167c
38cbb1b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3234,6 +3234,16 @@ export default { | |
}, | ||
copyReferralLink: 'Copiar enlace de invitación', | ||
}, | ||
onboardingBottomMessage: { | ||
[CONST.INTRO_CHOICES.MANAGE_TEAM]: { | ||
phrase1: 'Chatea con tu especialista asignado en ', | ||
phrase2: ' para obtener ayuda', | ||
}, | ||
default: { | ||
phrase1: 'Envía un email a ', | ||
phrase2: ' para obtener ayuda con la configuración', | ||
}, | ||
Comment on lines
+3260
to
+3267
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would check the style does not go crazy in Spanish because I think the translations is slightly longer |
||
}, | ||
violations: { | ||
allTagLevelsRequired: 'Todas las etiquetas son obligatorias', | ||
autoReportedRejectedExpense: ({rejectedBy, rejectReason}: ViolationsAutoReportedRejectedExpenseParams) => `${rejectedBy} rechazó la solicitud y comentó "${rejectReason}"`, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1172,10 +1172,25 @@ function isJoinRequestInAdminRoom(report: OnyxEntry<Report>): boolean { | |
return ReportActionsUtils.isActionableJoinRequestPending(report.reportID); | ||
} | ||
|
||
/** | ||
* Checks if report is in read-only mode. | ||
*/ | ||
function isReadOnly(report: OnyxEntry<Report>): boolean { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given the implementation and possible permissions, this name feels kind of wrong. Something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. UPD.mp4 |
||
if (Array.isArray(report?.permissions)) { | ||
return !report?.permissions?.includes(CONST.REPORT.PERMISSIONS.WRITE); | ||
} | ||
|
||
return false; | ||
} | ||
|
||
/** | ||
* Checks if the current user is allowed to comment on the given report. | ||
*/ | ||
function isAllowedToComment(report: OnyxEntry<Report>): boolean { | ||
if (isReadOnly(report)) { | ||
return false; | ||
} | ||
|
||
// Default to allowing all users to post | ||
const capability = report?.writeCapability ?? CONST.REPORT.WRITE_CAPABILITIES.ALL; | ||
|
||
|
@@ -5374,7 +5389,7 @@ function canUserPerformWriteAction(report: OnyxEntry<Report>) { | |
return false; | ||
} | ||
|
||
return !isArchivedRoom(report) && isEmptyObject(reportErrors) && report && isAllowedToComment(report) && !isAnonymousUser; | ||
return !isArchivedRoom(report) && isEmptyObject(reportErrors) && report && isAllowedToComment(report) && !isAnonymousUser && !isReadOnly(report); | ||
} | ||
|
||
/** | ||
|
@@ -6254,7 +6269,6 @@ export { | |
getParsedComment, | ||
getParticipantAccountIDs, | ||
getParticipants, | ||
getPayeeName, | ||
getPendingChatMembers, | ||
getPersonalDetailsForAccountID, | ||
getPolicyDescriptionText, | ||
|
@@ -6289,6 +6303,7 @@ export { | |
getWorkspaceChats, | ||
getWorkspaceIcon, | ||
goBackToDetailsPage, | ||
getPayeeName, | ||
hasActionsWithErrors, | ||
hasAutomatedExpensifyAccountIDs, | ||
hasExpensifyGuidesEmails, | ||
|
@@ -6376,6 +6391,7 @@ export { | |
isValidReport, | ||
isValidReportIDFromPath, | ||
isWaitingForAssigneeToCompleteTask, | ||
isReadOnly, | ||
navigateToDetailsPage, | ||
navigateToPrivateNotes, | ||
parseReportRouteParams, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -207,6 +207,7 @@ function ReportScreen({ | |
isOptimisticReport: reportProp?.isOptimisticReport, | ||
lastMentionedTime: reportProp?.lastMentionedTime, | ||
avatarUrl: reportProp?.avatarUrl, | ||
permissions: reportProp?.permissions, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When a user signs-in via google after viewing a public room, the |
||
}), | ||
[ | ||
reportProp?.lastReadTime, | ||
|
@@ -246,6 +247,7 @@ function ReportScreen({ | |
reportProp?.isOptimisticReport, | ||
reportProp?.lastMentionedTime, | ||
reportProp?.avatarUrl, | ||
reportProp?.permissions, | ||
], | ||
); | ||
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I propose to name this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done - 9076bc0. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import React, {useMemo} from 'react'; | ||
import {View} from 'react-native'; | ||
import {withOnyx} from 'react-native-onyx'; | ||
import type {OnyxCollection, OnyxEntry} from 'react-native-onyx'; | ||
import Text from '@components/Text'; | ||
import TextLink from '@components/TextLink'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import useWindowDimensions from '@hooks/useWindowDimensions'; | ||
import * as PolicyUtils from '@libs/PolicyUtils'; | ||
import Navigation from '@navigation/Navigation'; | ||
import * as ReportInstance from '@userActions/Report'; | ||
import type {OnboardingPurposeType} from '@src/CONST'; | ||
import CONST from '@src/CONST'; | ||
import ONYXKEYS from '@src/ONYXKEYS'; | ||
import ROUTES from '@src/ROUTES'; | ||
import type {Policy as PolicyType, Report} from '@src/types/onyx'; | ||
|
||
type OnboardingReportFooterMessageOnyxProps = { | ||
/** Saved onboarding purpose selected by the user */ | ||
choice: OnyxEntry<OnboardingPurposeType>; | ||
|
||
/** Collection of reports */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Which reports? All users reports? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, the app is looking for an admin chat to show in the banner. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is another way: to the active policyID by There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you think about this approach - 90a72e9? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a problem when the user creates a new account, the active policy does not exist yet. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test.mp4 |
||
reports: OnyxCollection<Report>; | ||
|
||
/** The list of this user's policies */ | ||
policies: OnyxCollection<PolicyType>; | ||
}; | ||
type OnboardingReportFooterMessageProps = OnboardingReportFooterMessageOnyxProps; | ||
rezkiy37 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
function OnboardingReportFooterMessage({choice, reports, policies}: OnboardingReportFooterMessageProps) { | ||
const {translate} = useLocalize(); | ||
const styles = useThemeStyles(); | ||
const {isSmallScreenWidth} = useWindowDimensions(); | ||
|
||
const adminChatReport = useMemo(() => { | ||
const adminsReports = Object.values(reports ?? {}).filter((report) => report?.chatType === CONST.REPORT.CHAT_TYPE.POLICY_ADMINS); | ||
const activePolicies = Object.values(policies ?? {}).filter((policy) => PolicyUtils.shouldShowPolicy(policy, false)); | ||
|
||
return adminsReports.find((report) => activePolicies.find((policy) => policy?.id === report?.policyID)); | ||
}, [policies, reports]); | ||
|
||
const content = useMemo(() => { | ||
switch (choice) { | ||
case CONST.ONBOARDING_CHOICES.MANAGE_TEAM: | ||
return ( | ||
<> | ||
{translate('onboardingBottomMessage.newDotManageTeam.phrase1')} | ||
<TextLink | ||
style={styles.label} | ||
onPress={() => Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(adminChatReport?.reportID ?? ''))} | ||
> | ||
{adminChatReport?.reportName ?? CONST.REPORT.WORKSPACE_CHAT_ROOMS.ADMINS} | ||
</TextLink> | ||
{translate('onboardingBottomMessage.newDotManageTeam.phrase2')} | ||
</> | ||
); | ||
default: | ||
return ( | ||
<> | ||
{translate('onboardingBottomMessage.default.phrase1')} | ||
<TextLink | ||
style={styles.label} | ||
onPress={() => ReportInstance.navigateToConciergeChat()} | ||
> | ||
{`${CONST?.CONCIERGE_CHAT_NAME}`} | ||
</TextLink> | ||
{translate('onboardingBottomMessage.default.phrase2')} | ||
</> | ||
); | ||
} | ||
}, [adminChatReport?.reportName, adminChatReport?.reportID, choice, styles.label, translate]); | ||
|
||
return ( | ||
<View | ||
style={[ | ||
styles.chatFooter, | ||
isSmallScreenWidth ? styles.mb5 : styles.mb4, | ||
styles.mh5, | ||
styles.mt4, | ||
styles.flexRow, | ||
styles.alignItemsCenter, | ||
styles.p4, | ||
styles.borderRadiusComponentLarge, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this might be too large? cc @Expensify/design - I have a feeling we were using something like 8px in the mocks instead of 16px? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I updated the component to reuse the Banner under the hood - #40010 (comment). |
||
styles.hoveredComponentBG, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why hoveredComponentBG and not just a regular componentBG background color? What did we have in the mocks? cc @Expensify/design There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I updated the component to reuse the Banner under the hood - #40010 (comment). |
||
styles.breakWord, | ||
styles.justifyContentCenter, | ||
]} | ||
> | ||
<Text style={[styles.textSupporting, styles.label]}>{content}</Text> | ||
</View> | ||
); | ||
} | ||
|
||
OnboardingReportFooterMessage.displayName = 'OnboardingReportFooterMessage'; | ||
|
||
export default withOnyx<OnboardingReportFooterMessageProps, OnboardingReportFooterMessageOnyxProps>({ | ||
choice: { | ||
key: ONYXKEYS.ONBOARDING_PURPOSE_SELECTED, | ||
}, | ||
reports: { | ||
key: ONYXKEYS.COLLECTION.REPORT, | ||
}, | ||
policies: { | ||
key: ONYXKEYS.COLLECTION.POLICY, | ||
}, | ||
})(OnboardingReportFooterMessage); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -186,6 +186,8 @@ type Report = OnyxCommon.OnyxValueWithOfflineFeedback< | |
transactionThreadReportID?: string; | ||
|
||
fieldList?: Record<string, PolicyReportField>; | ||
|
||
permissions?: Array<ValueOf<typeof CONST.REPORT.PERMISSIONS>>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There should be a comment here |
||
}, | ||
PolicyReportField['fieldID'] | ||
>; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I propose to name this
systemChatFooterMessage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done - 62b193a.