From d5c8c368b90c15709bf53dac961ab62f5c360b18 Mon Sep 17 00:00:00 2001 From: hujambo-dunia Date: Mon, 13 Jan 2025 09:49:37 -0500 Subject: [PATCH] Refactored Dataset Error Page email web form Make component reusable, changes made: * Componentized email web form into Vue.js * Decoupled the View (html email) from the Controller (API methods) * Abstracted the View elements for reuse with other objects (eg.Tools) * Utilized existing dependency (Python Jinja2) for repo consistency Reported by @hexylena in issue https://github.com/galaxyproject/galaxy/issues/17560 . --- .../Collections/common/UserReportingError.vue | 88 ++++++++++++ .../Collections/common/reporting.ts | 34 +++++ .../DatasetInformation/DatasetError.vue | 72 +--------- .../templates/mail/error-report-dataset.html | 87 ++++++++++++ .../templates/mail/error-report-dataset.txt | 44 ++++++ lib/galaxy/tools/errors.py | 128 +----------------- 6 files changed, 263 insertions(+), 190 deletions(-) create mode 100644 client/src/components/Collections/common/UserReportingError.vue create mode 100644 client/src/components/Collections/common/reporting.ts create mode 100644 lib/galaxy/config/templates/mail/error-report-dataset.html create mode 100644 lib/galaxy/config/templates/mail/error-report-dataset.txt diff --git a/client/src/components/Collections/common/UserReportingError.vue b/client/src/components/Collections/common/UserReportingError.vue new file mode 100644 index 000000000000..811d24e2c0aa --- /dev/null +++ b/client/src/components/Collections/common/UserReportingError.vue @@ -0,0 +1,88 @@ + + + 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.vue b/client/src/components/DatasetInformation/DatasetError.vue index cbe9f3e40189..9c09951773ff 100644 --- a/client/src/components/DatasetInformation/DatasetError.vue +++ b/client/src/components/DatasetInformation/DatasetError.vue @@ -1,21 +1,18 @@