mirror of
https://github.com/portainer/portainer.git
synced 2025-07-23 07:19:41 +02:00
feat(helm): filter on chart versions at API level [R8S-324] (#754)
This commit is contained in:
parent
07dfd981a2
commit
731afbee46
6 changed files with 159 additions and 56 deletions
|
@ -45,20 +45,21 @@ export function useHelmRepositories() {
|
|||
export function useHelmRepoVersions(
|
||||
chart: string,
|
||||
staleTime: number,
|
||||
repositories: string[] = []
|
||||
repositories: string[] = [],
|
||||
useCache: boolean = true
|
||||
) {
|
||||
// Fetch versions from each repository in parallel as separate queries
|
||||
const versionQueries = useQueries({
|
||||
queries: useMemo(
|
||||
() =>
|
||||
repositories.map((repo) => ({
|
||||
queryKey: ['helm', 'repositories', chart, repo],
|
||||
queryFn: () => getSearchHelmRepo(repo, chart),
|
||||
queryKey: ['helm', 'repositories', chart, repo, useCache],
|
||||
queryFn: () => getSearchHelmRepo(repo, chart, useCache),
|
||||
enabled: !!chart && repositories.length > 0,
|
||||
staleTime,
|
||||
...withGlobalError(`Unable to retrieve versions from ${repo}`),
|
||||
})),
|
||||
[repositories, chart, staleTime]
|
||||
[repositories, chart, staleTime, useCache]
|
||||
),
|
||||
});
|
||||
|
||||
|
@ -72,6 +73,8 @@ export function useHelmRepoVersions(
|
|||
data: allVersions,
|
||||
isInitialLoading: versionQueries.some((q) => q.isLoading),
|
||||
isError: versionQueries.some((q) => q.isError),
|
||||
isFetching: versionQueries.some((q) => q.isFetching),
|
||||
refetch: () => Promise.all(versionQueries.map((q) => q.refetch())),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -80,11 +83,12 @@ export function useHelmRepoVersions(
|
|||
*/
|
||||
async function getSearchHelmRepo(
|
||||
repo: string,
|
||||
chart: string
|
||||
chart: string,
|
||||
useCache: boolean = true
|
||||
): Promise<ChartVersion[]> {
|
||||
try {
|
||||
const { data } = await axios.get<HelmSearch>(`templates/helm`, {
|
||||
params: { repo, chart },
|
||||
params: { repo, chart, useCache },
|
||||
});
|
||||
const versions = data.entries[chart];
|
||||
return (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue