-
Notifications
You must be signed in to change notification settings - Fork 8
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
ui: Show some basic information about found packages in the results main page #1125
base: main
Are you sure you want to change the base?
ui: Show some basic information about found packages in the results main page #1125
Conversation
// Find deduplicated package types in packages data. | ||
const detectedPackageManagers = [ | ||
...new Set( | ||
packages.data.map((item) => item.identifier?.type).filter(Boolean) | ||
), | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This likely doesn't work as the query is paginated, so packages
only contains the first page with the default size.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks to me like it wouldn't work for Gradle projects, which would instead list "Maven" as the package manager, which would be wrong. Please verify for a Gradle project that "Gradle" would be listed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this rather be changed to describe that the list is of the package sources, or something else that would describe it better? I believe to type to just be ORT Identifier's type, so data to do what you're suggesting is not available here. The same is probably true for NPM/Yarn/pnpm all using NPM packages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe to type to just be ORT Identifier's type, so data to do what you're suggesting is not available here.
The information about whether an Identifier
belongs to a package or project is not available in the Identifier
itself. What the code should do is to collect the types of the identifiers of all root projects in an ORT result instead of iterating over packages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe to type to just be ORT Identifier's type, so data to do what you're suggesting is not available here.
The information about whether an
Identifier
belongs to a package or project is not available in theIdentifier
itself. What the code should do is to collect the types of the identifiers of all root projects in an ORT result instead of iterating over packages.
IMO there can be value for both, showing what package managers are used to manage the project and what type of dependencies the project uses.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, and the list of package types should be sorted alphabetically to be deterministic.
Sorted by package count per type could be good and also deterministic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, but I'd also be fine with not having per-type counts in this first iteration. At least not in the card; that's probably too detailed information that could go to a header on the "Packages" tab.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"100 packages of 2 types (Maven, NPM) found"
How about "100 packages from 2 ecosystems (Maven, NPM)" instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was at first thinking about almost exactly the same as I was using "ecosystems" myself above, but then I didn't want to coin yet another new term. On the other hand, we should have the liberty to use "new" terms in the UI if we believe the (non-ORT) user is familiar with them.
TL;DR "100 packages from 2 ecosystems (Maven, NPM)" would be ok with me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This likely doesn't work as the query is paginated, so
packages
only contains the first page with the default size.
I think this needs to be either queried twice, or then once with a very large "page size".
), | ||
]; | ||
|
||
console.log(detectedPackageManagers); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be removed.
value={ortRun.jobs.analyzer ? '-' : 'N/A'} | ||
className='hover:bg-muted/50' | ||
value={ortRun.jobs.analyzer ? packagesTotal : 'N/A'} | ||
description={`from ${detectedPackageManagers.length} package managers (${detectedPackageManagers.join(`,`)})`} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO this would look better with a badge for each package manager instead of a sentence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a sentence is fine for now. For monorepos with several package managers badges would probably take up too much screen space.
Nit from the screenshot: "1 package managers" should omit the "s", or simply use "1 package manager(s)" to avoid logic that prints the "s" or not depending on the count. |
ace3360
to
0a93d06
Compare
const ecoSystems = [ | ||
...new Set( | ||
packages.data.map((item) => item.identifier?.type).filter(Boolean) | ||
), | ||
].sort(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should maybe be memoized as the array can be quite large.
aef49bd
to
f4c6b95
Compare
if (packagesIsPending) { | ||
return <LoadingIndicator />; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would look better if the card including the title and icon etc was there while the data is pending. I would maybe try skeleton at first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or just a loading replacing the package count, skeleton doesn't look too good on first try.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I replaced all "real" data with a loading indicator, because there's no point in showing "(a spinner) from ??? ecosystems (???)". So during loading and processing, only the title and icon are shown.
f4c6b95
to
9db83d0
Compare
<div className='text-2xl font-bold'> | ||
{value ? value === 'loading' ? <LoadingIndicator /> : value : '-'} | ||
</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be based on matching a magic string like "loading". The simplest solution could be to type value as React.ReactNode
.
There may be a bug in the packages endpoint - please hold on merging this until I've verified it. |
068485e
to
325a296
Compare
I disabled auto-merge. |
325a296
to
0cdc213
Compare
This optional field can be used to provide some extra at-a-glance information for the ORT run main results page. An example of such info is the detected package managers for the packages statistics card. Signed-off-by: Jyrki Keisala <[email protected]>
For the purpose of de-duplicating and showing all unique ecosystems found from the packages (specifically, from `identifier.type`), it is currently required to fetch all package data and filter it in the front-end. For large projects, this can take seconds for the first time data is fetched and processed. In order to not block the whole ORT run results main page from rendering, while the package data is being processed, move the processing and showing of the data to its own subcomponent of the page. This way, the main page loads, and a loading state (a spinning wheel) is only shown in the package statistics card, until data is fetched and processed. Signed-off-by: Jyrki Keisala <[email protected]>
Show the total number of de-duplicated packages that were analyzed, and the de-duplicated types of the package identifiers. It should be mentioned that while both packages and projects have identifiers, project identifiers (which would probably be more valuable data to show here) are currently not available. This can be improved in a later PR, when that data is available. Signed-off-by: Jyrki Keisala <[email protected]>
While package data is being fetched and processed, show the card with a title and icon, and show loading indicator in place of the actual data which is not yet ready. Signed-off-by: Jyrki Keisala <[email protected]>
0cdc213
to
3343717
Compare
Please see the individual commits for details.