From 1feeb801ff29c7ba545e0d67d394370d32127320 Mon Sep 17 00:00:00 2001 From: ahmedGaber93 Date: Wed, 19 Jul 2023 01:24:52 +0200 Subject: [PATCH 01/12] display not found page when attachment is deleted. --- src/components/AttachmentCarousel/index.js | 170 ++++++++++++--------- src/components/AttachmentModal.js | 15 +- 2 files changed, 109 insertions(+), 76 deletions(-) diff --git a/src/components/AttachmentCarousel/index.js b/src/components/AttachmentCarousel/index.js index 85f3abcc90aa..30ae6f5bc5e7 100644 --- a/src/components/AttachmentCarousel/index.js +++ b/src/components/AttachmentCarousel/index.js @@ -21,6 +21,9 @@ import withLocalize, {withLocalizePropTypes} from '../withLocalize'; import compose from '../../libs/compose'; import withWindowDimensions from '../withWindowDimensions'; import reportPropTypes from '../../pages/reportPropTypes'; +import BlockingView from "../BlockingViews/BlockingView" +import * as Illustrations from "../Icon/Illustrations"; +import variables from '../../styles/variables'; const propTypes = { /** source is used to determine the starting index in the array of attachments */ @@ -29,6 +32,9 @@ const propTypes = { /** Callback to update the parent modal's state with a source and name from the attachments array */ onNavigate: PropTypes.func, + /** Callback to change the download button Visibility */ + toggleDownloadButtonVisibility: PropTypes.func, + /** Object of report actions for this report */ reportActions: PropTypes.objectOf(PropTypes.shape(reportActionPropTypes)), @@ -42,6 +48,7 @@ const defaultProps = { source: '', reportActions: {}, onNavigate: () => {}, + toggleDownloadButtonVisibility: () => {}, }; class AttachmentCarousel extends React.Component { @@ -190,12 +197,14 @@ class AttachmentCarousel extends React.Component { } const page = _.findIndex(attachments, (a) => a.source === this.props.source); - if (page === -1) { - throw new Error('Attachment not found'); + + if(page !== -1) { + // Update the parent modal's state with the source and name from the mapped attachments + this.props.onNavigate(attachments[page]); } - // Update the parent modal's state with the source and name from the mapped attachments - this.props.onNavigate(attachments[page]); + // Update the download button visibility in the parent modal + this.props.toggleDownloadButtonVisibility(page !== -1); return { page, @@ -302,82 +311,93 @@ class AttachmentCarousel extends React.Component { onMouseEnter={() => !this.canUseTouchScreen && this.toggleArrowsVisibility(true)} onMouseLeave={() => !this.canUseTouchScreen && this.toggleArrowsVisibility(false)} > - {this.state.shouldShowArrow && ( + {this.state.page === -1 ? ( + + ) : ( <> - {!isBackDisabled && ( - - -