fix: export json is converted to pull mode + rd fix

This commit is contained in:
Ruben Fiszel
2022-07-22 21:12:03 +02:00
parent 06e3d10a4f
commit 833cb2ac33
5 changed files with 40 additions and 11 deletions

View File

@@ -1,7 +1,7 @@
<script lang="ts">
import { FlowModuleValue } from '$lib/gen'
import { faFileExport, faFileImport, faPlus } from '@fortawesome/free-solid-svg-icons'
import { faFileExport, faFileImport, faGlobe, faPlus } from '@fortawesome/free-solid-svg-icons'
import Icon from 'svelte-awesome'
import FlowPreview from './FlowPreview.svelte'
import CopyFirstStepSchema from './flows/CopyFirstStepSchema.svelte'
@@ -42,7 +42,9 @@
<button
class="default-button px-4 py-2 font-semibold"
on:click={() => {
$flowStore.value = JSON.parse(jsonValue)
Object.assign($flowStore, JSON.parse(jsonValue))
$flowStore = $flowStore
open = -1
sendUserToast('Flow imported from JSON')
jsonSetter.closeModal()
}}
@@ -83,6 +85,21 @@
action: () => {
jsonViewer.openModal()
}
},
{
displayName: 'Publish to Hub',
icon: faGlobe,
action: () => {
const url = new URL('https://hub.windmill.dev/flows/add')
url.searchParams.append(
'flow',
btoa(JSON.stringify(flowToMode($flowStore, mode).value))
)
url.searchParams.append('schema', btoa(JSON.stringify($flowStore.schema)))
url.searchParams.append('description', $flowStore.description ?? '')
url.searchParams.append('summary', $flowStore.summary)
window.open(url, '_blank')?.focus()
}
}
]}
relative={false}
@@ -93,7 +110,7 @@
bind:error={pathError}
bind:path={$flowStore.path}
{initialPath}
namePlaceholder="example/my/flow"
namePlaceholder="my_flow"
kind="flow"
>
<div slot="ownerToolkit">

View File

@@ -6,12 +6,24 @@
import python from 'svelte-highlight/languages/python'
import typescript from 'svelte-highlight/languages/typescript'
import { FlowModuleValue, type Flow } from '$lib/gen'
import { FlowModuleValue, type FlowValue } from '$lib/gen'
import github from 'svelte-highlight/styles/github'
import { slide } from 'svelte/transition'
import Tabs from './Tabs.svelte'
export let flow: Flow
export let flow: {
summary: string
description?: string
value: FlowValue
schema?: any
}
let flowFiltered = {
summary: flow.summary,
description: flow.description,
value: flow.value,
schema: flow.schema
}
export let embedded = false
@@ -96,5 +108,5 @@
</ul>
</div>
{:else}
<Highlight language={json} code={JSON.stringify(flow.value, null, 4)} />
<Highlight language={json} code={JSON.stringify(flowFiltered, null, 4)} />
{/if}

View File

@@ -47,13 +47,13 @@
}
}
} else {
goto('/user/workspaces')
goto(`/user/workspaces?rd=${encodeURIComponent($page.url.pathname + $page.url.search)}`)
let user = await UserService.globalWhoami()
sendUserToast(`Welcome back ${user.email}`)
}
} catch (e) {
console.error(e)
logoutWithRedirect($page.url.pathname)
logoutWithRedirect($page.url.pathname + $page.url.search)
}
}

View File

@@ -71,7 +71,7 @@
} catch {}
}
if (!$usersWorkspaceStore) {
logoutWithRedirect($page.url.pathname)
logoutWithRedirect($page.url.pathname + $page.url.search)
}
}

View File

@@ -32,7 +32,7 @@
workspaceStore.set(localStorage.getItem('workspace')?.toString())
}
} else {
logoutWithRedirect($page.url.pathname)
logoutWithRedirect($page.url.pathname + $page.url.search)
}
}
@@ -90,7 +90,7 @@
"
on:click={() => {
workspaceStore.set(workspace.id)
goto('/scripts')
goto($page.url.searchParams.get('rd') ?? '/scripts')
}}
><span class="font-mono">{workspace.id}</span> - {workspace.name} as
<span class="font-mono">{workspace.username}</span>