Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Can delete attachments in archived workspace #17329

Merged
merged 4 commits into from
May 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import * as Download from '../../libs/actions/Download';
import fileDownload from '../../libs/fileDownload';
import addEncryptedAuthTokenToURL from '../../libs/addEncryptedAuthTokenToURL';
import {ShowContextMenuContext, showContextMenuForReport} from '../ShowContextMenuContext';
import * as ReportUtils from '../../libs/ReportUtils';

const propTypes = {
/** Press in handler for the link */
Expand Down Expand Up @@ -48,7 +49,7 @@ const BaseAnchorForAttachmentsOnly = (props) => {
<ShowContextMenuContext.Consumer>
{({
anchor,
reportID,
report,
action,
checkIfContextMenuActive,
}) => (
Expand All @@ -66,9 +67,10 @@ const BaseAnchorForAttachmentsOnly = (props) => {
onLongPress={event => showContextMenuForReport(
event,
anchor,
reportID,
report.reportID,
action,
checkIfContextMenuActive,
ReportUtils.isArchivedRoom(report),
)}
>
<AttachmentView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import PressableWithoutFocus from '../../PressableWithoutFocus';
import CONST from '../../../CONST';
import {ShowContextMenuContext, showContextMenuForReport} from '../../ShowContextMenuContext';
import tryResolveUrlFromApiRoot from '../../../libs/tryResolveUrlFromApiRoot';
import * as ReportUtils from '../../../libs/ReportUtils';

const ImageRenderer = (props) => {
const htmlAttribs = props.tnode.attributes;
Expand Down Expand Up @@ -53,13 +54,13 @@ const ImageRenderer = (props) => {
<ShowContextMenuContext.Consumer>
{({
anchor,
reportID,
report,
action,
checkIfContextMenuActive,
}) => (
<AttachmentModal
allowDownload
reportID={reportID}
reportID={report.reportID}
source={source}
isAuthTokenRequired={isAttachment}
originalFileName={originalFileName}
Expand All @@ -68,7 +69,7 @@ const ImageRenderer = (props) => {
<PressableWithoutFocus
style={styles.noOutline}
onPress={show}
onLongPress={event => showContextMenuForReport(event, anchor, reportID, action, checkIfContextMenuActive)}
onLongPress={event => showContextMenuForReport(event, anchor, report.reportID, action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report))}
>
<ThumbnailImage
previewSourceURL={previewSource}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import htmlRendererPropTypes from '../htmlRendererPropTypes';
import withLocalize from '../../../withLocalize';
import {ShowContextMenuContext, showContextMenuForReport} from '../../../ShowContextMenuContext';
import styles from '../../../../styles/styles';
import * as ReportUtils from '../../../../libs/ReportUtils';

const propTypes = {
/** Press in handler for the code block */
Expand Down Expand Up @@ -36,14 +37,14 @@ const BasePreRenderer = forwardRef((props, ref) => {
<ShowContextMenuContext.Consumer>
{({
anchor,
reportID,
report,
action,
checkIfContextMenuActive,
}) => (
<TouchableWithoutFeedback
onPressIn={props.onPressIn}
onPressOut={props.onPressOut}
onLongPress={event => showContextMenuForReport(event, anchor, reportID, action, checkIfContextMenuActive)}
onLongPress={event => showContextMenuForReport(event, anchor, report.reportID, action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report))}
>
<View>
{/* eslint-disable-next-line react/jsx-props-no-spreading */}
Expand Down
7 changes: 4 additions & 3 deletions src/components/ShowContextMenuContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as DeviceCapabilities from '../libs/DeviceCapabilities';

const ShowContextMenuContext = React.createContext({
anchor: null,
reportID: null,
report: null,
action: undefined,
checkIfContextMenuActive: () => {},
});
Expand All @@ -20,12 +20,12 @@ ShowContextMenuContext.displayName = 'ShowContextMenuContext';
* @param {String} reportID - Active Report ID
* @param {Object} action - ReportAction for ContextMenu
* @param {Function} checkIfContextMenuActive Callback to update context menu active state
* @param {Boolean} [isArchivedRoom=false] - Is the report an archived room
*/
function showContextMenuForReport(event, anchor, reportID, action, checkIfContextMenuActive) {
function showContextMenuForReport(event, anchor, reportID, action, checkIfContextMenuActive, isArchivedRoom = false) {
ShogunFire marked this conversation as resolved.
Show resolved Hide resolved
if (!DeviceCapabilities.canUseTouchScreen()) {
return;
}

ReportActionContextMenu.showContextMenu(
ContextMenuActions.CONTEXT_MENU_TYPES.REPORT_ACTION,
event,
Expand All @@ -36,6 +36,7 @@ function showContextMenuForReport(event, anchor, reportID, action, checkIfContex
'',
checkIfContextMenuActive,
checkIfContextMenuActive,
isArchivedRoom,
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/report/ReportActionItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class ReportActionItem extends Component {
<ShowContextMenuContext.Provider
value={{
anchor: this.popoverAnchor,
reportID: this.props.report.reportID,
report: this.props.report,
action: this.props.action,
checkIfContextMenuActive: this.checkIfContextMenuActive,
}}
Expand Down
5 changes: 4 additions & 1 deletion src/pages/home/report/ReportActionsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@ const ReportActionsList = (props) => {

// Native mobile does not render updates flatlist the changes even though component did update called.
// To notify there something changes we can use extraData prop to flatlist
const extraData = (!props.isDrawerOpen && props.isSmallScreenWidth) ? props.newMarkerReportActionID : undefined;
const extraData = [
(!props.isDrawerOpen && props.isSmallScreenWidth) ? props.newMarkerReportActionID : undefined,
ReportUtils.isArchivedRoom(props.report),
];
const shouldShowReportRecipientLocalTime = ReportUtils.canShowReportRecipientLocalTime(props.personalDetails, props.report);
return (
<Animated.View style={[animatedStyles, styles.flex1]}>
Expand Down