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

Indicate of a package version list in devbox search is truncated #2044

Merged
merged 1 commit into from
May 13, 2024

Conversation

Lagoja
Copy link
Contributor

@Lagoja Lagoja commented May 10, 2024

Summary

Current devbox search UI only shows the 10 newest versions for a package, unless the developer runs the command with --show-all. With the current presentation, this may confuse developers by making it seem like only 10 versions are available at all.

This pr Adds a ... at the end to indicate that more versions are available. For example:

Found 8+ results for "python":

* python  (3.13.0a6, 3.13.0a5, 3.13.0a3, 3.13.0a2, 3.13.0a1, 3.12.3, 3.12.2, 3.12.1, 3.12.0, 3.12.0rc3 ...)
* python-cosmopolitan  (3.6.14)
* python-launcher  (1.0.0)
* python-qt  (3.5.2, 3.5.1, 3.4.2, 3.3.0, 3.2)
* python-swiftclient  (4.2.0, 4.1.0, 4.0.0, 3.13.1, 3.13.0, 3.12.0)
* python-language-server  (2022-02-18, 2021-09-08, 2021-05-20, 2020-10-08, 2020-06-19, 2020-04-24)
* python-matter-server  (5.10.0, 5.9.0, 5.8.1, 5.8.0, 5.7.0b2, 5.5.3, 5.1.1, 5.0.3, 4.0.2, 4.0.1 ...)
* python-full  (3.13.0a6, 3.13.0a5, 3.13.0a3, 3.13.0a2, 3.13.0a1, 3.12.3, 3.12.2, 3.12.1, 3.12.0, 3.11.9 ...)

Warning: Showing top 10 results and truncated versions. Use --show-all to show all.

How was it tested?

Debugged locally, tested with go and python
Also verified that the ellipses don't appear when the --show-all flag is set

@@ -16,6 +16,8 @@ import (
"go.jetpack.io/devbox/internal/ux"
)

const TrimmedVersionsLength = 10
Copy link
Contributor

Choose a reason for hiding this comment

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

nit, camelCase.

Comment on lines 105 to 110
versionString = fmt.Sprintf(" (%s", strings.Join(nonEmptyVersions, ", "))
}
if resultsAreTrimmed && pkg.NumVersions > TrimmedVersionsLength {
versionString += " ...)"
} else {
versionString += ")"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion to avoid closing paren manually:

ellipses := lo.Ternary(resultsAreTrimmed && pkg.NumVersions > TrimmedVersionsLength, " ...", "")
versionString = fmt.Sprintf(" (%s%s)", strings.Join(nonEmptyVersions, ", "), ellipses)

@Lagoja Lagoja force-pushed the jl/search-show-truncation branch from 091db17 to b687514 Compare May 10, 2024 19:18
@Lagoja Lagoja merged commit a592fe5 into main May 13, 2024
24 checks passed
@Lagoja Lagoja deleted the jl/search-show-truncation branch May 13, 2024 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants