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

✨ Bulk download analysis details #2142

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

Shevijacobson
Copy link
Contributor

@Shevijacobson Shevijacobson commented Oct 28, 2024

This PR introduces a new feature allowing users to download multiple analysis details at once.

Related to: #2143

Demo
Bulk Analysis Download Demo.

Copy link

codecov bot commented Oct 28, 2024

Codecov Report

Attention: Patch coverage is 20.00000% with 4 lines in your changes missing coverage. Please review.

Project coverage is 41.96%. Comparing base (b654645) to head (8919b1e).
Report is 241 commits behind head on main.

Files with missing lines Patch % Lines
client/src/app/api/rest.ts 20.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2142      +/-   ##
==========================================
+ Coverage   39.20%   41.96%   +2.76%     
==========================================
  Files         146      175      +29     
  Lines        4857     5635     +778     
  Branches     1164     1409     +245     
==========================================
+ Hits         1904     2365     +461     
- Misses       2939     3149     +210     
- Partials       14      121     +107     
Flag Coverage Δ
client 41.96% <20.00%> (+2.76%) ⬆️
server ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Shevijacobson Shevijacobson changed the title ✨ Bulk download analysis reports ✨ Bulk download analysis details Oct 28, 2024
.post<Task[]>(`${TASKS}/multiple`, ids, {
headers: headers,
responseType: responseType,
})
Copy link
Contributor

@jortel jortel Oct 28, 2024

Choose a reason for hiding this comment

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

Is there a reasons this does not use the existing List endpoint with a filter?
Example:

GET /tasks?filter=id:(1|2|3)

Filter construction is done a lot in the dynamic analysis reporting parts of the ui.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In light of @jortel feedback, I have updated the code to utilize the existing List endpoint with a filter, as suggested. Thank you for your input!

Copy link
Contributor

@jortel jortel left a comment

Choose a reason for hiding this comment

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

See comment re: List with filter.

Copy link
Member

@sjd78 sjd78 left a comment

Choose a reason for hiding this comment

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

Looks like a really nice base. A few changes requested

Comment on lines +216 to +219
const data =
selectedFormat === "yaml"
? yaml.dump(tasks, { indent: 2 })
: JSON.stringify(tasks, null, 2);
Copy link
Member

Choose a reason for hiding this comment

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

If the data is coming back in the requested "selectedFormat" why is it being formatted again?

Copy link
Contributor Author

@Shevijacobson Shevijacobson Oct 31, 2024

Choose a reason for hiding this comment

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

I realized that I was unnecessarily sending the selectedFormat parameter in the server request. Since the server function does not currently support returning data in that format, I’ve adjusted the implementation to handle JSON formatting on the UI side instead


setIsDownloadModalOpen(false);
} catch (error) {
console.error("Error fetching tasks:", error);
Copy link
Member

Choose a reason for hiding this comment

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

The user should be alerted to an error with at least a pushNotification()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for your valuable feedback. I have implemented the pushNotification() as you suggested to enhance user error alerts.

Comment on lines 1362 to 1393
<Modal
isOpen={isDownloadModalOpen}
variant="small"
title={t("actions.download", { what: "analysis details reports" })}
onClose={() => setIsDownloadModalOpen(false)}
>
<FormGroup label="Select Format" fieldId="format-select">
<div>
<Button
variant={selectedFormat === "json" ? "primary" : "secondary"}
onClick={() => setSelectedFormat("json")}
>
{<CodeIcon />} JSON
</Button>
<Button
variant={selectedFormat === "yaml" ? "primary" : "secondary"}
onClick={() => setSelectedFormat("yaml")}
>
{<CodeIcon />} YAML
</Button>
</div>
<p>Selected Format: {selectedFormat}</p>
</FormGroup>
<Button variant="primary" onClick={handleDownload}>
{t("actions.download")}
</Button>
</Modal>
Copy link
Member

@sjd78 sjd78 Oct 30, 2024

Choose a reason for hiding this comment

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

The look of the modal needs to be updated.

Have a look at the "Show dropdown modal": https://www.patternfly.org/components/modal#with-dropdown

Put the modal's action buttons in the actions parameter so they render in the correct place with all the good spacing.

Put the yaml vs json selection in a basic drop down: https://www.patternfly.org/components/forms/form-select#basic

For reference, this is what it looks like currently:
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the feedback! I've updated the modal following your recommendations:

  • The action buttons have been moved to the actions parameter to ensure proper alignment and spacing.
  • A dropdown for selecting the format has been added, utilizing the basic dropdown from PatternFly as suggested.

I've attached a screenshot of the updated modal for your review.

Please let me know if there are any further adjustments you'd recommend. Thank you again for guiding me through this!

Screenshot from 2024-11-02 22-07-59

Screenshot from 2024-10-31 21-02-10

@Shevijacobson Shevijacobson marked this pull request as ready for review October 31, 2024 19:36
Shevijacobson and others added 9 commits November 4, 2024 12:08
Signed-off-by: shevijacobson <shevijacob@gmail.com>
Signed-off-by: MiriSafra <m0533175827@gmail.com>
Signed-off-by: shevijacobson <shevijacob@gmail.com>
Signed-off-by: MiriSafra <m0533175827@gmail.com>
Signed-off-by: shevijacobson <shevijacob@gmail.com>
Signed-off-by: MiriSafra <m0533175827@gmail.com>
Signed-off-by: shevijacobson <shevijacob@gmail.com>
Signed-off-by: shevijacobson <shevijacob@gmail.com>
Signed-off-by: shevijacobson <shevijacob@gmail.com>
@Shevijacobson Shevijacobson force-pushed the bulk-download-reports branch 2 times, most recently from 365ec09 to b0a806a Compare November 4, 2024 11:11
MiriSafra and others added 4 commits November 4, 2024 13:55
Signed-off-by: MiriSafra <m0533175827@gmail.com>
Signed-off-by: shevijacobson <shevijacob@gmail.com>
Signed-off-by: shevijacobson <shevijacob@gmail.com>
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.

4 participants