-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
ParentNavigationSubtitle.js
62 lines (53 loc) · 2.27 KB
/
ParentNavigationSubtitle.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import React from 'react';
import PropTypes from 'prop-types';
import styles from '../styles/styles';
import CONST from '../CONST';
import Text from './Text';
import PressableWithoutFeedback from './Pressable/PressableWithoutFeedback';
import Navigation from '../libs/Navigation/Navigation';
import ROUTES from '../ROUTES';
import useLocalize from '../hooks/useLocalize';
const propTypes = {
parentNavigationSubtitleData: PropTypes.shape({
// Title of root report room
rootReportName: PropTypes.string,
// Name of workspace, if any
workspaceName: PropTypes.string,
}).isRequired,
/** parent Report ID */
parentReportID: PropTypes.string,
/** PressableWithoutFeedack additional styles */
// eslint-disable-next-line react/forbid-prop-types
pressableStyles: PropTypes.arrayOf(PropTypes.object),
};
const defaultProps = {
parentReportID: '',
pressableStyles: [],
};
function ParentNavigationSubtitle(props) {
const {workspaceName, rootReportName} = props.parentNavigationSubtitleData;
const {translate} = useLocalize();
return (
<PressableWithoutFeedback
onPress={() => {
Navigation.navigate(ROUTES.getReportRoute(props.parentReportID));
}}
accessibilityLabel={translate('threads.parentNavigationSummary', {rootReportName, workspaceName})}
accessibilityRole={CONST.ACCESSIBILITY_ROLE.LINK}
style={[...props.pressableStyles]}
>
<Text
style={[styles.optionAlternateText]}
numberOfLines={1}
>
<Text style={[styles.optionAlternateText, styles.textLabelSupporting]}>{`${translate('threads.from')} `}</Text>
<Text style={[styles.optionAlternateText, styles.textLabelSupporting, styles.link]}>{rootReportName}</Text>
{Boolean(workspaceName) && <Text style={[styles.optionAlternateText, styles.textLabelSupporting]}>{` ${translate('threads.in')} ${workspaceName}`}</Text>}
</Text>
</PressableWithoutFeedback>
);
}
ParentNavigationSubtitle.defaultProps = defaultProps;
ParentNavigationSubtitle.propTypes = propTypes;
ParentNavigationSubtitle.displayName = 'ParentNavigationSubtitle';
export default ParentNavigationSubtitle;