1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-09 07:45:22 +02:00

feat(namespace): migrate create ns to react [EE-2226] (#10377)

This commit is contained in:
Ali 2023-10-11 20:32:02 +01:00 committed by GitHub
parent 31bcba96c6
commit 7218eb0892
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
83 changed files with 1869 additions and 358 deletions

View file

@ -22,12 +22,12 @@ interface RegistryAccess {
}
export async function updateEnvironmentRegistryAccess(
id: EnvironmentId,
environmentId: EnvironmentId,
registryId: RegistryId,
access: RegistryAccess
access: Partial<RegistryAccess>
) {
try {
await axios.put<void>(buildRegistryUrl(id, registryId), access);
await axios.put<void>(buildRegistryUrl(environmentId, registryId), access);
} catch (e) {
throw parseAxiosError(e as Error);
}

View file

@ -3,13 +3,16 @@ import axios, { parseAxiosError } from '@/portainer/services/axios';
import { buildUrl } from '../environment.service/utils';
import { EnvironmentId } from '../types';
import { Registry } from '../../registries/types/registry';
import { useGenericRegistriesQuery } from '../../registries/queries/useRegistries';
import {
GenericRegistriesQueryOptions,
useGenericRegistriesQuery,
} from '../../registries/queries/useRegistries';
import { environmentQueryKeys } from './query-keys';
export function useEnvironmentRegistries<T = Array<Registry>>(
environmentId: EnvironmentId,
queryOptions: { select?(data: Array<Registry>): T; enabled?: boolean } = {}
queryOptions: GenericRegistriesQueryOptions<T> = {}
) {
return useGenericRegistriesQuery(
environmentQueryKeys.registries(environmentId),

View file

@ -50,7 +50,7 @@ export type IngressClass = {
Type: string;
};
interface StorageClass {
export interface StorageClass {
Name: string;
AccessModes: string[];
AllowVolumeExpansion: boolean;

View file

@ -22,6 +22,16 @@ export function useRegistries<T = Registry[]>(
);
}
/**
* @field hideDefault - is used to hide the default registry from the list of registries, regardless of the user's settings. Kubernetes views use this.
*/
export type GenericRegistriesQueryOptions<T> = {
enabled?: boolean;
select?: (registries: Registry[]) => T;
onSuccess?: (data: T) => void;
hideDefault?: boolean;
};
export function useGenericRegistriesQuery<T = Registry[]>(
queryKey: QueryKey,
fetcher: () => Promise<Array<Registry>>,
@ -29,18 +39,16 @@ export function useGenericRegistriesQuery<T = Registry[]>(
enabled,
select,
onSuccess,
}: {
enabled?: boolean;
select?: (registries: Registry[]) => T;
onSuccess?: (data: T) => void;
} = {}
hideDefault: hideDefaultOverride,
}: GenericRegistriesQueryOptions<T> = {}
) {
const hideDefaultRegistryQuery = usePublicSettings({
select: (settings) => settings.DefaultRegistry?.Hide,
enabled,
// We don't need the hideDefaultRegistry info if we're overriding it to true
enabled: enabled && !hideDefaultOverride,
});
const hideDefault = !!hideDefaultRegistryQuery.data;
const hideDefault = hideDefaultOverride || !!hideDefaultRegistryQuery.data;
return useQuery(
queryKey,
@ -66,7 +74,8 @@ export function useGenericRegistriesQuery<T = Registry[]>(
{
select,
...withError('Unable to retrieve registries'),
enabled: hideDefaultRegistryQuery.isSuccess && enabled,
enabled:
(hideDefaultOverride || hideDefaultRegistryQuery.isSuccess) && enabled,
onSuccess,
}
);