revert: leave the deploy panel's access toggle to the settings drawer PR

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Guilhem Lemouel
2026-10-23 02:43:49 -07:00
co-authored by Claude Opus 5.5
parent 7f18fd3136
commit d92cd4f6de
3 changed files with 25 additions and 67 deletions
@@ -467,27 +467,20 @@
}
}
async function setPublishState(message: string) {
async function setPublishState(message?: string) {
policy = await updatePolicy($app, policy)
await AppService.updateApp({
workspace: $workspaceStore!,
path: $appPath,
requestBody: { policy }
})
sendUserToast(message)
}
async function setAccessMode(mode: NonNullable<Policy['execution_mode']>) {
await AppService.updateApp({
workspace: $workspaceStore!,
path: $appPath,
requestBody: { execution_mode: mode }
})
sendUserToast(
mode == 'anonymous'
? 'App require no login to be accessed'
: 'App require login and read-access'
)
if (message) {
sendUserToast(message)
} else if (policy.execution_mode == 'anonymous') {
sendUserToast('App require no login to be accessed')
} else {
sendUserToast('App require login and read-access')
}
}
async function save() {
@@ -955,7 +948,6 @@
{newApp}
{policy}
{setPublishState}
{setAccessMode}
appPath={$appPath}
{onLatest}
{headUnknown}
@@ -11,7 +11,7 @@
import ClipboardPanel from '$lib/components/details/ClipboardPanel.svelte'
import { untrack } from 'svelte'
import { AppService, SettingService, WorkspaceService } from '$lib/gen'
import type { GuestUsage, Policy } from '$lib/gen'
import type { GuestUsage } from '$lib/gen'
import ToggleButtonGroup from '$lib/components/common/toggleButton-v2/ToggleButtonGroup.svelte'
import ToggleButton from '$lib/components/common/toggleButton-v2/ToggleButton.svelte'
import Path from '$lib/components/Path.svelte'
@@ -43,7 +43,6 @@
let {
policy,
setPublishState,
setAccessMode,
appPath,
customPath = $bindable(),
onLatest,
@@ -63,9 +62,7 @@
operatingWorkspace = undefined
}: {
policy: any
setPublishState: (message: string) => void
/** Changes who may open the deployed app, leaving the rest of its deployed policy as is. */
setAccessMode: (mode: NonNullable<Policy['execution_mode']>) => Promise<void>
setPublishState: (message?: string) => void
appPath: string
customPath: string | undefined
onLatest: boolean
@@ -148,26 +145,14 @@
})
})
// One change at a time: a failed request puts back the mode it replaced, which would
// overwrite a newer selection that already succeeded.
let accessModePending = $state(false)
async function onAccessModeChange(mode: string | undefined) {
if (mode === undefined || mode === accessMode || accessModePending) return
const previous = policy.execution_mode
function onAccessModeChange(mode: string | undefined) {
if (mode === undefined || mode === accessMode) return
policy.execution_mode = mode
// Same as sandbox: a not-yet-deployed app has no row to update, so
// `setAccessMode` would 404. The mode is carried by the first deploy's
// Same as sandbox: a not-yet-deployed app has no row to PATCH, so
// `setPublishState` would 404. The mode is carried by the first deploy's
// policy; persist incrementally only once the app exists.
if (savedApp && !newApp && !modeChangesOnDeploy) {
accessModePending = true
try {
await setAccessMode(mode as NonNullable<Policy['execution_mode']>)
} catch (e) {
policy.execution_mode = previous
throw e
} finally {
accessModePending = false
}
if (savedApp && !newApp) {
setPublishState()
}
}
let canPreserve = $derived(!!actingUser?.is_admin || !!actingUser?.is_super_admin || isDeployer)
@@ -176,11 +161,6 @@
let onBehalfOfChoice: OnBehalfOfChoice = $state(undefined)
let customOnBehalfOfEmail: string = $state('')
let myOnBehalfOf = $derived(actingUser?.username ? `u/${actingUser.username}` : undefined)
// The server refuses to change the mode alone of an app that runs as someone else unless the
// caller may keep that identity, and always for a builder; for them it changes on deploy.
let modeChangesOnDeploy = $derived(
!!savedOnBehalfOf && savedOnBehalfOf !== myOnBehalfOf && (!canPreserve || composeOnlyApps)
)
// Without the right to preserve, the backend runs the redeployed app as the deployer whatever
// the policy says, as it does for "me".
let deployOnBehalfOf = $derived.by(() => {
@@ -538,7 +518,7 @@
<ToggleButtonGroup
selected={accessMode}
on:selected={(e) => onAccessModeChange(e.detail)}
disabled={!savedApp || accessModePending}
disabled={!savedApp}
>
{#snippet children({ item })}
<ToggleButton
@@ -566,12 +546,6 @@
{/snippet}
</ToggleButtonGroup>
</div>
{#if savedApp && !newApp && modeChangesOnDeploy}
<div class="text-xs text-secondary">
This app runs as <strong>{savedOnBehalfOf}</strong>, so a change here takes effect when
you deploy.
</div>
{/if}
<div class="text-xs text-secondary">
{#if policy.execution_mode == 'anonymous'}
Anyone holding the secret URL below can open this app without signing in.
@@ -663,7 +663,7 @@
})
}
async function setPublishState(message: string) {
async function setPublishState(message?: string) {
const nextPolicy = await policyWithTriggerables()
await AppService.updateApp({
workspace: opWorkspace!,
@@ -671,20 +671,13 @@
requestBody: { policy: nextPolicy }
})
policy.triggerables_v2 = nextPolicy.triggerables_v2
sendUserToast(message)
}
async function setAccessMode(mode: NonNullable<Policy['execution_mode']>) {
await AppService.updateApp({
workspace: opWorkspace!,
path: appPath,
requestBody: { execution_mode: mode }
})
sendUserToast(
mode == 'anonymous'
? 'App require no login to be accessed'
: 'App require login and read-access'
)
if (message) {
sendUserToast(message)
} else if (policy.execution_mode == 'anonymous') {
sendUserToast('App require no login to be accessed')
} else {
sendUserToast('App require login and read-access')
}
}
async function save() {
@@ -901,7 +894,6 @@
{newApp}
{policy}
{setPublishState}
{setAccessMode}
{appPath}
{onLatest}
{headUnknown}