mirror of
https://github.com/moghtech/komodo.git
synced 2026-03-11 17:44:19 -05:00
disable server builder cancel in UI
This commit is contained in:
@@ -53,6 +53,7 @@ impl super::MonitorResource for Build {
|
||||
info: BuildListItemInfo {
|
||||
last_built_at: build.info.last_built_at,
|
||||
version: build.config.version,
|
||||
builder_id: build.config.builder_id,
|
||||
git_provider: build.config.git_provider,
|
||||
repo: build.config.repo,
|
||||
branch: build.config.branch,
|
||||
|
||||
@@ -59,6 +59,7 @@ impl super::MonitorResource for Repo {
|
||||
resource_type: ResourceTargetVariant::Repo,
|
||||
info: RepoListItemInfo {
|
||||
server_id: repo.config.server_id,
|
||||
builder_id: repo.config.builder_id,
|
||||
last_pulled_at: repo.info.last_pulled_at,
|
||||
last_built_at: repo.info.last_built_at,
|
||||
git_provider: repo.config.git_provider,
|
||||
|
||||
@@ -26,6 +26,8 @@ pub struct BuildListItemInfo {
|
||||
pub last_built_at: I64,
|
||||
/// The current version of the build
|
||||
pub version: Version,
|
||||
/// The builder attached to build.
|
||||
pub builder_id: String,
|
||||
/// The git provider domain
|
||||
pub git_provider: String,
|
||||
/// The repo used as the source of the build
|
||||
|
||||
@@ -23,7 +23,10 @@ pub type _PartialBuilderConfig = PartialBuilderConfig;
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
pub struct BuilderListItemInfo {
|
||||
/// 'Server' or 'Aws'
|
||||
pub builder_type: String,
|
||||
/// If 'Server': the server id
|
||||
/// If 'Aws': the instance type (eg. c5.xlarge)
|
||||
pub instance_type: Option<String>,
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@ pub type RepoListItem = ResourceListItem<RepoListItemInfo>;
|
||||
pub struct RepoListItemInfo {
|
||||
/// The server that repo sits on.
|
||||
pub server_id: String,
|
||||
/// The builder that builds the repo.
|
||||
pub builder_id: String,
|
||||
/// Repo last cloned / pulled timestamp in ms.
|
||||
pub last_pulled_at: I64,
|
||||
/// Repo last built timestamp in ms.
|
||||
|
||||
@@ -489,6 +489,8 @@ export interface BuildListItemInfo {
|
||||
last_built_at: I64;
|
||||
/** The current version of the build */
|
||||
version: Version;
|
||||
/** The builder attached to build. */
|
||||
builder_id: string;
|
||||
/** The git provider domain */
|
||||
git_provider: string;
|
||||
/** The repo used as the source of the build */
|
||||
@@ -535,7 +537,12 @@ export type Builder = Resource<BuilderConfig, undefined>;
|
||||
export type GetBuilderResponse = Builder;
|
||||
|
||||
export interface BuilderListItemInfo {
|
||||
/** 'Server' or 'Aws' */
|
||||
builder_type: string;
|
||||
/**
|
||||
* If 'Server': the server id
|
||||
* If 'Aws': the instance type (eg. c5.xlarge)
|
||||
*/
|
||||
instance_type?: string;
|
||||
}
|
||||
|
||||
@@ -1060,6 +1067,8 @@ export enum RepoState {
|
||||
export interface RepoListItemInfo {
|
||||
/** The server that repo sits on. */
|
||||
server_id: string;
|
||||
/** The builder that builds the repo. */
|
||||
builder_id: string;
|
||||
/** Repo last cloned / pulled timestamp in ms. */
|
||||
last_pulled_at: I64;
|
||||
/** Repo last built timestamp in ms. */
|
||||
|
||||
@@ -2,6 +2,8 @@ import { ConfirmButton } from "@components/util";
|
||||
import { useExecute, useRead } from "@lib/hooks";
|
||||
import { Types } from "@monitor/client";
|
||||
import { Ban, Hammer, Loader2 } from "lucide-react";
|
||||
import { useBuilder } from "../builder";
|
||||
import { useBuild } from ".";
|
||||
|
||||
export const RunBuild = ({ id }: { id: string }) => {
|
||||
const perms = useRead("GetPermissionLevel", {
|
||||
@@ -21,6 +23,9 @@ export const RunBuild = ({ id }: { id: string }) => {
|
||||
const { mutate: run_mutate, isPending: runPending } = useExecute("RunBuild");
|
||||
const { mutate: cancel_mutate, isPending: cancelPending } =
|
||||
useExecute("CancelBuild");
|
||||
const build = useBuild(id);
|
||||
const builder = useBuilder(build?.info.builder_id);
|
||||
const canCancel = builder?.info.builder_type !== "Server";
|
||||
|
||||
// make sure hidden without perms.
|
||||
// not usually necessary, but this button also used in deployment actions.
|
||||
@@ -38,6 +43,7 @@ export const RunBuild = ({ id }: { id: string }) => {
|
||||
(u) => u.operation === Types.Operation.CancelBuild
|
||||
);
|
||||
const cancelDisabled =
|
||||
!canCancel ||
|
||||
cancelPending ||
|
||||
(latestCancel && latestBuild
|
||||
? latestCancel!.start_ts > latestBuild!.start_ts
|
||||
|
||||
@@ -24,7 +24,7 @@ import { Badge } from "@ui/badge";
|
||||
import { useToast } from "@ui/use-toast";
|
||||
import { Button } from "@ui/button";
|
||||
|
||||
const useBuild = (id?: string) =>
|
||||
export const useBuild = (id?: string) =>
|
||||
useRead("ListBuilds", {}, { refetchInterval: 5000 }).data?.find(
|
||||
(d) => d.id === id
|
||||
);
|
||||
|
||||
@@ -19,8 +19,10 @@ import { BuilderConfig } from "./config";
|
||||
import { DeleteResource, ResourceLink } from "../common";
|
||||
import { BuilderTable } from "./table";
|
||||
|
||||
const useBuilder = (id?: string) =>
|
||||
useRead("ListBuilders", {}).data?.find((d) => d.id === id);
|
||||
export const useBuilder = (id?: string) =>
|
||||
useRead("ListBuilders", {}, { refetchInterval: 5000 }).data?.find(
|
||||
(d) => d.id === id
|
||||
);
|
||||
|
||||
export const BuilderInstanceType = ({ id }: { id: string }) => {
|
||||
let info = useBuilder(id)?.info;
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
} from "lucide-react";
|
||||
import { useRepo } from ".";
|
||||
import { Types } from "@monitor/client";
|
||||
import { useBuilder } from "../builder";
|
||||
|
||||
export const CloneRepo = ({ id }: { id: string }) => {
|
||||
const hash = useRepo(id)?.info.latest_hash;
|
||||
@@ -84,6 +85,10 @@ export const BuildRepo = ({ id }: { id: string }) => {
|
||||
const { mutate: cancel_mutate, isPending: cancelPending } =
|
||||
useExecute("CancelRepoBuild");
|
||||
|
||||
const repo = useRepo(id);
|
||||
const builder = useBuilder(repo?.info.builder_id);
|
||||
const canCancel = builder?.info.builder_type !== "Server";
|
||||
|
||||
// make sure hidden without perms.
|
||||
// not usually necessary, but this button also used in deployment actions.
|
||||
if (
|
||||
@@ -100,6 +105,7 @@ export const BuildRepo = ({ id }: { id: string }) => {
|
||||
(u) => u.operation === Types.Operation.CancelRepoBuild
|
||||
);
|
||||
const cancelDisabled =
|
||||
!canCancel ||
|
||||
cancelPending ||
|
||||
(latestCancel && latestBuild
|
||||
? latestCancel!.start_ts > latestBuild!.start_ts
|
||||
|
||||
Reference in New Issue
Block a user