Add feedback form (#1967)

Add feedback button and form. This feedback form can be used to provide direct feedback to the SCM-Manager Team.

Co-authored-by: Matthias Thieroff <matthias.thieroff@cloudogu.com>
This commit is contained in:
Eduard Heimbuch
2022-03-10 09:39:17 +01:00
committed by GitHub
parent 390384b723
commit 4407dc6d8a
22 changed files with 235 additions and 21 deletions

View File

@@ -52,7 +52,7 @@ describe("ApiProvider tests", () => {
});
if (result.current?.onIndexFetched) {
result.current.onIndexFetched({ version: "a.b.c", _links: {} });
result.current.onIndexFetched({ version: "a.b.c", _links: {}, instanceId: "123" });
}
expect(msg!).toEqual("hello");

View File

@@ -33,7 +33,6 @@ export type BaseContext = {
export type LegacyContext = BaseContext & {
initialize: () => void;
queryClient?: QueryClient;
};
const Context = createContext<LegacyContext | undefined>(undefined);

View File

@@ -58,13 +58,14 @@ describe("Test config hooks", () => {
proxyUser: null,
realmDescription: "",
alertsUrl: "",
feedbackUrl: "",
releaseFeedUrl: "",
skipFailedAuthenticators: false,
_links: {
update: {
href: "/config",
},
},
href: "/config"
}
}
};
afterEach(() => {
@@ -77,7 +78,7 @@ describe("Test config hooks", () => {
setIndexLink(queryClient, "config", "/config");
fetchMock.get("/api/v2/config", config);
const { result, waitFor } = renderHook(() => useConfig(), {
wrapper: createWrapper(undefined, queryClient),
wrapper: createWrapper(undefined, queryClient)
});
await waitFor(() => !!result.current.data);
expect(result.current.data).toEqual(config);
@@ -91,15 +92,15 @@ describe("Test config hooks", () => {
const newConfig = {
...config,
baseUrl: "/hog",
baseUrl: "/hog"
};
fetchMock.putOnce("/api/v2/config", {
status: 200,
status: 200
});
const { result, waitForNextUpdate } = renderHook(() => useUpdateConfig(), {
wrapper: createWrapper(undefined, queryClient),
wrapper: createWrapper(undefined, queryClient)
});
await act(() => {

View File

@@ -30,20 +30,23 @@ import { requiredLink } from "./links";
export const useConfig = (): ApiResult<Config> => {
const indexLink = useIndexLink("config");
return useQuery<Config, Error>("config", () => apiClient.get(indexLink!).then((response) => response.json()), {
enabled: !!indexLink,
return useQuery<Config, Error>("config", () => apiClient.get(indexLink!).then(response => response.json()), {
enabled: !!indexLink
});
};
export const useUpdateConfig = () => {
const queryClient = useQueryClient();
const { mutate, isLoading, error, data, reset } = useMutation<unknown, Error, Config>(
(config) => {
config => {
const updateUrl = requiredLink(config, "update");
return apiClient.put(updateUrl, config, "application/vnd.scmm-config+json;v=2");
},
{
onSuccess: () => queryClient.invalidateQueries("config"),
onSuccess: async () => {
await queryClient.invalidateQueries("config");
await queryClient.invalidateQueries("index");
}
}
);
return {
@@ -51,6 +54,6 @@ export const useUpdateConfig = () => {
isLoading,
error,
isUpdated: !!data,
reset,
reset
};
};

View File

@@ -63,6 +63,7 @@ export * from "./search";
export * from "./loginInfo";
export * from "./usePluginCenterAuthInfo";
export * from "./compare";
export * from "./utils";
export { default as ApiProvider } from "./ApiProvider";
export * from "./ApiProvider";