diff --git a/client/src/components/Collections/common/UserReportingError.vue b/client/src/components/Collections/common/UserReportingError.vue new file mode 100644 index 000000000000..ee41fe26e958 --- /dev/null +++ b/client/src/components/Collections/common/UserReportingError.vue @@ -0,0 +1,87 @@ + + + diff --git a/client/src/components/Collections/common/reporting.ts b/client/src/components/Collections/common/reporting.ts new file mode 100644 index 000000000000..9ea253248827 --- /dev/null +++ b/client/src/components/Collections/common/reporting.ts @@ -0,0 +1,34 @@ +import { GalaxyApi } from "@/api"; +import { type HDADetailed } from "@/api"; +import { errorMessageAsString } from "@/utils/simple-error"; + +export interface ReportableObject { + id: string; + creating_job: string; +} + +export async function submitReport( + reportableData: HDADetailed, + message: string, + email: string +): Promise<{ messages: string[][]; error?: string }> { + try { + const { data, error } = await GalaxyApi().POST("/api/jobs/{job_id}/error", { + params: { + path: { job_id: reportableData.creating_job }, + }, + body: { + dataset_id: reportableData.id, + message, + email, + }, + }); + + if (error) { + return { messages: [], error: errorMessageAsString(error) }; + } + return { messages: data.messages }; + } catch (err) { + return { messages: [], error: errorMessageAsString(err) }; + } +} diff --git a/client/src/components/DatasetInformation/DatasetError.test.ts b/client/src/components/DatasetInformation/DatasetError.test.ts index 1c514acb3d14..f964c71191eb 100644 --- a/client/src/components/DatasetInformation/DatasetError.test.ts +++ b/client/src/components/DatasetInformation/DatasetError.test.ts @@ -102,7 +102,7 @@ describe("DatasetError", () => { }); it("hides form fields and button on success", async () => { - const wrapper = await montDatasetError(); + const wrapper = await montDatasetError(false, false, "test_email"); server.use( http.post("/api/jobs/{job_id}/error", ({ response }) => { @@ -112,10 +112,10 @@ describe("DatasetError", () => { }) ); - const FormAndSubmitButton = "#dataset-error-form"; + const FormAndSubmitButton = "#data-error-form"; expect(wrapper.find(FormAndSubmitButton).exists()).toBe(true); - const submitButton = "#dataset-error-submit"; + const submitButton = "#data-error-submit"; expect(wrapper.find(submitButton).exists()).toBe(true); await wrapper.find(submitButton).trigger("click"); diff --git a/client/src/components/DatasetInformation/DatasetError.vue b/client/src/components/DatasetInformation/DatasetError.vue index 22a807219ae2..465fcdf51abe 100644 --- a/client/src/components/DatasetInformation/DatasetError.vue +++ b/client/src/components/DatasetInformation/DatasetError.vue @@ -1,8 +1,7 @@