Skip to content

feat: add warning message when trying to delete active template #10142

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 10 commits into from
Oct 10, 2023
Prev Previous commit
Next Next commit
refactor: improve readability
  • Loading branch information
Parkreiner committed Oct 9, 2023
commit 8f50beb7dbef76f906f924f0580c52df40798704
6 changes: 4 additions & 2 deletions site/src/pages/TemplatePage/TemplatePageHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ export const TemplatePageHeader: FC<TemplatePageHeaderProps> = ({
});

const hasIcon = template.icon && template.icon !== "";
const safeToDeleteTemplate =
workspaceCountQuery.status === "success" && workspaceCountQuery.data === 0;

return (
<Margins>
Expand Down Expand Up @@ -180,8 +182,7 @@ export const TemplatePageHeader: FC<TemplatePageHeaderProps> = ({
</Stack>
</PageHeader>

{workspaceCountQuery.status === "success" &&
workspaceCountQuery.data === 0 ? (
{safeToDeleteTemplate ? (
<DeleteDialog
isOpen={deletionState.isDeleteDialogOpen}
onConfirm={deletionState.confirmDelete}
Expand All @@ -197,6 +198,7 @@ export const TemplatePageHeader: FC<TemplatePageHeaderProps> = ({
open={deletionState.isDeleteDialogOpen}
onClose={deletionState.cancelDeleteConfirmation}
confirmText="See workspaces"
confirmLoading={workspaceCountQuery.status !== "success"}
onConfirm={() => {
navigate({
pathname: "/workspaces",
Expand Down