Repository navigation
Conversation
Add an optional, non-breaking way for plugins to report the total number of matching scopes in the search-remote-scopes response: - helpers: new DsSearchRemoteScopesWithCount function type and NewDsRemoteApiScopeSearchHelperWithCount constructor. The existing NewDsRemoteApiScopeSearchHelper wraps legacy search functions with an unknown total (-1), so no other plugin needs to change. - The response body contains "count" only if the plugin reports it. - DsRemoteApiScopeList documents the optional count field. - sonarqube: pass paging.total of api/components/search_projects through. Signed-off-by: DoDiODev <DoDiDev@proton.me>
When searching remote scopes, an "ALL" entry is rendered as the first row of the result list (same placement as showSelectAll of miller-columns-select). It (de)selects every match of the current search: - loads all remaining pages on demand, stopping at the backend-reported count or, for plugins without count, at the first short page - keeps the selection outside of the filter and skips already added (disabled) scopes - shows the number of matches, a tri-state checkbox and a warning if the page limit was reached - discards results that arrive after the search query changed The feature is opt-in via dataScope.searchSelectAll and only enabled for SonarQube. Duplicates are removed when appending further search pages. Signed-off-by: DoDiODev <DoDiDev@proton.me>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When adding data scopes to a SonarQube connection (Connection → Add Data
Scope), the search box only lets you pick the matching projects one by one.
With a few hundred projects sharing a prefix this is tedious.
This PR adds an "ALL" checkbox as the first entry of the search result
list. It selects or deselects all projects matching the search term, not
only the page that is currently loaded. The feature is opt-in per plugin and
is only switched on for SonarQube.
Backend (
feat(sonarqube): return total count from search-remote-scopes)DsRemoteApiScopeSearchHelpercan now return the total number of matchesas
countin thesearch-remote-scopesresponse.DsSearchRemoteScopesWithCountand constructorNewDsRemoteApiScopeSearchHelperWithCount.NewDsRemoteApiScopeSearchHelperwraps its function andreports the total as unknown (
-1). In that casecountis omitted fromthe response. No other plugin changes; the response of all other
plugins is unchanged.
DsRemoteApiScopeListdocuments the optionalcountfield (Swagger).querySonarqubeProjectsalso returnspaging.totalfromapi/components/search_projects, and the search endpoint uses the newconstructor.
config-ui (
feat(config-ui): add "ALL" toggle to the SonarQube remote scope search)dataScope.searchSelectAll, set totruefor SonarQube only.
renderTitleofMillerColumnsSelect, so itsits inside the list, before the first item, and looks like a list item.
The built-in
showSelectAllofmiller-columns-selectis not used: it onlycovers the already loaded items and replaces the whole selection.
ALL (237)(fromcount, or thelist length once the whole result is loaded).
(disabled entries) are ignored.
(spinner shown). With
countthe loop stops exactly at the last page;without it, it stops at the first short page. Limit: 100 pages × 100.
If the limit is hit, a warning asks to refine the search.
removes the filtered entries.
search-remote.tsx: results are de-duplicated when the nextpage is appended, and the memoised
disabledIdsis reused.API.scope.searchRemote:countis now typed as optional.Question for reviewers
The new behaviour is opt-in and currently enabled for SonarQube only. Should
it become the default for all plugins with a remote search? That covers:
ALL (n)), andof acting only on the loaded items.
The helper extension is already generic. Each plugin would only need to
return the total from its search function (many remote APIs report it, for
example GitHub search
total_countor Jiratotal; this would need to bechecked per plugin). Without a
total, the UI falls back to "load until a short page" and shows the count
only after everything is loaded. Plugins that use
NewDsRemoteApiScopeSearchHelpertoday: azuredevops_go, bamboo, bitbucket, bitbucket_server, circleci,
gh-copilot, github, gitlab, grafana_irm, incidentio, jira, pagerduty, rootly,
slack, sonarqube, tapd, teambition, tempo, testmo, trello.
If you agree, I would prefer a follow-up PR: drop the
searchSelectAllflag(or flip its default) and add
countplugin by plugin. That keeps this PRsmall. I'm also happy to change it here if you prefer.
Does this close any open issues?
N/A
Screenshots
Other Information
countis only added to the response when a pluginreports it; existing clients ignore unknown fields.
countpresent / omitted, legacywrapper) and for
querySonarqubeProjects(mockedApiClient; checkspaging.total,filter,p,ps).tests for the "ALL" row (15/15).
tscandeslintpass.config-ui, license header, Grafana check; 14/14 jobs green):
https://github.com/DoDiODev/devlake/actions/runs/40840628487