Skip to content

Commit e18329a

Browse files
committed
Use notifications API for tool requests
1 parent 66a09d8 commit e18329a

12 files changed

Lines changed: 425 additions & 514 deletions

File tree

client/src/api/notifications.ts

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { GalaxyApi } from "@/api";
12
import type { components } from "@/api/schema";
23

34
export type BaseUserNotification = components["schemas"]["UserNotificationResponse"];
@@ -30,16 +31,14 @@ export interface MessageNotificationCreateRequest extends NotificationCreateRequ
3031

3132
export interface ToolRequestNotificationContent {
3233
category: "tool_request";
33-
tool_name: string;
34+
tool_names: string[];
3435
tool_url?: string;
3536
description: string;
3637
scientific_domain?: string;
3738
requested_version?: string;
38-
conda_available?: boolean;
39-
test_data_available?: boolean;
40-
requester_name?: string;
41-
requester_email: string;
42-
requester_affiliation?: string;
39+
requester_email?: string | null;
40+
workflow_id?: string;
41+
additional_remarks?: string;
4342
}
4443

4544
export interface ToolRequestNotification extends BaseUserNotification {
@@ -57,3 +56,39 @@ export type NotificationVariants = components["schemas"]["NotificationVariant"];
5756

5857
export type NewSharedItemNotificationContentItemType =
5958
components["schemas"]["NewSharedItemNotificationContent"]["item_type"];
59+
60+
export interface ToolRequestSubmitContent {
61+
tool_names: string[];
62+
tool_url?: string;
63+
description: string;
64+
scientific_domain?: string;
65+
requested_version?: string;
66+
workflow_id?: string;
67+
additional_remarks?: string;
68+
}
69+
70+
/** Submit a tool-installation request as the authenticated user.
71+
* Returns the encoded notification ID so the caller can link to it.
72+
*/
73+
export async function submitUserNotification(content: ToolRequestSubmitContent): Promise<string> {
74+
const { data, error } = await GalaxyApi().POST("/api/notifications", {
75+
body: {
76+
recipients: { user_ids: [], group_ids: [], role_ids: [] },
77+
notification: {
78+
source: "tool_request_form",
79+
category: "tool_request",
80+
variant: "info",
81+
content: {
82+
category: "tool_request",
83+
...content,
84+
},
85+
},
86+
},
87+
});
88+
if (error) {
89+
const errorObject = error as { err_msg?: string; message?: string };
90+
const message = errorObject.err_msg || errorObject.message || "Failed to submit notification.";
91+
throw new Error(message);
92+
}
93+
return (data as { notification: { id: string } }).notification.id;
94+
}

client/src/api/schema/schema.ts

Lines changed: 14 additions & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -5198,29 +5198,6 @@ export interface paths {
51985198
patch?: never;
51995199
trace?: never;
52005200
};
5201-
"/api/tool_request_form": {
5202-
parameters: {
5203-
query?: never;
5204-
header?: never;
5205-
path?: never;
5206-
cookie?: never;
5207-
};
5208-
get?: never;
5209-
put?: never;
5210-
/**
5211-
* Submit a tool installation request to the instance admins.
5212-
* @description Submit a request for a new tool to be installed on this Galaxy instance.
5213-
*
5214-
* Sends a notification to all admin users with the submitted request details.
5215-
* Requires the notification system and tool request form to be enabled in the configuration.
5216-
*/
5217-
post: operations["submit_tool_request_api_tool_request_form_post"];
5218-
delete?: never;
5219-
options?: never;
5220-
head?: never;
5221-
patch?: never;
5222-
trace?: never;
5223-
};
52245201
"/api/tool_requests/{id}": {
52255202
parameters: {
52265203
query?: never;
@@ -23607,62 +23584,6 @@ export interface components {
2360723584
state: components["schemas"]["ToolRequestState"];
2360823585
state_message?: components["schemas"]["ToolRequestStateMessage"] | null;
2360923586
};
23610-
/**
23611-
* ToolRequestFormData
23612-
* @description The data submitted with the Tool Request Form.
23613-
*/
23614-
ToolRequestFormData: {
23615-
/**
23616-
* Conda available
23617-
* @description Whether a Conda package for this tool is available.
23618-
*/
23619-
conda_available?: boolean | null;
23620-
/**
23621-
* Description
23622-
* @description Short description of the tool and its scientific use case.
23623-
*/
23624-
description: string;
23625-
/**
23626-
* Requested version
23627-
* @description The version of the tool being requested.
23628-
*/
23629-
requested_version?: string | null;
23630-
/**
23631-
* Requester affiliation
23632-
* @description The affiliation/lab of the requester.
23633-
*/
23634-
requester_affiliation?: string | null;
23635-
/**
23636-
* Scientific domain
23637-
* @description The scientific domain for the requested tool.
23638-
*/
23639-
scientific_domain?: string | null;
23640-
/**
23641-
* Test data available
23642-
* @description Whether test data for this tool is available.
23643-
*/
23644-
test_data_available?: boolean | null;
23645-
/**
23646-
* Tool IDs
23647-
* @description Tool shed tool IDs for workflow install requests.
23648-
*/
23649-
tool_ids?: string[] | null;
23650-
/**
23651-
* Tool name
23652-
* @description The name of the requested tool.
23653-
*/
23654-
tool_name: string;
23655-
/**
23656-
* Tool URL
23657-
* @description Homepage or repository URL for the requested tool.
23658-
*/
23659-
tool_url?: string | null;
23660-
/**
23661-
* Workflow name
23662-
* @description Name of the workflow requiring these tools, if applicable.
23663-
*/
23664-
workflow_name?: string | null;
23665-
};
2366623587
/** ToolRequestImplicitCollectionReference */
2366723588
ToolRequestImplicitCollectionReference: {
2366823589
/**
@@ -23708,16 +23629,16 @@ export interface components {
2370823629
};
2370923630
/** ToolRequestNotificationContent */
2371023631
ToolRequestNotificationContent: {
23632+
/**
23633+
* Additional remarks
23634+
* @description Any additional information or context for the request.
23635+
*/
23636+
additional_remarks?: string | null;
2371123637
/**
2371223638
* @description discriminator enum property added by openapi-typescript
2371323639
* @enum {string}
2371423640
*/
2371523641
category: "tool_request";
23716-
/**
23717-
* Conda available
23718-
* @description Whether a Conda package for this tool is available.
23719-
*/
23720-
conda_available?: boolean | null;
2372123642
/**
2372223643
* Description
2372323644
* @description Short description of the tool and its scientific use case.
@@ -23728,51 +23649,31 @@ export interface components {
2372823649
* @description The version of the tool being requested.
2372923650
*/
2373023651
requested_version?: string | null;
23731-
/**
23732-
* Requester affiliation
23733-
* @description The affiliation/lab of the requester.
23734-
*/
23735-
requester_affiliation?: string | null;
2373623652
/**
2373723653
* Requester email
23738-
* @description The email address of the requester for follow-up.
23654+
* @description The email address of the requester for follow-up. This is derived server-side for user submissions.
2373923655
*/
23740-
requester_email: string;
23741-
/**
23742-
* Requester name
23743-
* @description The name of the person requesting the tool.
23744-
*/
23745-
requester_name?: string | null;
23656+
requester_email?: string | null;
2374623657
/**
2374723658
* Scientific domain
2374823659
* @description The scientific domain for the requested tool.
2374923660
*/
2375023661
scientific_domain?: string | null;
2375123662
/**
23752-
* Test data available
23753-
* @description Whether test data for this tool is available.
23663+
* Tool names
23664+
* @description Names or tool-shed IDs of the requested tools.
2375423665
*/
23755-
test_data_available?: boolean | null;
23756-
/**
23757-
* Tool IDs
23758-
* @description Tool shed tool IDs for workflow install requests.
23759-
*/
23760-
tool_ids?: string[] | null;
23761-
/**
23762-
* Tool name
23763-
* @description The name of the requested tool.
23764-
*/
23765-
tool_name: string;
23666+
tool_names: string[];
2376623667
/**
2376723668
* Tool URL
23768-
* @description Homepage or repository URL for the requested tool.
23669+
* @description Homepage or repository URL for the requested tool (single-tool requests only).
2376923670
*/
2377023671
tool_url?: string | null;
2377123672
/**
23772-
* Workflow name
23773-
* @description Name of the workflow requiring these tools, if applicable.
23673+
* Workflow ID
23674+
* @description Encoded ID of the workflow requiring these tools, if applicable.
2377423675
*/
23775-
workflow_name?: string | null;
23676+
workflow_id?: string | null;
2377623677
};
2377723678
/**
2377823679
* ToolRequestState
@@ -46658,49 +46559,6 @@ export interface operations {
4665846559
};
4665946560
};
4666046561
};
46661-
submit_tool_request_api_tool_request_form_post: {
46662-
parameters: {
46663-
query?: never;
46664-
header?: {
46665-
/** @description The user ID that will be used to effectively make this API call. Only admins and designated users can make API calls on behalf of other users. */
46666-
"run-as"?: string | null;
46667-
};
46668-
path?: never;
46669-
cookie?: never;
46670-
};
46671-
requestBody: {
46672-
content: {
46673-
"application/json": components["schemas"]["ToolRequestFormData"];
46674-
};
46675-
};
46676-
responses: {
46677-
/** @description Successful Response */
46678-
204: {
46679-
headers: {
46680-
[name: string]: unknown;
46681-
};
46682-
content?: never;
46683-
};
46684-
/** @description Request Error */
46685-
"4XX": {
46686-
headers: {
46687-
[name: string]: unknown;
46688-
};
46689-
content: {
46690-
"application/json": components["schemas"]["MessageExceptionModel"];
46691-
};
46692-
};
46693-
/** @description Server Error */
46694-
"5XX": {
46695-
headers: {
46696-
[name: string]: unknown;
46697-
};
46698-
content: {
46699-
"application/json": components["schemas"]["MessageExceptionModel"];
46700-
};
46701-
};
46702-
};
46703-
};
4670446562
get_tool_request_api_tool_requests__id__get: {
4670546563
parameters: {
4670646564
query?: never;

client/src/api/toolRequestForm.ts

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)