mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-11-28 08:06:16 +00:00
fix: keep pending accounts out of pickers that can't create them
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
3f02e71f8e
commit
e2dc85077a
@@ -40,6 +40,7 @@
|
||||
} from './access/serviceAccounts.svelte'
|
||||
import NewServiceAccountForm from './access/NewServiceAccountForm.svelte'
|
||||
import type { NeedsSource } from './access/detectNeeds'
|
||||
import { useOperatingUser } from './operatingWorkspace.svelte'
|
||||
|
||||
interface Props {
|
||||
targetWorkspace: string
|
||||
@@ -167,6 +168,14 @@
|
||||
}
|
||||
const GROUP_ORDER = Object.values(GROUP_OF)
|
||||
|
||||
// Service accounts are created at deploy time for the runnables a deploy dialog confirms; a
|
||||
// trigger's identity is set where it is saved, with no dialog to create one from.
|
||||
const offersCreate = $derived(
|
||||
offerCreate && (kind === 'script' || kind === 'flow' || kind === 'app' || kind === 'raw_app')
|
||||
)
|
||||
const operatingUser = useOperatingUser()
|
||||
const canCreate = $derived(!!$enterpriseLicense && !!operatingUser.current?.is_admin)
|
||||
|
||||
// One row per user: the saved value and "me" are tags on the account or person row when it is
|
||||
// listed, and rows of their own, at the top of the group of what they name, when it is not.
|
||||
let rows: Row[] = $derived.by(() => {
|
||||
@@ -178,7 +187,8 @@
|
||||
|
||||
const listed: Omit<Row, 'label'>[] = [
|
||||
...serviceAccounts.current
|
||||
.filter((a) => a.pending || canPreserve)
|
||||
// Only a host that creates accounts at deploy can keep one that doesn't exist yet.
|
||||
.filter((a) => (a.pending ? offersCreate : canPreserve))
|
||||
.sort(
|
||||
(a, b) =>
|
||||
Number(!!b.pending) - Number(!!a.pending) || a.username.localeCompare(b.username)
|
||||
@@ -241,13 +251,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
// Service accounts are created at deploy time for the runnables a deploy dialog confirms; a
|
||||
// trigger's identity is set where it is saved, with no dialog to create one from.
|
||||
const offersCreate = $derived(
|
||||
offerCreate && (kind === 'script' || kind === 'flow' || kind === 'app' || kind === 'raw_app')
|
||||
)
|
||||
const canCreate = $derived(!!$enterpriseLicense && !!$userStore?.is_admin)
|
||||
|
||||
let filterText = $state('')
|
||||
let selectOpen = $state(false)
|
||||
let drawerOpen = $state(false)
|
||||
|
||||
@@ -23,7 +23,8 @@
|
||||
kind,
|
||||
itemPath,
|
||||
needsSource,
|
||||
account
|
||||
account,
|
||||
onConfirmingChange
|
||||
}: {
|
||||
workspace: string
|
||||
kind: RunnableKind
|
||||
@@ -32,6 +33,8 @@
|
||||
needsSource?: () => NeedsSource | undefined
|
||||
/** `u/<username>` the item runs as; unset when it runs as whoever runs it. */
|
||||
account: string | undefined
|
||||
/** Whether the grant confirmation is open. */
|
||||
onConfirmingChange?: (open: boolean) => void
|
||||
} = $props()
|
||||
|
||||
type Report = {
|
||||
@@ -62,6 +65,10 @@
|
||||
let grantErrors: Record<string, string> = $state({})
|
||||
let granting: string | undefined = $state()
|
||||
let confirming: NeededItem | undefined = $state()
|
||||
function setConfirming(item: NeededItem | undefined) {
|
||||
confirming = item
|
||||
onConfirmingChange?.(!!item)
|
||||
}
|
||||
// Responses are not ordered: a slow answer for the previous identity must not land.
|
||||
let requestId = 0
|
||||
|
||||
@@ -138,7 +145,7 @@
|
||||
}
|
||||
await check()
|
||||
granting = undefined
|
||||
confirming = undefined
|
||||
setConfirming(undefined)
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -153,7 +160,7 @@
|
||||
alwaysPortal
|
||||
zIndexClass="z-[10000]"
|
||||
onConfirmed={() => confirming && grantRead(confirming)}
|
||||
onCanceled={() => (confirming = undefined)}
|
||||
onCanceled={() => setConfirming(undefined)}
|
||||
>
|
||||
{#if confirming}
|
||||
<p class="text-xs text-primary">
|
||||
@@ -208,7 +215,7 @@
|
||||
variant="default"
|
||||
unifiedSize="xs"
|
||||
disabled={!!granting}
|
||||
onClick={() => (confirming = item)}
|
||||
onClick={() => setConfirming(item)}
|
||||
>
|
||||
Grant read
|
||||
</Button>
|
||||
|
||||
@@ -199,6 +199,7 @@
|
||||
}
|
||||
placeholder="Add a folder"
|
||||
size="sm"
|
||||
disablePortal
|
||||
/>
|
||||
</div>
|
||||
<div class="flex items-start gap-1.5 text-2xs text-secondary">
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
savedPermissionedAs,
|
||||
runnablesRunAsCaller = false,
|
||||
onUseAccount,
|
||||
onCreatingChange
|
||||
onOverlayChange
|
||||
}: {
|
||||
kind: 'script' | 'flow' | 'app'
|
||||
targetWorkspace: string
|
||||
@@ -39,8 +39,9 @@
|
||||
/** An app in viewer mode runs its runnables as each viewer, whoever `runsAs` names. */
|
||||
runnablesRunAsCaller?: boolean
|
||||
onUseAccount: (username: string, email: string) => void
|
||||
/** See `OnBehalfOfSelector`'s `onPickerOpenChange`. */
|
||||
onCreatingChange?: (open: boolean) => void
|
||||
/** Whether the create drawer or the grant confirmation is open over the host dialog, which
|
||||
* must stop handling keys meanwhile: its listener and theirs both sit on the window. */
|
||||
onOverlayChange?: (open: boolean) => void
|
||||
} = $props()
|
||||
|
||||
const operatingUser = useOperatingUser()
|
||||
@@ -82,10 +83,15 @@
|
||||
)
|
||||
|
||||
let creatingOpen = $state(false)
|
||||
let confirmingGrant = false
|
||||
let createForm: NewServiceAccountForm | undefined = $state()
|
||||
function setCreating(open: boolean) {
|
||||
creatingOpen = open
|
||||
onCreatingChange?.(open)
|
||||
onOverlayChange?.(creatingOpen || confirmingGrant)
|
||||
}
|
||||
function setConfirmingGrant(open: boolean) {
|
||||
confirmingGrant = open
|
||||
onOverlayChange?.(creatingOpen || confirmingGrant)
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -123,6 +129,7 @@
|
||||
{itemPath}
|
||||
{needsSource}
|
||||
account={runnablesRunAsCaller ? undefined : runsAs}
|
||||
onConfirmingChange={setConfirmingGrant}
|
||||
/>
|
||||
|
||||
{#if pending}
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
})
|
||||
)
|
||||
let pickerOpen = $state(false)
|
||||
let creatingOpen = $state(false)
|
||||
let overlayOpen = $state(false)
|
||||
let deploying = $state(false)
|
||||
|
||||
async function confirm() {
|
||||
@@ -97,7 +97,7 @@
|
||||
confirmationText="Deploy"
|
||||
confirmDisabled={folderDefaultLoading}
|
||||
loading={deploying}
|
||||
keyListen={!pickerOpen && !creatingOpen}
|
||||
keyListen={!pickerOpen && !overlayOpen}
|
||||
alwaysPortal
|
||||
onConfirmed={confirm}
|
||||
onCanceled={() => (open = false)}
|
||||
@@ -118,7 +118,7 @@
|
||||
onPickerOpenChange={(o) => (pickerOpen = o)}
|
||||
{itemPath}
|
||||
{needsSource}
|
||||
onCreatingChange={(o) => (creatingOpen = o)}
|
||||
onOverlayChange={(o) => (overlayOpen = o)}
|
||||
/>
|
||||
<TextInput bind:value={message} inputProps={{ placeholder: 'Deployment message' }} />
|
||||
</div>
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
/** The item's path and its editor's copy: what a service account made here is built from. */
|
||||
itemPath?: string
|
||||
needsSource?: () => NeedsSource | undefined
|
||||
onCreatingChange?: (open: boolean) => void
|
||||
onOverlayChange?: (open: boolean) => void
|
||||
}
|
||||
|
||||
let {
|
||||
@@ -47,7 +47,7 @@
|
||||
onPickerOpenChange,
|
||||
itemPath,
|
||||
needsSource,
|
||||
onCreatingChange
|
||||
onOverlayChange
|
||||
}: Props = $props()
|
||||
|
||||
const operatingUser = useOperatingUser()
|
||||
@@ -132,5 +132,5 @@
|
||||
email = accountEmail
|
||||
permissionedAs = `u/${username}`
|
||||
}}
|
||||
{onCreatingChange}
|
||||
{onOverlayChange}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user