diff --git a/frontend/src/lib/components/access/ItemReads.svelte b/frontend/src/lib/components/access/ItemReads.svelte new file mode 100644 index 0000000000..afe0f3004d --- /dev/null +++ b/frontend/src/lib/components/access/ItemReads.svelte @@ -0,0 +1,216 @@ + + +{#if items.length} + open, (o) => key && (toggled = { key, open: o })} + > +
+
+ {#each items as item (item.kind + ':' + item.path)} + {@const itemKey = `${item.kind}:${item.path}`} + {@const ok = readable?.(item)} + {#if readable} + {#if ok} + + {:else} + + {/if} + {/if} + {item.path} + {item.kind} + {#if readable} + {#if grantErrors[itemKey]} + + {grantErrors[itemKey]} + + {:else if !ok} + + {account} + {mode === 'pending' ? "won't be able to read it" : "can't read it"} + + {:else} + + {/if} + {/if} + {/each} +
+ {#if missing.length && mode === 'checked' && isAdmin} +
+ +
+ {/if} + {#if mode === 'caller'} + + It runs as whoever runs it, so each of them needs read access to these. + + {/if} + {#if shown?.needs.others.length} + + Also uses {shown.needs.others.map((o) => `${o.kind} ${o.path}`).join(', ')}; access to + these is set on the storage or data table itself. + + {/if} + {#if shown?.needs.errors.length} + + Some of it could not be read, so this list may be incomplete: {shown.needs.errors.join( + '; ' + )}. + + {/if} + + Only paths written out in the code are found; a path the code builds while it runs isn't. + +
+
+{/if} diff --git a/frontend/src/lib/components/access/MissingReadsNote.svelte b/frontend/src/lib/components/access/MissingReadsNote.svelte deleted file mode 100644 index 71d4d1a177..0000000000 --- a/frontend/src/lib/components/access/MissingReadsNote.svelte +++ /dev/null @@ -1,128 +0,0 @@ - - -{#if shown?.missing.length} - {@const n = shown.missing.length} -
-
- - - {shown.account} can't read {n} - {n === 1 ? 'thing' : 'things'} this {kind} reads - - A path the code builds while it runs can't be found. -
-
- {#each shown.missing as item (item.kind + ':' + item.path)} - {@const error = grantErrors[`${item.kind}:${item.path}`]} - {item.path} - {item.kind} - {error ?? ''} - {/each} -
-
- -
-
-{:else if shown?.items.length} - {@const n = shown.items.length} - - {shown.account} reads the {n === 1 ? shown.items[0].kind : `${n} resources and variables`} this {kind} - uses. - -{/if} diff --git a/frontend/src/lib/components/access/RunAsNotes.svelte b/frontend/src/lib/components/access/RunAsNotes.svelte index b8ab40774f..83321cfaac 100644 --- a/frontend/src/lib/components/access/RunAsNotes.svelte +++ b/frontend/src/lib/components/access/RunAsNotes.svelte @@ -10,7 +10,7 @@ import { enterpriseLicense } from '$lib/stores' import { Bot, Folder } from 'lucide-svelte' import type { NeedsSource } from './detectNeeds' - import MissingReadsNote from './MissingReadsNote.svelte' + import ItemReads from './ItemReads.svelte' import NewServiceAccountForm from './NewServiceAccountForm.svelte' import { getPendingServiceAccount, @@ -26,6 +26,7 @@ runsAs, isNew, savedPermissionedAs, + runnablesRunAsCaller = false, onUseAccount, onCreatingChange }: { @@ -37,6 +38,8 @@ runsAs: string | undefined isNew: boolean savedPermissionedAs: string | undefined + /** 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 @@ -114,7 +117,13 @@ {/if} - + {#if pending}
diff --git a/frontend/src/lib/components/apps/editor/AppEditorHeaderDeploy.svelte b/frontend/src/lib/components/apps/editor/AppEditorHeaderDeploy.svelte index 55fa0a7246..eb10eb2174 100644 --- a/frontend/src/lib/components/apps/editor/AppEditorHeaderDeploy.svelte +++ b/frontend/src/lib/components/apps/editor/AppEditorHeaderDeploy.svelte @@ -397,6 +397,7 @@ runsAs={deployOnBehalfOf} isNew={newApp} savedPermissionedAs={savedOnBehalfOf} + runnablesRunAsCaller={policy.execution_mode == 'viewer'} onUseAccount={(username, email) => { onBehalfOfChoice = 'custom' policy.on_behalf_of_email = email diff --git a/frontend/src/lib/components/itemSettings/RunOnBehalfOfSetting.svelte b/frontend/src/lib/components/itemSettings/RunOnBehalfOfSetting.svelte index 593da3d8a1..7e08dee41c 100644 --- a/frontend/src/lib/components/itemSettings/RunOnBehalfOfSetting.svelte +++ b/frontend/src/lib/components/itemSettings/RunOnBehalfOfSetting.svelte @@ -10,7 +10,7 @@ import { canPreserveOnBehalfOf, deployedPermissionedAs, WM_DEPLOYERS_GROUP } from './onBehalfOf' import { useServiceAccounts } from '$lib/components/access/serviceAccounts.svelte' import type { NeedsSource } from '$lib/components/access/detectNeeds' - import MissingReadsNote from '$lib/components/access/MissingReadsNote.svelte' + import ItemReads from '$lib/components/access/ItemReads.svelte' const DOCS_LINK = 'https://www.windmill.dev/docs/core_concepts/roles_and_permissions#run-on-behalf-of' @@ -174,16 +174,6 @@ : 'No folder is shared with it.'}
{/if} - - {#if !aboveConfirmationModal} - - {/if} {#if !canPreserve}
Only workspace admins and members of {WM_DEPLOYERS_GROUP} can pick another user. @@ -243,3 +233,16 @@ {@render picker()} {/if} + + +{#if !aboveConfirmationModal} +
+ +
+{/if}