{#if menuOpen} goto('/schedules')} bind:this={scheduleEditor} /> {/if} {#snippet badges()} {#if script.lock_error_logs} Deployment failed {/if} {#if script.archived} Archived {/if} {#if script.no_main_func && script.kind !== 'preprocessor'} {/if} {#if script.kind !== 'script'} {script.kind === 'failure' ? 'Error handler' : capitalize(script.kind)} {/if} {/snippet} {#snippet actions()} {#if !$userStore?.operator && showEditButton} {#if script.use_codebase} bundleThis script is deployed as a bundle and can only be deployed from the CLI for now {:else if script.canWrite && !script.archived} 0 ? script.summary : script.path}`} aiDescription={`Edits the script ${script.summary?.length > 0 ? script.summary : script.path}`} variant="subtle" wrapperClasses="w-20" unifiedSize="md" startIcon={{ icon: Pen }} href="{base}/scripts/edit/{script.path}" > Edit {:else if !script.draft_only} Fork {/if} {/if} 0 ? script.summary : script.path}`} aiDescription={`Open dropdown for script ${script.summary?.length > 0 ? script.summary : script.path} options`} items={async () => { let owner = isOwner(script.path, $userStore, $workspaceStore) const canEdit = script.canWrite && showEditButton if (script.draft_only) { return [ { displayName: 'View code', icon: Code, action: () => { showCode(script.path, script.summary) } }, { displayName: 'Delete', icon: Trash, action: (event) => { // TODO // @ts-ignore if (event?.shiftKey) { deleteScript(script.path) } else { deleteConfirmedCallback = () => { deleteScript(script.path) } } }, type: dlt, disabled: !canEdit } ] } return [ { displayName: 'View code', icon: Code, action: () => { showCode(script.path, script.summary) } }, { displayName: 'Duplicate/Fork', icon: GitFork, href: `${base}/scripts/add?template=${script.path}`, disabled: !showEditButton, hide: $userStore?.operator }, { displayName: 'Move/Rename', icon: FolderOpen, action: () => { moveDrawer.openDrawer(script.path, script.summary, 'script') }, disabled: !owner || script.archived || !canEdit, hide: $userStore?.operator }, ...(isDeployable('script', script.path, await getDeployUiSettings()) ? [ { displayName: 'Deploy to staging/prod', icon: ChevronUpSquare, action: () => { deploymentDrawer.openDrawer(script.path, 'script') }, disabled: script.archived, hide: $userStore?.operator } ] : []), { displayName: 'View runs', icon: List, href: `${base}/runs/${script.path}` }, { displayName: 'Versions', icon: History, action: () => { versionsDrawerOpen = true } }, { displayName: 'Audit logs', icon: Eye, href: `${base}/audit_logs?resource=${script.path}`, hide: $userStore?.operator }, { displayName: 'Schedule', icon: Calendar, action: () => { scheduleEditor?.openNew(false, script.path) }, disabled: script.archived, hide: $userStore?.operator }, { displayName: owner ? 'Share' : 'See Permissions', icon: Share, action: () => { shareModal.openDrawer && shareModal.openDrawer(script.path, 'script') }, disabled: script.archived, hide: $userStore?.operator }, { displayName: 'Copy path', icon: Copy, action: () => { copyToClipboard(script.path) } }, { displayName: 'Publish to Hub', icon: Globe2, action: async () => { const scriptData = await ScriptService.getScriptByPath({ workspace: $workspaceStore!, path: script.path }) window.open( scriptToHubUrl( scriptData.content, scriptData.summary, scriptData.description ?? '', scriptData.kind, scriptData.language, scriptData.schema, scriptData.lock ?? '', $hubBaseUrlStore ).toString(), '_blank' ) } }, { displayName: script.archived ? 'Unarchive' : 'Archive', icon: Archive, action: () => { script.archived ? script.path && unarchiveScript(script.path) : script.path && archiveScript(script.path) }, type: 'delete', disabled: !owner || !canEdit, hide: $userStore?.operator }, ...(script.has_draft ? [ { displayName: 'Delete Draft', icon: Trash, action: async () => { await DraftService.deleteDraft({ workspace: $workspaceStore ?? '', path: script.path, kind: 'script' }) dispatch('change') }, type: DELETE, disabled: !owner, hide: $userStore?.operator } ] : []), ...($userStore?.is_admin || $userStore?.is_super_admin ? [ { displayName: 'Delete', icon: Trash, action: (event) => { if (event?.shiftKey) { deleteScript(script.path) } else { deleteConfirmedCallback = () => { deleteScript(script.path) } } }, type: dlt, disabled: !canEdit, hide: $userStore?.operator } ] : []) ] }} on:open={() => { menuOpen = true }} /> {/snippet} {#if script} (versionsDrawerOpen = false)}> { if (script) { goto(`/scripts/get/${e.detail.version}?workspace=${$workspaceStore}`) } versionsDrawerOpen = false }} /> {/if}