{#snippet draftBanner()}
(selected ? initialStates[selected] : undefined)}
getCurrent={() => current}
onDiscard={async () => {
if (!selected) return
// The workspace the editor is showing, which `WsSpecificVersions` can point at
// a linked one: the discard deletes that workspace's draft, so that is whose
// tabs it is about.
const ws = selected
const from = editPath ?? ''
UserDraft.discard('variable', from, initialStates[ws], { workspace: ws })
// A draft-only variable has no deployed row under the draft, so discarding
// it removed the variable: `initialStates` holds a synthesized stand-in, not
// a baseline to fall back to. Only once the delete has landed — until then
// the variable is still there, and a host would leave on a row it can see.
const landed = await flushDraftDelete('variable', from, { workspace: ws })
if (!existedInitially[ws] && landed && from) onRemoved?.(from, ws)
}}
disabled={!can_write}
/>
{/snippet}
{#snippet editorActions()}
{#if useDrawer}
{/if}
{#if edit && curWs}
{/if}
{/snippet}
{#snippet editorBody()}
{#if !can_write}
You only have read access to this resource and cannot edit it
{/if}
{#if otherDirty.length > 0}
You are going to edit the value in: {otherDirty.join(', ')}
{/if}
{#if current}
{#key current}
{/key}
{/if}