mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-25 08:00:59 +00:00
give public app badges
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import Highlight from 'svelte-highlight'
|
||||
import Highlight, { LineNumbers } from 'svelte-highlight'
|
||||
import python from 'svelte-highlight/languages/python'
|
||||
import typescript from 'svelte-highlight/languages/typescript'
|
||||
import go from 'svelte-highlight/languages/go'
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
export let code: string = ''
|
||||
export let language: 'python3' | 'deno' | 'go' | 'bash' | undefined
|
||||
export let lines = false
|
||||
|
||||
function getLang(lang: string | undefined) {
|
||||
switch (lang) {
|
||||
@@ -27,7 +28,13 @@
|
||||
</script>
|
||||
|
||||
{#if code?.length < 5000}
|
||||
<Highlight class="nowrap {$$props.class}" language={lang} {code} />
|
||||
{#if !lines}
|
||||
<Highlight class="nowrap {$$props.class}" language={lang} {code} />
|
||||
{:else}
|
||||
<Highlight class="nowrap {$$props.class}" language={lang} {code} let:highlighted>
|
||||
<LineNumbers {highlighted} />
|
||||
</Highlight>
|
||||
{/if}
|
||||
{:else}
|
||||
<pre class="overflow-auto max-h-screen {$$props.class}"
|
||||
><code class="language-{language}">{code}</code></pre
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
resizeWindow()
|
||||
|
||||
const parentWidth = writable(0)
|
||||
|
||||
const state = writable({})
|
||||
setContext<AppViewerContext>('AppViewerContext', {
|
||||
worldStore: buildWorld(ncontext),
|
||||
initialized: writable({ initialized: false, initializedComponents: [] }),
|
||||
@@ -86,7 +86,7 @@
|
||||
focusedGrid: writable(undefined),
|
||||
stateId: writable(0),
|
||||
parentWidth,
|
||||
state: writable({}),
|
||||
state: state,
|
||||
componentControl: writable({}),
|
||||
hoverStore: writable(undefined),
|
||||
allIdsInPath
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
import {
|
||||
faCodeFork,
|
||||
faEdit,
|
||||
faExternalLink,
|
||||
faEye,
|
||||
faFileExport,
|
||||
faPen,
|
||||
@@ -18,6 +19,10 @@
|
||||
import Button from '../button/Button.svelte'
|
||||
import Row from './Row.svelte'
|
||||
import DraftBadge from '$lib/components/DraftBadge.svelte'
|
||||
import Badge from '../badge/Badge.svelte'
|
||||
import { Eye } from 'lucide-svelte'
|
||||
import { goto } from '$app/navigation'
|
||||
import { page } from '$app/stores'
|
||||
|
||||
export let app: ListableApp & { has_draft?: boolean; draft_only?: boolean; canWrite: boolean }
|
||||
export let marked: string | undefined
|
||||
@@ -26,7 +31,16 @@
|
||||
export let moveDrawer: MoveDrawer
|
||||
export let deleteConfirmedCallback: (() => void) | undefined
|
||||
|
||||
let { summary, path, extra_perms, canWrite, workspace_id, has_draft, draft_only } = app
|
||||
let {
|
||||
summary,
|
||||
path,
|
||||
extra_perms,
|
||||
canWrite,
|
||||
workspace_id,
|
||||
has_draft,
|
||||
draft_only,
|
||||
execution_mode
|
||||
} = app
|
||||
|
||||
const dispatch = createEventDispatcher()
|
||||
</script>
|
||||
@@ -44,7 +58,14 @@
|
||||
>
|
||||
<svelte:fragment slot="badges">
|
||||
<DraftBadge {has_draft} {draft_only} />
|
||||
|
||||
{#if execution_mode == 'anonymous'}
|
||||
<Badge small>
|
||||
<div class="flex gap-1 items-center">
|
||||
<Eye size={14} />
|
||||
Public
|
||||
</div></Badge
|
||||
>
|
||||
{/if}
|
||||
<SharedBadge {canWrite} extraPerms={extra_perms} />
|
||||
</svelte:fragment>
|
||||
<svelte:fragment slot="actions">
|
||||
@@ -143,6 +164,25 @@
|
||||
shareModal.openDrawer && shareModal.openDrawer(path, 'app')
|
||||
}
|
||||
},
|
||||
...(execution_mode == 'anonymous'
|
||||
? [
|
||||
{
|
||||
displayName: 'Go to public page',
|
||||
icon: faExternalLink,
|
||||
action: async () => {
|
||||
let secretUrl = await AppService.getPublicSecretOfApp({
|
||||
workspace: $workspaceStore ?? '',
|
||||
path
|
||||
})
|
||||
let url =
|
||||
$page.url.protocol +
|
||||
'//' +
|
||||
`${$page.url.hostname}/public/${$workspaceStore}/${secretUrl}`
|
||||
goto(url)
|
||||
}
|
||||
}
|
||||
]
|
||||
: []),
|
||||
{
|
||||
displayName: 'Delete',
|
||||
icon: faTrashAlt,
|
||||
|
||||
@@ -338,7 +338,7 @@
|
||||
</div>
|
||||
{:else if viewTab == 'code'}
|
||||
{#if job && 'raw_code' in job && job.raw_code}
|
||||
<HighlightCode language={job.language} code={job.raw_code} />
|
||||
<HighlightCode lines language={job.language} code={job.raw_code} />
|
||||
{:else if job}
|
||||
No code is available
|
||||
{:else}
|
||||
|
||||
Reference in New Issue
Block a user