mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-12-03 08:10:27 +00:00
feat: require typing the workspace ID to archive or delete a root workspace (#12821)
* feat: require typing the workspace ID to archive or delete a root workspace Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: say only an instance superadmin can unarchive a workspace Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
9f7d00ef4e
commit
48d2b46a65
@@ -111,6 +111,7 @@
|
||||
reconcileAfterWorkspaceChange
|
||||
} from '$lib/components/sessions/sessionState.svelte'
|
||||
import TextInput from '$lib/components/text_input/TextInput.svelte'
|
||||
import { workspaceIsFork } from '$lib/utils/workspaceHierarchy'
|
||||
import CollapseLink from '$lib/components/CollapseLink.svelte'
|
||||
import SlackAppSetup from '$lib/components/common/slack/SlackAppSetup.svelte'
|
||||
import { validateWebhookUrl, validateEncryptionKey } from '$lib/validators/workspaceSettings'
|
||||
@@ -139,13 +140,18 @@
|
||||
let archiveConfirmOpen = $state(false)
|
||||
let deleteConfirmOpen = $state(false)
|
||||
let affectedSessionCount = $state(0)
|
||||
// A root workspace has no parent to fall back on, so archiving or deleting it asks for its
|
||||
// ID typed out; a fork is disposable and keeps the one-click confirm.
|
||||
let typedWorkspaceId = $state('')
|
||||
|
||||
async function openArchiveConfirm() {
|
||||
affectedSessionCount = await countSessionsForWorkspace($workspaceStore ?? '')
|
||||
typedWorkspaceId = ''
|
||||
archiveConfirmOpen = true
|
||||
}
|
||||
async function openDeleteConfirm() {
|
||||
affectedSessionCount = await countSessionsForWorkspace($workspaceStore ?? '')
|
||||
typedWorkspaceId = ''
|
||||
deleteConfirmOpen = true
|
||||
}
|
||||
async function doArchiveWorkspace() {
|
||||
@@ -503,6 +509,14 @@
|
||||
}
|
||||
})
|
||||
const currentWorkspace = $derived($userWorkspaces.find((w) => w.id === $workspaceStore))
|
||||
// A dev workspace has a parent too but is long-lived, so only a plain fork skips typing the ID.
|
||||
const requiresTypedWorkspaceId = $derived(
|
||||
!workspaceIsFork($workspaceStore, $userWorkspaces) || !!currentWorkspace?.is_dev_workspace
|
||||
)
|
||||
const typedWorkspaceIdMatches = $derived(
|
||||
!requiresTypedWorkspaceId || typedWorkspaceId.trim() === ($workspaceStore ?? '')
|
||||
)
|
||||
const isSpecialWorkspace = $derived($workspaceStore === 'admins' || $workspaceStore === 'starter')
|
||||
|
||||
// The deploy filters configure what may be promoted into the parent, so they only mean
|
||||
// something for a fork. A root workspace deploys nowhere by lineage.
|
||||
@@ -2145,46 +2159,84 @@
|
||||
</div>
|
||||
|
||||
<div class="mt-12"></div>
|
||||
<span class="text-sm font-semibold text-emphasis">Delete workspace</span>
|
||||
{#if !$superadmin}
|
||||
<p class="text-2xs text-secondary">
|
||||
Only instance superadmins can delete a workspace.
|
||||
</p>
|
||||
{/if}
|
||||
{#if $workspaceStore === 'admins' || $workspaceStore === 'starter'}
|
||||
<p class="text-2xs text-secondary">
|
||||
This workspace cannot be deleted as it has a special function. Consult the
|
||||
documentation for more information.
|
||||
</p>
|
||||
{/if}
|
||||
<div class="flex flex-wrap gap-x-2">
|
||||
<Button
|
||||
destructive
|
||||
disabled={$workspaceStore === 'admins' || $workspaceStore === 'starter'}
|
||||
unifiedSize="md"
|
||||
btnClasses="mt-2"
|
||||
on:click={openArchiveConfirm}
|
||||
>
|
||||
Archive workspace
|
||||
</Button>
|
||||
|
||||
{#if $superadmin}
|
||||
<Button
|
||||
color="red"
|
||||
disabled={$workspaceStore === 'admins' || $workspaceStore === 'starter'}
|
||||
size="sm"
|
||||
btnClasses="mt-2"
|
||||
on:click={openDeleteConfirm}
|
||||
<Section label="Danger zone">
|
||||
<div class="flex flex-col rounded-md border border-red-300 dark:border-red-400/40">
|
||||
{#if isSpecialWorkspace}
|
||||
<p class="px-4 py-3 text-2xs text-secondary">
|
||||
This workspace cannot be archived or deleted as it has a special function.
|
||||
Consult the documentation for more information.
|
||||
</p>
|
||||
{/if}
|
||||
<div
|
||||
class="flex flex-wrap items-center justify-between gap-x-6 gap-y-2 px-4 py-3"
|
||||
>
|
||||
Delete workspace (superadmin)
|
||||
</Button>
|
||||
<div class="flex flex-col gap-0.5 flex-1 min-w-60">
|
||||
<span class="text-xs font-semibold text-emphasis">Archive workspace</span>
|
||||
<span class="text-xs text-secondary">
|
||||
Hides <span class="font-mono">{$workspaceStore}</span> from its members and archives
|
||||
its AI sessions. An instance superadmin can unarchive it from the workspaces
|
||||
page.
|
||||
</span>
|
||||
</div>
|
||||
<Button
|
||||
destructive
|
||||
variant="default"
|
||||
unifiedSize="md"
|
||||
disabled={isSpecialWorkspace}
|
||||
onClick={() => void openArchiveConfirm()}
|
||||
>
|
||||
Archive workspace
|
||||
</Button>
|
||||
</div>
|
||||
<div
|
||||
class="flex flex-wrap items-center justify-between gap-x-6 gap-y-2 px-4 py-3"
|
||||
>
|
||||
<div class="flex flex-col gap-0.5 flex-1 min-w-60">
|
||||
<span class="text-xs font-semibold text-emphasis">Delete workspace</span>
|
||||
<span class="text-xs text-secondary">
|
||||
Permanently deletes <span class="font-mono">{$workspaceStore}</span> with
|
||||
its scripts, flows, apps, resources, variables, schedules, run history and
|
||||
AI sessions. This cannot be undone.{#if !$superadmin}
|
||||
Only instance superadmins can delete a workspace.{/if}
|
||||
</span>
|
||||
</div>
|
||||
<Button
|
||||
destructive
|
||||
variant="default"
|
||||
unifiedSize="md"
|
||||
disabled={isSpecialWorkspace || !$superadmin}
|
||||
onClick={() => void openDeleteConfirm()}
|
||||
>
|
||||
Delete workspace
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Section>
|
||||
|
||||
{#snippet typeWorkspaceIdToConfirm()}
|
||||
{#if requiresTypedWorkspaceId}
|
||||
<div class="flex flex-col gap-1 mt-2">
|
||||
<span class="text-xs text-primary">
|
||||
Type <span class="font-mono font-semibold">{$workspaceStore}</span> to confirm.
|
||||
</span>
|
||||
<TextInput
|
||||
bind:value={typedWorkspaceId}
|
||||
inputProps={{
|
||||
type: 'text',
|
||||
autocomplete: 'off',
|
||||
spellcheck: false,
|
||||
'aria-label': 'Workspace ID'
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/snippet}
|
||||
|
||||
<ConfirmationModal
|
||||
open={archiveConfirmOpen}
|
||||
title="Archive workspace"
|
||||
confirmationText="Archive"
|
||||
confirmDisabled={!typedWorkspaceIdMatches}
|
||||
onConfirmed={async () => {
|
||||
archiveConfirmOpen = false
|
||||
await doArchiveWorkspace()
|
||||
@@ -2197,6 +2249,7 @@
|
||||
? ` (${affectedSessionCount})`
|
||||
: ''}. Unarchiving the workspace restores them.
|
||||
</span>
|
||||
{@render typeWorkspaceIdToConfirm()}
|
||||
</div>
|
||||
</ConfirmationModal>
|
||||
|
||||
@@ -2204,6 +2257,7 @@
|
||||
open={deleteConfirmOpen}
|
||||
title="Delete workspace"
|
||||
confirmationText="Delete"
|
||||
confirmDisabled={!typedWorkspaceIdMatches}
|
||||
onConfirmed={async () => {
|
||||
deleteConfirmOpen = false
|
||||
await doDeleteWorkspace()
|
||||
@@ -2217,6 +2271,7 @@
|
||||
? ` (${affectedSessionCount})`
|
||||
: ''}. This cannot be undone.
|
||||
</span>
|
||||
{@render typeWorkspaceIdToConfirm()}
|
||||
</div>
|
||||
</ConfirmationModal>
|
||||
{:else if tab == 'webhook'}
|
||||
|
||||
Reference in New Issue
Block a user