-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40010 from rezkiy37/feature/38773-support-read-on…
…ly-messages Support read only messages
- Loading branch information
Showing
16 changed files
with
197 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import React, {useMemo} from 'react'; | ||
import {withOnyx} from 'react-native-onyx'; | ||
import type {OnyxCollection, OnyxEntry} from 'react-native-onyx'; | ||
import Banner from '@components/Banner'; | ||
import * as Expensicons from '@components/Icon/Expensicons'; | ||
import Text from '@components/Text'; | ||
import TextLink from '@components/TextLink'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import * as PolicyUtils from '@libs/PolicyUtils'; | ||
import * as ReportUtils from '@libs/ReportUtils'; | ||
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} from '@src/types/onyx'; | ||
|
||
type SystemChatReportFooterMessageOnyxProps = { | ||
/** Saved onboarding purpose selected by the user */ | ||
choice: OnyxEntry<OnboardingPurposeType>; | ||
|
||
/** The list of this user's policies */ | ||
policies: OnyxCollection<PolicyType>; | ||
|
||
/** policyID for main workspace */ | ||
activePolicyID: OnyxEntry<Required<string>>; | ||
}; | ||
|
||
type SystemChatReportFooterMessageProps = SystemChatReportFooterMessageOnyxProps; | ||
|
||
function SystemChatReportFooterMessage({choice, policies, activePolicyID}: SystemChatReportFooterMessageProps) { | ||
const {translate} = useLocalize(); | ||
const styles = useThemeStyles(); | ||
|
||
const adminChatReport = useMemo(() => { | ||
const adminPolicy = activePolicyID | ||
? PolicyUtils.getPolicy(activePolicyID ?? '') | ||
: Object.values(policies ?? {}).find((policy) => PolicyUtils.shouldShowPolicy(policy, false) && policy?.role === CONST.POLICY.ROLE.ADMIN && policy?.chatReportIDAdmins); | ||
|
||
return ReportUtils.getReport(String(adminPolicy?.chatReportIDAdmins)); | ||
}, [activePolicyID, policies]); | ||
|
||
const content = useMemo(() => { | ||
switch (choice) { | ||
case CONST.ONBOARDING_CHOICES.MANAGE_TEAM: | ||
return ( | ||
<> | ||
{translate('systemChatFooterMessage.newDotManageTeam.phrase1')} | ||
<TextLink onPress={() => Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(adminChatReport?.reportID ?? ''))}> | ||
{adminChatReport?.reportName ?? CONST.REPORT.WORKSPACE_CHAT_ROOMS.ADMINS} | ||
</TextLink> | ||
{translate('systemChatFooterMessage.newDotManageTeam.phrase2')} | ||
</> | ||
); | ||
default: | ||
return ( | ||
<> | ||
{translate('systemChatFooterMessage.default.phrase1')} | ||
<TextLink onPress={() => ReportInstance.navigateToConciergeChat()}>{CONST?.CONCIERGE_CHAT_NAME}</TextLink> | ||
{translate('systemChatFooterMessage.default.phrase2')} | ||
</> | ||
); | ||
} | ||
}, [adminChatReport?.reportName, adminChatReport?.reportID, choice, translate]); | ||
|
||
return ( | ||
<Banner | ||
containerStyles={[styles.archivedReportFooter]} | ||
shouldShowIcon | ||
icon={Expensicons.Lightbulb} | ||
content={<Text suppressHighlighting>{content}</Text>} | ||
/> | ||
); | ||
} | ||
|
||
SystemChatReportFooterMessage.displayName = 'SystemChatReportFooterMessage'; | ||
|
||
export default withOnyx<SystemChatReportFooterMessageProps, SystemChatReportFooterMessageOnyxProps>({ | ||
choice: { | ||
key: ONYXKEYS.ONBOARDING_PURPOSE_SELECTED, | ||
}, | ||
policies: { | ||
key: ONYXKEYS.COLLECTION.POLICY, | ||
}, | ||
activePolicyID: { | ||
key: ONYXKEYS.NVP_ACTIVE_POLICY_ID, | ||
initialValue: null, | ||
}, | ||
})(SystemChatReportFooterMessage); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.