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

feat: offer package search suggestions #2410

Merged
merged 16 commits into from Dec 21, 2023
Merged

Conversation

davidmundelius
Copy link
Contributor

Summary of changes

  • Use react query to load search suggestions from deps.dev
  • Create faker module for mocking package search hooks

Context and reason for change

A step toward #2394

How can the changes be tested

Start the app and open the file opossum_input.opossum from the example-files folder.
In Audit View, choose the root folder. In the Network tab of the DevTools, check that there is an entry with name "suggest?q=Vue". Check that the respone for this entry contains the desired search results.

Base automatically changed from feat-create-package-autocompletes to main December 12, 2023 16:45
@davidmundelius davidmundelius force-pushed the feat-add-package-name-suggestions branch from 4e37008 to 9b1634c Compare December 13, 2023 07:34
src/Frontend/util/package-search-hooks.ts Outdated Show resolved Hide resolved
src/Frontend/util/package-search-hooks.ts Outdated Show resolved Hide resolved
@mstykow mstykow self-assigned this Dec 13, 2023
@davidmundelius davidmundelius force-pushed the feat-add-package-name-suggestions branch from 9b1634c to ea9969e Compare December 13, 2023 08:40
package.json Show resolved Hide resolved
@davidmundelius davidmundelius force-pushed the feat-add-package-name-suggestions branch from ea9969e to a394e03 Compare December 13, 2023 08:55
renovate.json5 Show resolved Hide resolved
@davidmundelius davidmundelius force-pushed the feat-add-package-name-suggestions branch 2 times, most recently from 6e0f3e7 to 0c7fbd1 Compare December 13, 2023 10:10
@davidmundelius davidmundelius force-pushed the feat-add-package-name-suggestions branch from 0c7fbd1 to e0ed7b5 Compare December 13, 2023 12:16
Copy link
Collaborator

@mstykow mstykow left a comment

Choose a reason for hiding this comment

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

Let's wait to merge this until the suggestions feature is complete and usable.

@mstykow mstykow force-pushed the feat-add-package-name-suggestions branch 4 times, most recently from b69ba7a to 6fda270 Compare December 14, 2023 11:49
@mstykow mstykow changed the title feat: load package search suggestions feat: offer package search suggestions Dec 14, 2023
davidmundelius added a commit that referenced this pull request Dec 14, 2023
- Remove the PackageSearchPopup which is not needed anymore after the changes of #2410 and #2415
- Rename the SearchPackagesIcon to SearchSignalsIcon as it is now only used for signals.

Signed-off-by: davidmundelius <david.mundelius@tngtech.com>
@mstykow mstykow force-pushed the feat-add-package-name-suggestions branch from 42824e6 to 05f7610 Compare December 15, 2023 10:45
mstykow pushed a commit that referenced this pull request Dec 15, 2023
- Remove the PackageSearchPopup which is not needed anymore after the changes of #2410 and #2415
- Rename the SearchPackagesIcon to SearchSignalsIcon as it is now only used for signals.

Signed-off-by: davidmundelius <david.mundelius@tngtech.com>
davidmundelius added a commit that referenced this pull request Dec 18, 2023
- Remove the PackageSearchPopup which is not needed anymore after the changes of #2410 and #2415

Signed-off-by: davidmundelius <david.mundelius@tngtech.com>
davidmundelius added a commit that referenced this pull request Dec 18, 2023
- Remove the PackageSearchPopup which is not needed anymore after the changes of #2410 and #2415

Signed-off-by: davidmundelius <david.mundelius@tngtech.com>
@mstykow mstykow force-pushed the feat-add-package-name-suggestions branch from 05f7610 to 9188587 Compare December 18, 2023 11:24
mstykow pushed a commit that referenced this pull request Dec 18, 2023
- Remove the PackageSearchPopup which is not needed anymore after the changes of #2410 and #2415

Signed-off-by: davidmundelius <david.mundelius@tngtech.com>
@mstykow mstykow changed the title feat: offer package search suggestions [STORY] feat: offer package search suggestions Dec 19, 2023
@mstykow mstykow force-pushed the feat-add-package-name-suggestions branch from eee63d5 to c62d951 Compare December 19, 2023 18:50
mstykow pushed a commit that referenced this pull request Dec 19, 2023
- Remove the PackageSearchPopup which is not needed anymore after the changes of #2410 and #2415

Signed-off-by: davidmundelius <david.mundelius@tngtech.com>
@mstykow mstykow force-pushed the feat-add-package-name-suggestions branch from 10e96c0 to c0f1bc1 Compare December 20, 2023 13:15
mstykow pushed a commit that referenced this pull request Dec 20, 2023
- Remove the PackageSearchPopup which is not needed anymore after the changes of #2410 and #2415

Signed-off-by: davidmundelius <david.mundelius@tngtech.com>
mstykow pushed a commit that referenced this pull request Dec 21, 2023
- Remove the PackageSearchPopup which is not needed anymore after the changes of #2410 and #2415

Signed-off-by: davidmundelius <david.mundelius@tngtech.com>
@mstykow mstykow force-pushed the feat-add-package-name-suggestions branch from 35556c3 to 494de72 Compare December 21, 2023 13:29
davidmundelius and others added 12 commits December 21, 2023 14:39
- Use react query to load search suggestions from deps.dev
- Create faker module for mocking package search hooks
- Add ESLint plugin for TanStack Query

Signed-off-by: davidmundelius <david.mundelius@tngtech.com>
- do not retry errored queries
- load package versions from deps.dev given a name and system and convert them to autocomplete suggestions
- sort versions by semantic versioning
- display defaults also in attribution view
- add possibility to add suffixes to package attribute labels

Signed-off-by: Maxim Stykow <maxim.stykow@tngtech.com>
Signed-off-by: davidmundelius <david.mundelius@tngtech.com>
- get URL and license from deps.dev when user adds an attribution via a version suggestion
- create "tryit" util to catch errors and convert them to undefined

Signed-off-by: Maxim Stykow <maxim.stykow@tngtech.com>
- Remove the PackageSearchPopup which is not needed anymore after the changes of #2410 and #2415

Signed-off-by: davidmundelius <david.mundelius@tngtech.com>
- extend list of common package types
- remove golang from list of types that are requiring namespaces because there is debate in the community about this
- do not include preferred attributions in autocomplete suggestions because they are meant for a specific resource-attribution combination
- add optional group action to autocomplete component

Signed-off-by: Maxim Stykow <maxim.stykow@tngtech.com>
- offer namespace suggestions, when relevant, based on package name and type
- do not highlight package version and URL in attribution view since they are not essential information when determining legal information (it's rare albeit not impossible that different versions have different licenses)

Signed-off-by: Maxim Stykow <maxim.stykow@tngtech.com>
- for packages stored on GitHub or GitLab, extract copyright in addition to license name when loading the license information
- use default package version for all further requests if no package version has been provided

Signed-off-by: Maxim Stykow <maxim.stykow@tngtech.com>
- offer GitHub and GitLab project tags as version suggestions
- GitLab narrows down suggestions by taking current version value as search param while GitHub API has no such feature and thus always returns the latest 100 tags
- take latest tag as default version for GitHub and GitLab packages
- always re-compute legal and URL to ensure that a new choice of version also updates legal information

Signed-off-by: Maxim Stykow <maxim.stykow@tngtech.com>
- remove unnecessary test blocks and setup from setupTests.ts and test suites
- add linter rules to ensure that it/test and jest.spyon is correctly used

Signed-off-by: Maxim Stykow <maxim.stykow@tngtech.com>
- create generic confirmation dialog with custom handlers for onConfirm and onCancel
- make user confirm changes to previously preferred attributions immediately rather than on save

Signed-off-by: Maxim Stykow <maxim.stykow@tngtech.com>
- no longer needed since the package autocompletes can fetch licenses more effectively (via the "+" button)

Signed-off-by: Maxim Stykow <maxim.stykow@tngtech.com>
@mstykow mstykow force-pushed the feat-add-package-name-suggestions branch from ce7a45c to bf7640c Compare December 21, 2023 14:39
- ensure that the autocomplete suggestion "+" button overwrites all previously entered data so that there cannot be confusion about what was and what wasn't replaced by the user's action
- make autocomplete suggestion "+" button more visually distinct from the primary suggestion action of just adding the single attribute so that it becomes clearer that there really are two separate actions on the suggestion card
- ensure click on entire autocomplete input field opens option popper and not just a click on the underlying HTML input element
- catch unhandled errors produced by the PackageURL constructor and instead display "INVALID URL"
- do not set a default version when user adopts a suggestion via autocomplete "+" button because the default (latest) version will almost always be the wrong one

Signed-off-by: Maxim Stykow <maxim.stykow@tngtech.com>
- add description, homepage, origins from Open Source Insights (deps.dev) to attribution comment when the user selects a suggestion from one of the package comboboxes via the "+" button

Signed-off-by: Maxim Stykow <maxim.stykow@tngtech.com>
…into-comment

feat: add package description and homepage into comment field
Signed-off-by: Maxim Stykow <maxim.stykow@tngtech.com>
@mstykow mstykow force-pushed the feat-add-package-name-suggestions branch from e72da72 to 8d92f1a Compare December 21, 2023 15:09
@mstykow mstykow changed the title [STORY] feat: offer package search suggestions feat: offer package search suggestions Dec 21, 2023
@mstykow mstykow merged commit ecf144f into main Dec 21, 2023
5 checks passed
@mstykow mstykow deleted the feat-add-package-name-suggestions branch December 21, 2023 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants