Skip to content

Commit

Permalink
Merge pull request #31485 from pasyukevich/feature/migrate-ParentNavi…
Browse files Browse the repository at this point in the history
…gationSubtitle
  • Loading branch information
dangrous authored Nov 21, 2023
2 parents 0cca90a + 977fbf2 commit 689338c
Showing 1 changed file with 10 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,49 +1,38 @@
import PropTypes from 'prop-types';
import React from 'react';
import {StyleProp, ViewStyle} from 'react-native';
import useLocalize from '@hooks/useLocalize';
import Navigation from '@libs/Navigation/Navigation';
import useThemeStyles from '@styles/useThemeStyles';
import CONST from '@src/CONST';
import {ParentNavigationSummaryParams} from '@src/languages/types';
import ROUTES from '@src/ROUTES';
import PressableWithoutFeedback from './Pressable/PressableWithoutFeedback';
import Text from './Text';

const propTypes = {
parentNavigationSubtitleData: PropTypes.shape({
// Title of root report room
rootReportName: PropTypes.string,

// Name of workspace, if any
workspaceName: PropTypes.string,
}).isRequired,
type ParentNavigationSubtitleProps = {
parentNavigationSubtitleData: ParentNavigationSummaryParams;

/** parent Report ID */
parentReportID: PropTypes.string,
parentReportID?: string;

/** PressableWithoutFeedack additional styles */
// eslint-disable-next-line react/forbid-prop-types
pressableStyles: PropTypes.arrayOf(PropTypes.object),
};

const defaultProps = {
parentReportID: '',
pressableStyles: [],
pressableStyles?: StyleProp<ViewStyle>;
};

function ParentNavigationSubtitle(props) {
function ParentNavigationSubtitle({parentNavigationSubtitleData, parentReportID = '', pressableStyles}: ParentNavigationSubtitleProps) {
const styles = useThemeStyles();
const {workspaceName, rootReportName} = props.parentNavigationSubtitleData;
const {workspaceName, rootReportName} = parentNavigationSubtitleData;

const {translate} = useLocalize();

return (
<PressableWithoutFeedback
onPress={() => {
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(props.parentReportID));
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(parentReportID));
}}
accessibilityLabel={translate('threads.parentNavigationSummary', {rootReportName, workspaceName})}
role={CONST.ACCESSIBILITY_ROLE.LINK}
style={[...props.pressableStyles]}
style={pressableStyles}
>
<Text
style={[styles.optionAlternateText]}
Expand All @@ -57,7 +46,5 @@ function ParentNavigationSubtitle(props) {
);
}

ParentNavigationSubtitle.defaultProps = defaultProps;
ParentNavigationSubtitle.propTypes = propTypes;
ParentNavigationSubtitle.displayName = 'ParentNavigationSubtitle';
export default ParentNavigationSubtitle;

0 comments on commit 689338c

Please sign in to comment.