);
}
-
-type FileDetails = {
- path: string;
- size: string;
- hash: string;
-};
-
interface RepoProps {
repo: RepositoryResource;
}
+function ErrorView({ repo }: RepoProps) {
+ const name = repo.metadata.name;
+ const status = useTestRepositoryQuery({ name });
+ if (status.isLoading) {
+ return (
+
+ Testing configuration...
+
+ );
+ }
+ if (status.isError) {
+ let response = (status.error as any)?.data as TestResponse;
+ if (!response || !response.errors) {
+ return ;
+ }
+
+ return (
+
+ {error}
} />
+
+ );
+ }
+ return null; // don't show anything when it is OK?
+}
+
type Cell = CellProps;
function FilesView({ repo }: RepoProps) {
diff --git a/public/app/features/provisioning/api/endpoints.ts b/public/app/features/provisioning/api/endpoints.ts
index b98d9c5283e..44bd453b26a 100644
--- a/public/app/features/provisioning/api/endpoints.ts
+++ b/public/app/features/provisioning/api/endpoints.ts
@@ -1,3 +1,5 @@
+import { Resource } from 'app/features/apiserver/types';
+
import { baseAPI as api } from './baseAPI';
import {
RepositoryList,
@@ -10,6 +12,8 @@ import {
GetFileArg,
ListFilesApiResponse,
HistoryListResponse,
+ TestResponse,
+ RepositorySpec,
JobList,
} from './types';
@@ -135,6 +139,18 @@ const injectedRtkApi = api.injectEndpoints({
body,
}),
}),
+ testRepository: build.query({
+ query: ({ name }) => ({
+ url: `${BASE_PATH}/${name}/test`,
+ method: 'POST', // tests the existing configuration
+ }),
+ }),
+ testRepositoryConfig: build.mutation>({
+ query: ({ metadata }) => ({
+ url: `${BASE_PATH}/${metadata.name ?? 'new'}/test`,
+ method: 'POST',
+ }),
+ }),
}),
overrideExisting: false,
});
@@ -160,4 +176,6 @@ export const {
useGetRepositoryStatusQuery,
useUpdateRepositoryStatusMutation,
usePatchRepositoryStatusMutation,
+ useTestRepositoryQuery,
+ useTestRepositoryConfigMutation,
} = injectedRtkApi;
diff --git a/public/app/features/provisioning/api/types.ts b/public/app/features/provisioning/api/types.ts
index 3a0ece7a093..eacf3203f22 100644
--- a/public/app/features/provisioning/api/types.ts
+++ b/public/app/features/provisioning/api/types.ts
@@ -44,9 +44,13 @@ export type EditingOptions = {
update: boolean;
};
-export type WatchEvent = {
- object: unknown;
- type: string;
+export type TestResponse = {
+ apiVersion?: string;
+ kind?: string;
+ code: number;
+ success: boolean;
+ errors?: string[];
+ details?: object;
};
export interface RequestArg {
@@ -126,9 +130,15 @@ export type GetFileArg = {
ref?: string;
};
+export type FileDetails = {
+ path: string;
+ size: string;
+ hash: string;
+};
+
export type ListFilesApiResponse = {
apiVersion?: string;
- files?: any[];
+ files?: FileDetails[];
kind?: string;
metadata?: any;
};