Skip to content

feat: display provisioner jobs and daemons for an organization #16532

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
b6430bb
Set base structure to display the provisioner jobs
BrunoQuaresma Feb 5, 2025
5d7d58f
Merge branch 'main' of https://github.com/coder/coder into bq/refacto…
BrunoQuaresma Feb 7, 2025
643c362
[WIP]: Load data and display them in the table
BrunoQuaresma Feb 7, 2025
f9db209
Merge branch 'main' of https://github.com/coder/coder into bq/refacto…
BrunoQuaresma Feb 10, 2025
6e967f1
Update table to use API data
BrunoQuaresma Feb 10, 2025
943b7d7
Finish job structure
BrunoQuaresma Feb 10, 2025
2bc6ccf
Display tiny alert for error
BrunoQuaresma Feb 10, 2025
71f4fe5
Fix tags
BrunoQuaresma Feb 10, 2025
f027485
Add daemons page
BrunoQuaresma Feb 10, 2025
dcf8140
Merge branch 'main' of https://github.com/coder/coder into bq/refacto…
BrunoQuaresma Feb 10, 2025
994e186
Merge branch 'main' of https://github.com/coder/coder into bq/refacto…
BrunoQuaresma Feb 11, 2025
3083cef
Merge branch 'main' of https://github.com/coder/coder into bq/refacto…
BrunoQuaresma Feb 11, 2025
d66141e
Display all daemon data from server
BrunoQuaresma Feb 11, 2025
49a7ec7
Remove unused imports
BrunoQuaresma Feb 11, 2025
ffee2ed
Run fmt
BrunoQuaresma Feb 11, 2025
7802636
Add cancel provisioner job
BrunoQuaresma Feb 12, 2025
4f9030f
Run fmt
BrunoQuaresma Feb 12, 2025
22dc7be
Merge branch 'main' of https://github.com/coder/coder into bq/refacto…
BrunoQuaresma Feb 13, 2025
0ff39e5
Merge branch 'main' of https://github.com/coder/coder into bq/refacto…
BrunoQuaresma Feb 14, 2025
5953960
Apply PR reviews
BrunoQuaresma Feb 14, 2025
aabf8df
FMT
BrunoQuaresma Feb 14, 2025
ed61ce7
Reset devcontainer.json
BrunoQuaresma Feb 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 44 additions & 1 deletion site/src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1238,7 +1238,7 @@ class ApiMethods {
};

cancelTemplateVersionBuild = async (
templateVersionId: TypesGen.TemplateVersion["id"],
templateVersionId: string,
): Promise<TypesGen.Response> => {
const response = await this.axios.patch(
`/api/v2/templateversions/${templateVersionId}/cancel`,
Expand All @@ -1247,6 +1247,17 @@ class ApiMethods {
return response.data;
};

cancelTemplateVersionDryRun = async (
templateVersionId: string,
jobId: string,
): Promise<TypesGen.Response> => {
const response = await this.axios.patch(
`/api/v2/templateversions/${templateVersionId}/dry-run/${jobId}/cancel`,
);

return response.data;
};

createUser = async (
user: TypesGen.CreateUserRequestWithOrgs,
): Promise<TypesGen.User> => {
Expand Down Expand Up @@ -2295,6 +2306,38 @@ class ApiMethods {
);
return res.data;
};

getProvisionerJobs = async (orgId: string) => {
const res = await this.axios.get<TypesGen.ProvisionerJob[]>(
`/api/v2/organizations/${orgId}/provisionerjobs`,
);
return res.data;
};

cancelProvisionerJob = async (job: TypesGen.ProvisionerJob) => {
switch (job.type) {
case "workspace_build":
if (!job.input.workspace_build_id) {
throw new Error("Workspace build ID is required to cancel this job");
}
return this.cancelWorkspaceBuild(job.input.workspace_build_id);

case "template_version_import":
if (!job.input.template_version_id) {
throw new Error("Template version ID is required to cancel this job");
}
return this.cancelTemplateVersionBuild(job.input.template_version_id);

case "template_version_dry_run":
if (!job.input.template_version_id) {
throw new Error("Template version ID is required to cancel this job");
}
return this.cancelTemplateVersionDryRun(
job.input.template_version_id,
job.id,
);
}
};
}

// This is a hard coded CSRF token/cookie pair for local development. In prod,
Expand Down
13 changes: 13 additions & 0 deletions site/src/api/queries/organizations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,19 @@ export const organizationPermissions = (organizationId: string | undefined) => {
};
};

export const provisionerJobQueryKey = (orgId: string) => [
"organization",
orgId,
"provisionerjobs",
];

export const provisionerJobs = (orgId: string) => {
return {
queryKey: provisionerJobQueryKey(orgId),
queryFn: () => API.getProvisionerJobs(orgId),
};
};

/**
* Fetch permissions for all provided organizations.
*
Expand Down
19 changes: 16 additions & 3 deletions site/src/components/Badge/Badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,21 @@ import type { FC } from "react";
import { cn } from "utils/cn";

export const badgeVariants = cva(
"inline-flex items-center rounded-md border px-2.5 py-1 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
"inline-flex items-center rounded-md border px-2 py-1 transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
{
variants: {
variant: {
default:
"border-transparent bg-surface-secondary text-content-secondary shadow hover:bg-surface-tertiary",
},
size: {
sm: "text-2xs font-regular",
md: "text-xs font-medium",
},
},
defaultVariants: {
variant: "default",
size: "md",
},
},
);
Expand All @@ -25,8 +30,16 @@ export interface BadgeProps
extends React.HTMLAttributes<HTMLDivElement>,
VariantProps<typeof badgeVariants> {}

export const Badge: FC<BadgeProps> = ({ className, variant, ...props }) => {
export const Badge: FC<BadgeProps> = ({
className,
variant,
size,
...props
}) => {
return (
<div className={cn(badgeVariants({ variant }), className)} {...props} />
<div
className={cn(badgeVariants({ variant, size }), className)}
{...props}
/>
);
};
8 changes: 4 additions & 4 deletions site/src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { cn } from "utils/cn";

export const buttonVariants = cva(
`inline-flex items-center justify-center gap-1 whitespace-nowrap
border-solid rounded-md transition-colors min-w-20
border-solid rounded-md transition-colors
text-sm font-semibold font-medium cursor-pointer no-underline
focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-content-link
disabled:pointer-events-none disabled:text-content-disabled
Expand All @@ -28,9 +28,9 @@ export const buttonVariants = cva(
},

size: {
lg: "h-10 px-3 py-2 [&_svg]:size-icon-lg",
sm: "h-[30px] px-2 py-1.5 text-xs [&_svg]:size-icon-sm",
icon: "h-[30px] min-w-[30px] px-1 py-1.5 [&_svg]:size-icon-sm",
lg: "min-w-20 h-10 px-3 py-2 [&_svg]:size-icon-lg",
sm: "min-w-20 h-8 px-2 py-1.5 text-xs [&_svg]:size-icon-sm",
icon: "size-8 px-1.5 [&_svg]:size-icon-sm",
},
},
defaultVariants: {
Expand Down
5 changes: 5 additions & 0 deletions site/src/modules/management/DeploymentSidebarView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ export const DeploymentSidebarView: FC<DeploymentSidebarViewProps> = ({
IdP Organization Sync
</SidebarNavItem>
)}
{permissions.viewDeploymentValues && (
<SidebarNavItem href="/deployment/provisioners">
Provisioners
</SidebarNavItem>
)}
{!hasPremiumLicense && (
<SidebarNavItem href="/deployment/premium">Premium</SidebarNavItem>
)}
Expand Down

This file was deleted.

This file was deleted.

Loading
Loading