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

Display blocking view and remove download button when user have no access to the report #42312

Merged
Show file tree
Hide file tree
Changes from 2 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
8 changes: 4 additions & 4 deletions src/components/AttachmentModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ function AttachmentModal({
let shouldShowThreeDotsButton = false;
if (!isEmptyObject(report)) {
headerTitleNew = translate(isReceiptAttachment ? 'common.receipt' : 'common.attachment');
shouldShowDownloadButton = allowDownload && isDownloadButtonReadyToBeShown && !isReceiptAttachment && !isOffline;
shouldShowDownloadButton = allowDownload && isDownloadButtonReadyToBeShown && !shouldShowNotFoundPage && !isReceiptAttachment && !isOffline;
shouldShowThreeDotsButton = isReceiptAttachment && isModalOpen && threeDotsMenuItems.length !== 0;
}
const context = useMemo(
Expand Down Expand Up @@ -515,7 +515,7 @@ function AttachmentModal({
onLinkPress={() => Navigation.dismissModal()}
/>
)}
{!isEmptyObject(report) && !isReceiptAttachment ? (
{!shouldShowNotFoundPage && (!isEmptyObject(report) && !isReceiptAttachment ? (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now wrong.

Copy link
Contributor Author

@Ahmed-Abdella Ahmed-Abdella May 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please tell me what is exactly wrong about it, I tested it and it works just fine, like before wrapping. The whole view now is wrapped inside ( after !shouldShowNotFoundPage.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, missed the (). All good here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please format this a little differently? It is hard to see the (which makes it confusing.

<AttachmentCarousel
report={report}
onNavigate={onNavigate}
Expand All @@ -527,7 +527,7 @@ function AttachmentModal({
!!sourceForAttachmentView &&
shouldLoadAttachment &&
!isLoading &&
!shouldShowNotFoundPage && (
(
<AttachmentCarouselPagerContext.Provider value={context}>
<AttachmentView
containerStyles={[styles.mh5]}
Expand All @@ -543,7 +543,7 @@ function AttachmentModal({
/>
</AttachmentCarouselPagerContext.Provider>
)
)}
))}
</View>
{/* If we have an onConfirm method show a confirmation button */}
{!!onConfirm && (
Expand Down
1 change: 1 addition & 0 deletions src/pages/home/report/ReportAttachments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ function ReportAttachments({route}: ReportAttachmentsProps) {
ComposerFocusManager.setReadyToFocus();
}}
onCarouselAttachmentChange={onCarouselAttachmentChange}
shouldShowNotFoundPage={!report?.reportID}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As suggested please use data from Onyx key.

we can directly subscribe to the key: ONYXKEYS.IS_LOADING_APP key on the ReportAttachments

We can subscribe to that key in this component.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Subscriping will be through the withOnyx function?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be hook is better. useOnyx.

/>
);
}
Expand Down
Loading