diff --git a/plugins/devtools-common/report-alpha.api.md b/plugins/devtools-common/report-alpha.api.md index e11b2d62ca..3c3b7ff89e 100644 --- a/plugins/devtools-common/report-alpha.api.md +++ b/plugins/devtools-common/report-alpha.api.md @@ -6,11 +6,6 @@ import { BasicPermission } from '@backstage/plugin-permission-common'; import { JsonObject } from '@backstage/types'; -// @alpha (undocumented) -export type CancelScheduledTask = { - error?: string; -}; - // @alpha (undocumented) export const devToolsTaskSchedulerCreatePermission: BasicPermission; diff --git a/plugins/devtools-common/src/alpha.ts b/plugins/devtools-common/src/alpha.ts index d7f9f94d76..7abe4b1f5e 100644 --- a/plugins/devtools-common/src/alpha.ts +++ b/plugins/devtools-common/src/alpha.ts @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + export { devToolsTaskSchedulerReadPermission, devToolsTaskSchedulerCreatePermission, } from './permissions'; export type { - CancelScheduledTask, ScheduledTasks, TaskApiTasksResponse, TriggerScheduledTask, diff --git a/plugins/devtools-common/src/types.ts b/plugins/devtools-common/src/types.ts index 3879fb1ae3..dc35188fde 100644 --- a/plugins/devtools-common/src/types.ts +++ b/plugins/devtools-common/src/types.ts @@ -133,8 +133,3 @@ export type ScheduledTasks = { export type TriggerScheduledTask = { error?: string; }; - -/** @alpha */ -export type CancelScheduledTask = { - error?: string; -}; diff --git a/plugins/devtools/src/api/DevToolsApi.ts b/plugins/devtools/src/api/DevToolsApi.ts index 6894a0a8b2..2aaad49aa8 100644 --- a/plugins/devtools/src/api/DevToolsApi.ts +++ b/plugins/devtools/src/api/DevToolsApi.ts @@ -21,7 +21,6 @@ import { ExternalDependency, } from '@backstage/plugin-devtools-common'; import { - CancelScheduledTask, ScheduledTasks, TriggerScheduledTask, } from '@backstage/plugin-devtools-common/alpha'; @@ -39,8 +38,5 @@ export interface DevToolsApi { plugin: string, taskId: string, ): Promise; - cancelScheduledTask( - plugin: string, - taskId: string, - ): Promise; + cancelScheduledTask(plugin: string, taskId: string): Promise; } diff --git a/plugins/devtools/src/api/DevToolsClient.ts b/plugins/devtools/src/api/DevToolsClient.ts index c5b50193ea..b6d9d4b119 100644 --- a/plugins/devtools/src/api/DevToolsClient.ts +++ b/plugins/devtools/src/api/DevToolsClient.ts @@ -21,11 +21,10 @@ import { ExternalDependency, } from '@backstage/plugin-devtools-common'; import { - CancelScheduledTask, ScheduledTasks, TriggerScheduledTask, } from '@backstage/plugin-devtools-common/alpha'; -import { ResponseError } from '@backstage/errors'; +import { ResponseError, NotFoundError, ConflictError } from '@backstage/errors'; import { DevToolsApi } from './DevToolsApi'; export class DevToolsClient implements DevToolsApi { @@ -83,13 +82,13 @@ export class DevToolsClient implements DevToolsApi { throw await ResponseError.fromResponse(response); } - return response.json() as Promise; + return {}; } public async cancelScheduledTask( plugin: string, taskId: string, - ): Promise { + ): Promise { const baseUrl = `${await this.discoveryApi.getBaseUrl(plugin)}/`; const url = new URL( `.backstage/scheduler/v1/tasks/${encodeURIComponent(taskId)}/cancel`, @@ -101,10 +100,13 @@ export class DevToolsClient implements DevToolsApi { }); if (!response.ok) { + if (response.status === 404) { + throw new NotFoundError(`Task ${taskId} not found`); + } else if (response.status === 409) { + throw new ConflictError(`Task ${taskId} is not running`); + } throw await ResponseError.fromResponse(response); } - - return response.json() as Promise; } public async getExternalDependencies(): Promise< diff --git a/plugins/devtools/src/components/Content/ScheduledTasksContent/ScheduledTasksContent.tsx b/plugins/devtools/src/components/Content/ScheduledTasksContent/ScheduledTasksContent.tsx index d115968a77..af86b9b237 100644 --- a/plugins/devtools/src/components/Content/ScheduledTasksContent/ScheduledTasksContent.tsx +++ b/plugins/devtools/src/components/Content/ScheduledTasksContent/ScheduledTasksContent.tsx @@ -288,7 +288,7 @@ export const ScheduledTasksContent = () => { )} /> - {loading && } + {loading && !scheduledTasks && } {error && ( { )} - {!loading && !error && ( + {scheduledTasks && ( { search: true, sorting: true, searchFieldAlignment: 'right', + padding: 'dense', }} columns={columns} data={scheduledTasks || []}