Skip to content

Commit

Permalink
feat: 14131
Browse files Browse the repository at this point in the history
  • Loading branch information
tienifr committed Jan 20, 2023
1 parent 5aabd37 commit 1236e72
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 46 deletions.
47 changes: 27 additions & 20 deletions src/libs/Navigation/AppNavigator/MainDrawerNavigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import SidebarScreen from '../../../pages/home/sidebar/SidebarScreen';
import BaseDrawerNavigator from './BaseDrawerNavigator';
import * as ReportUtils from '../../ReportUtils';
import reportPropTypes from '../../../pages/reportPropTypes';
import * as ReportActionContextMenu from '../../../pages/home/report/ContextMenu/ReportActionContextMenu';
import PopoverReportActionContextMenu from '../../../pages/home/report/ContextMenu/PopoverReportActionContextMenu';

const propTypes = {
/** Available reports that would be displayed in this navigator */
Expand Down Expand Up @@ -80,26 +82,31 @@ class MainDrawerNavigator extends Component {
// This way routing information is updated (if needed) based on the initial report ID resolved.
// This is usually needed after login/create account and re-launches
return (
<BaseDrawerNavigator
drawerContent={({navigation, state}) => {
// This state belongs to the drawer so it should always have the ReportScreen as it's initial (and only) route
const reportIDFromRoute = lodashGet(state, ['routes', 0, 'params', 'reportID']);
return (
<SidebarScreen
navigation={navigation}
reportIDFromRoute={reportIDFromRoute}
/>
);
}}
screens={[
{
name: SCREENS.REPORT,
component: ReportScreen,
initialParams: this.initialParams,
},
]}
isMainScreen
/>
<>
<PopoverReportActionContextMenu
ref={ReportActionContextMenu.contextMenuRef}
/>
<BaseDrawerNavigator
drawerContent={({navigation, state}) => {
// This state belongs to the drawer so it should always have the ReportScreen as it's initial (and only) route
const reportIDFromRoute = lodashGet(state, ['routes', 0, 'params', 'reportID']);
return (
<SidebarScreen
navigation={navigation}
reportIDFromRoute={reportIDFromRoute}
/>
);
}}
screens={[
{
name: SCREENS.REPORT,
component: ReportScreen,
initialParams: this.initialParams,
},
]}
isMainScreen
/>
</>
);
}
}
Expand Down
27 changes: 12 additions & 15 deletions src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
Dimensions,
} from 'react-native';
import _ from 'underscore';
import PropTypes from 'prop-types';
import lodashGet from 'lodash/get';
import * as Report from '../../../../libs/actions/Report';
import withLocalize, {withLocalizePropTypes} from '../../../../components/withLocalize';
Expand All @@ -12,20 +11,9 @@ import BaseReportActionContextMenu from './BaseReportActionContextMenu';
import ConfirmModal from '../../../../components/ConfirmModal';

const propTypes = {
/** Flag to check if the chat participant is Chronos */
isChronosReport: PropTypes.bool,

/** Whether the provided report is an archived room */
isArchivedRoom: PropTypes.bool,

...withLocalizePropTypes,
};

const defaultProps = {
isChronosReport: false,
isArchivedRoom: false,
};

class PopoverReportActionContextMenu extends React.Component {
constructor(props) {
super(props);
Expand All @@ -48,6 +36,8 @@ class PopoverReportActionContextMenu extends React.Component {
horizontal: 0,
vertical: 0,
},
isArchivedRoom: false,
isChronosReport: false,
};
this.onPopoverShow = () => {};
this.onPopoverHide = () => {};
Expand Down Expand Up @@ -126,6 +116,8 @@ class PopoverReportActionContextMenu extends React.Component {
* @param {String} draftMessage - ReportAction Draftmessage
* @param {Function} [onShow] - Run a callback when Menu is shown
* @param {Function} [onHide] - Run a callback when Menu is hidden
* @param {Boolean} isArchivedRoom - isArchivedRoom
* @param {Boolean} isChronosReport - isChronosReport
*/
showContextMenu(
type,
Expand All @@ -137,6 +129,8 @@ class PopoverReportActionContextMenu extends React.Component {
draftMessage,
onShow = () => {},
onHide = () => {},
isArchivedRoom,
isChronosReport,
) {
const nativeEvent = event.nativeEvent || {};
this.contextMenuAnchor = contextMenuAnchor;
Expand Down Expand Up @@ -167,6 +161,8 @@ class PopoverReportActionContextMenu extends React.Component {
selection,
isPopoverVisible: true,
reportActionDraftMessage: draftMessage,
isArchivedRoom,
isChronosReport,
});
});
}
Expand Down Expand Up @@ -239,8 +235,8 @@ class PopoverReportActionContextMenu extends React.Component {
selection={this.state.selection}
reportID={this.state.reportID}
reportAction={this.state.reportAction}
isArchivedRoom={this.props.isArchivedRoom}
isChronosReport={this.props.isChronosReport}
isArchivedRoom={this.state.isArchivedRoom}
isChronosReport={this.state.isChronosReport}
anchor={this.contextMenuTargetNode}
/>
);
Expand Down Expand Up @@ -269,6 +265,8 @@ class PopoverReportActionContextMenu extends React.Component {
reportAction: {},
isDeleteCommentConfirmModalVisible: false,
shouldSetModalVisibilityForDeleteConfirmation: true,
isArchivedRoom: false,
isChronosReport: false,
});
}

Expand Down Expand Up @@ -336,6 +334,5 @@ class PopoverReportActionContextMenu extends React.Component {
}

PopoverReportActionContextMenu.propTypes = propTypes;
PopoverReportActionContextMenu.defaultProps = defaultProps;

export default withLocalize(PopoverReportActionContextMenu);
6 changes: 6 additions & 0 deletions src/pages/home/report/ContextMenu/ReportActionContextMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const contextMenuRef = React.createRef();
* @param {String} draftMessage - ReportAction Draftmessage
* @param {Function} [onShow=() => {}] - Run a callback when Menu is shown
* @param {Function} [onHide=() => {}] - Run a callback when Menu is hidden
* @param {Boolean} isArchivedRoom - isArchivedRoom
* @param {Boolean} isChronosReport - isChronosReport
*/
function showContextMenu(
type,
Expand All @@ -25,6 +27,8 @@ function showContextMenu(
draftMessage = '',
onShow = () => {},
onHide = () => {},
isArchivedRoom = false,
isChronosReport = false,
) {
if (!contextMenuRef.current) {
return;
Expand All @@ -39,6 +43,8 @@ function showContextMenu(
draftMessage,
onShow,
onHide,
isArchivedRoom,
isChronosReport,
);
}

Expand Down
2 changes: 2 additions & 0 deletions src/pages/home/report/ReportActionItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ class ReportActionItem extends Component {
this.props.draftMessage,
undefined,
this.checkIfContextMenuActive,
ReportUtils.isArchivedRoom(this.props.report),
ReportUtils.chatIncludesChronos(this.props.report),
);
}

Expand Down
7 changes: 0 additions & 7 deletions src/pages/home/report/ReportActionsView.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import withWindowDimensions, {windowDimensionsPropTypes} from '../../../componen
import {withDrawerPropTypes} from '../../../components/withDrawerState';
import * as ReportScrollManager from '../../../libs/ReportScrollManager';
import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize';
import * as ReportActionContextMenu from './ContextMenu/ReportActionContextMenu';
import PopoverReportActionContextMenu from './ContextMenu/PopoverReportActionContextMenu';
import Performance from '../../../libs/Performance';
import {withNetwork} from '../../../components/OnyxProvider';
import * as EmojiPickerAction from '../../../libs/actions/EmojiPickerAction';
Expand Down Expand Up @@ -371,11 +369,6 @@ class ReportActionsView extends React.Component {
loadMoreChats={this.loadMoreChats}
newMarkerReportActionID={this.state.newMarkerReportActionID}
/>
<PopoverReportActionContextMenu
ref={ReportActionContextMenu.contextMenuRef}
isArchivedRoom={ReportUtils.isArchivedRoom(this.props.report)}
isChronosReport={ReportUtils.chatIncludesChronos(this.props.report)}
/>
</>
)}
<EmojiPicker ref={EmojiPickerAction.emojiPickerRef} />
Expand Down
4 changes: 0 additions & 4 deletions src/pages/settings/AppDownloadLinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import withWindowDimensions, {windowDimensionsPropTypes} from '../../components/
import * as DeviceCapabilities from '../../libs/DeviceCapabilities';
import * as ReportActionContextMenu from '../home/report/ContextMenu/ReportActionContextMenu';
import * as ContextMenuActions from '../home/report/ContextMenu/ContextMenuActions';
import PopoverReportActionContextMenu from '../home/report/ContextMenu/PopoverReportActionContextMenu';

const propTypes = {
...withLocalizePropTypes,
Expand Down Expand Up @@ -81,9 +80,6 @@ const AppDownloadLinksPage = (props) => {
onCloseButtonPress={() => Navigation.dismissModal(true)}
/>
<ScrollView style={[styles.mt5]}>
<PopoverReportActionContextMenu
ref={ReportActionContextMenu.contextMenuRef}
/>
{_.map(menuItems, item => (
<PressableWithSecondaryInteraction
key={item.translationKey}
Expand Down

0 comments on commit 1236e72

Please sign in to comment.