mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-14 17:26:22 +01:00
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:
@@ -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");
|
||||
|
||||
@@ -33,7 +33,6 @@ export type BaseContext = {
|
||||
|
||||
export type LegacyContext = BaseContext & {
|
||||
initialize: () => void;
|
||||
queryClient?: QueryClient;
|
||||
};
|
||||
|
||||
const Context = createContext<LegacyContext | undefined>(undefined);
|
||||
|
||||
@@ -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(() => {
|
||||
|
||||
@@ -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
|
||||
};
|
||||
};
|
||||
|
||||
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user