refactor(ui): migrate from canceling queue items to deleteing, make queue hook APIs consistent

This commit is contained in:
psychedelicious
2025-06-06 18:29:43 +10:00
parent cc5083599d
commit 2ddcde13ff
50 changed files with 773 additions and 516 deletions

View File

@@ -224,7 +224,7 @@ export const queueApi = api.injectEndpoints({
];
},
}),
cancelByDestination: build.mutation<
cancelQueueItemsByDestination: build.mutation<
paths['/api/v1/queue/{queue_id}/cancel_by_destination']['put']['responses']['200']['content']['application/json'],
paths['/api/v1/queue/{queue_id}/cancel_by_destination']['put']['parameters']['query']
>({
@@ -256,6 +256,16 @@ export const queueApi = api.injectEndpoints({
}),
invalidatesTags: ['SessionQueueStatus', 'BatchStatus', 'QueueCountsByDestination', 'SessionQueueItem'],
}),
deleteAllExceptCurrent: build.mutation<
paths['/api/v1/queue/{queue_id}/delete_all_except_current']['put']['responses']['200']['content']['application/json'],
void
>({
query: () => ({
url: buildQueueUrl('delete_all_except_current'),
method: 'PUT',
}),
invalidatesTags: ['SessionQueueStatus', 'BatchStatus', 'QueueCountsByDestination', 'SessionQueueItem'],
}),
retryItemsById: build.mutation<
paths['/api/v1/queue/{queue_id}/retry_items_by_id']['put']['responses']['200']['content']['application/json'],
paths['/api/v1/queue/{queue_id}/retry_items_by_id']['put']['requestBody']['content']['application/json']
@@ -329,7 +339,11 @@ export const queueApi = api.injectEndpoints({
url: buildQueueUrl(`i/${item_id}`),
method: 'DELETE',
}),
invalidatesTags: (result, error, { item_id }) => [{ type: 'SessionQueueItem', id: item_id }],
invalidatesTags: (result, error, { item_id }) => [
{ type: 'SessionQueueItem', id: item_id },
{ type: 'SessionQueueItem', id: LIST_TAG },
{ type: 'SessionQueueItem', id: LIST_ALL_TAG },
],
}),
deleteQueueItemsByDestination: build.mutation<void, { destination: string }>({
query: ({ destination }) => ({
@@ -366,8 +380,10 @@ export const {
useGetQueueStatusQuery,
useListQueueItemsQuery,
useCancelQueueItemMutation,
useCancelQueueItemsByDestinationMutation,
useDeleteQueueItemMutation,
useDeleteQueueItemsByDestinationMutation,
useDeleteAllExceptCurrentMutation,
useGetBatchStatusQuery,
useGetCurrentQueueItemQuery,
useGetQueueCountsByDestinationQuery,

View File

@@ -1244,6 +1244,26 @@ export type paths = {
patch?: never;
trace?: never;
};
"/api/v1/queue/{queue_id}/delete_all_except_current": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
get?: never;
/**
* Delete All Except Current
* @description Immediately deletes all queue items except in-processing items
*/
put: operations["delete_all_except_current"];
post?: never;
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
"/api/v1/queue/{queue_id}/cancel_by_batch_ids": {
parameters: {
query?: never;
@@ -5885,6 +5905,17 @@ export type components = {
*/
type: "dw_openpose_detection";
};
/**
* DeleteAllExceptCurrentResult
* @description Result of deleting all except current
*/
DeleteAllExceptCurrentResult: {
/**
* Deleted
* @description Number of queue items deleted
*/
deleted: number;
};
/** DeleteBoardResult */
DeleteBoardResult: {
/**
@@ -24570,6 +24601,38 @@ export interface operations {
};
};
};
delete_all_except_current: {
parameters: {
query?: never;
header?: never;
path: {
/** @description The queue id to perform this operation on */
queue_id: string;
};
cookie?: never;
};
requestBody?: never;
responses: {
/** @description Successful Response */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["DeleteAllExceptCurrentResult"];
};
};
/** @description Validation Error */
422: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["HTTPValidationError"];
};
};
};
};
cancel_by_batch_ids: {
parameters: {
query?: never;