Signed-off-by: Fredrik Adelöw <freben@spotify.com>
This commit is contained in:
Fredrik Adelöw
2026-03-11 20:29:45 +01:00
parent 9110c16c8a
commit 239c8dcfd2
6 changed files with 13 additions and 24 deletions
@@ -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;
+1 -1
View File
@@ -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,
-5
View File
@@ -133,8 +133,3 @@ export type ScheduledTasks = {
export type TriggerScheduledTask = {
error?: string;
};
/** @alpha */
export type CancelScheduledTask = {
error?: string;
};
+1 -5
View File
@@ -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<TriggerScheduledTask>;
cancelScheduledTask(
plugin: string,
taskId: string,
): Promise<CancelScheduledTask>;
cancelScheduledTask(plugin: string, taskId: string): Promise<void>;
}
+8 -6
View File
@@ -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<TriggerScheduledTask>;
return {};
}
public async cancelScheduledTask(
plugin: string,
taskId: string,
): Promise<CancelScheduledTask> {
): Promise<void> {
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<CancelScheduledTask>;
}
public async getExternalDependencies(): Promise<
@@ -288,7 +288,7 @@ export const ScheduledTasksContent = () => {
)}
/>
{loading && <Progress />}
{loading && !scheduledTasks && <Progress />}
{error && (
<ErrorPanel
@@ -317,7 +317,7 @@ export const ScheduledTasksContent = () => {
</ErrorPanel>
)}
{!loading && !error && (
{scheduledTasks && (
<Table
title={`Scheduled Tasks (${selectedPlugin})`}
options={{
@@ -325,6 +325,7 @@ export const ScheduledTasksContent = () => {
search: true,
sorting: true,
searchFieldAlignment: 'right',
padding: 'dense',
}}
columns={columns}
data={scheduledTasks || []}