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 when generating a PDF report, the open report button in safari does not work #7019

Conversation

chantal-kelm
Copy link
Member

@chantal-kelm chantal-kelm commented Sep 25, 2024

Description

Fix when generating a PDF report, the open report button in safari does not work

Issues Resolved

#7018

Evidence

Grabacion.de.pantalla.2024-09-25.a.la.s.4.16.02.p.m.mov

Test

[Provide instructions to test this PR

  • Go to some module

  • Click on generate pdf report

  • Click on open report button

Check List

  • All tests pass
    • yarn test:jest
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

@chantal-kelm chantal-kelm self-assigned this Sep 25, 2024
Comment on lines 97 to 114
onClick={() => {
// Open the new tab immediately
const windowReference = window.open('', '_blank');

// Verify if the new tab was locked
if (windowReference) {
// Get the URL (in this case, it is obtained directly, but it can be asynchronous)
const url = getHttp().basePath.prepend(
`/reports/${filename}`,
);

// Then assign the URL to the new tab
windowReference.location = url;
} else {
// If the tab is locked, it displays an alert to the user.
alert('The tab was blocked. Please enable pop-up windows.');
}
}}
Copy link
Member

Choose a reason for hiding this comment

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

thought: I see you changed to window.open. For this case, we could try a cleaner solution using a link instead of manage the access to the report with a onClick. Could you try it?

In the case we implement the proposed solution in the onClick, there are more usages of window.open that could be failing in Safari too. We should review them.

CHANGELOG.md Outdated
@@ -21,6 +21,7 @@ All notable changes to the Wazuh app project will be documented in this file.
- Fixed missing options depending on agent operating system in the agent configuration report [#6983](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6983)
- Fixed an style that affected the Discover plugin [#6989](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6989)
- Fixed a problem updating the API host registry in the GET /api/check-stored-api [#6995](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6995)
- Fixed, when generating a PDF report, the open report button in safari does not work [#7019](https://github.com/wazuh/wazuh-dashboard-plugins/pull/7019)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- Fixed, when generating a PDF report, the open report button in safari does not work [#7019](https://github.com/wazuh/wazuh-dashboard-plugins/pull/7019)
- Fixed the `Open report` button does not work on Safari [#7019](https://github.com/wazuh/wazuh-dashboard-plugins/pull/7019)

Copy link
Member Author

Choose a reason for hiding this comment

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

I have corrected the changelog by mentioning the two changes I have made 649e7d9

  • Fixed the Open report button of the toast and the Download report icon of the reporting table in Safari #7019

Copy link
Contributor

Wazuh Core plugin code coverage (Jest) test % values
Statements 45.5% ( 400 / 879 )
Branches 41.09% ( 157 / 382 )
Functions 43.87% ( 136 / 310 )
Lines 45.69% ( 398 / 871 )

Copy link
Contributor

Wazuh Check Updates plugin code coverage (Jest) test % values
Statements 76.44% ( 172 / 225 )
Branches 58.65% ( 61 / 104 )
Functions 61.7% ( 29 / 47 )
Lines 76.44% ( 172 / 225 )

Copy link
Contributor

Main plugin code coverage (Jest) test % values
Statements 13.8% ( 4069 / 29477 )
Branches 9.16% ( 1765 / 19264 )
Functions 13.46% ( 959 / 7124 )
Lines 13.97% ( 3965 / 28363 )

Copy link
Member

@Machi3mfl Machi3mfl left a comment

Choose a reason for hiding this comment

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

Screen.Recording.2024-09-26.at.2.45.50.PM.mov

Copy link
Member

@asteriscos asteriscos left a comment

Choose a reason for hiding this comment

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

CR: 🟢
Test: 🟢

Peek.2024-09-26.20-19.mp4

@asteriscos asteriscos merged commit a2ab3ee into 4.9.1 Sep 26, 2024
5 checks passed
@asteriscos asteriscos deleted the bug/7018-when-generating-a-PDF-report-the-open-report-button-in-safari-does-not-work branch September 26, 2024 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When generating a PDF report, the open report button in safari does not work
4 participants