-
Notifications
You must be signed in to change notification settings - Fork 3k
/
BaseReportActionContextMenu.js
executable file
·62 lines (56 loc) · 2.62 KB
/
BaseReportActionContextMenu.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 {View} from 'react-native';
import _ from 'underscore';
import PropTypes from 'prop-types';
import getReportActionContextMenuStyles from '../../../../styles/getReportActionContextMenuStyles';
import ContextMenuItem from '../../../../components/ContextMenuItem';
import {
propTypes as genericReportActionContextMenuPropTypes,
defaultProps as GenericReportActionContextMenuDefaultProps,
} from './genericReportActionContextMenuPropTypes';
import withLocalize, {withLocalizePropTypes} from '../../../../components/withLocalize';
import ContextMenuActions, {CONTEXT_MENU_TYPES} from './ContextMenuActions';
const propTypes = {
/** String representing the context menu type [LINK, REPORT_ACTION] which controls context menu choices */
type: PropTypes.string,
...genericReportActionContextMenuPropTypes,
...withLocalizePropTypes,
};
const defaultProps = {
type: CONTEXT_MENU_TYPES.REPORT_ACTION,
...GenericReportActionContextMenuDefaultProps,
};
class BaseReportActionContextMenu extends React.Component {
constructor(props) {
super(props);
this.wrapperStyle = getReportActionContextMenuStyles(this.props.isMini);
}
render() {
const shouldShowFilter = contextAction => contextAction.shouldShow(this.props.type, this.props.reportAction);
return this.props.isVisible && (
<View style={this.wrapperStyle}>
{_.map(_.filter(ContextMenuActions, shouldShowFilter), contextAction => (
<ContextMenuItem
icon={contextAction.icon}
text={this.props.translate(contextAction.textTranslateKey)}
successIcon={contextAction.successIcon}
successText={contextAction.successTextTranslateKey
? this.props.translate(contextAction.successTextTranslateKey)
: undefined}
isMini={this.props.isMini}
key={contextAction.textTranslateKey}
onPress={() => contextAction.onPress(!this.props.isMini, {
reportAction: this.props.reportAction,
reportID: this.props.reportID,
draftMessage: this.props.draftMessage,
selection: this.props.selection,
})}
/>
))}
</View>
);
}
}
BaseReportActionContextMenu.propTypes = propTypes;
BaseReportActionContextMenu.defaultProps = defaultProps;
export default withLocalize(BaseReportActionContextMenu);