This commit is contained in:
Ruben Fiszel
2023-05-29 16:17:51 +02:00
parent c21c12fb36
commit cbb9e444ea
10 changed files with 73 additions and 9 deletions
@@ -442,6 +442,16 @@
</button>
</div>
<div class="flex flex-row gap-x-4">
<Button
color="light"
variant="border"
size="xs"
on:click={() => {
metadataOpen = true
}}
>
Metadata
</Button>
<Button
color="dark"
variant="border"
+20
View File
@@ -0,0 +1,20 @@
<script lang="ts">
export let text: string
const parseURL = (input) => {
if (input.startsWith('http://') || input.startsWith('https://')) {
return `<a href="${input}" target="_blank" rel="noopener noreferrer">${input}</a>`
} else {
return input
}
}
const parseInput = (input) => {
if (!input) return ''
const words = input.split(' ')
return words.map((word) => parseURL(word)).join(' ')
}
$: parsed = text ? text.split('\n').map(parseInput).join('\n') : ''
</script>
{@html parsed}
@@ -31,7 +31,7 @@
<div class="py-1">
{#each $userWorkspaces as workspace}
<button
class="text-xs min-w-0 w-full flex flex-col py-1.5
class="text-xs min-w-0 w-full overflow-hidden flex flex-col py-1.5
{$workspaceStore === workspace.id
? 'cursor-default bg-blue-50'
: 'cursor-pointer hover:bg-gray-100'}"
+1 -1
View File
@@ -16,7 +16,7 @@ export interface UserExt {
folders_owners: string[]
}
let persistedWorkspace = BROWSER && localStorage.getItem('workspace')
const persistedWorkspace = BROWSER && localStorage.getItem('workspace')
export const enterpriseLicense = writable<string | undefined>(undefined)
export const workerTags = writable<string[] | undefined>(undefined)
+13
View File
@@ -19,6 +19,19 @@ export function validateUsername(username: string): string {
}
}
export function parseQueryParams(url: string | undefined) {
if (!url) return {}
const index = url.indexOf('?')
if (index == -1) return {}
const paramArr = url?.slice(index + 1)?.split('&')
const params: Record<string, string> = {}
paramArr?.map((param) => {
const [key, val] = param.split('=')
params[key] = decodeURIComponent(val)
})
return params
}
export function isToday(someDate: Date): boolean {
const today = new Date()
return (
@@ -40,6 +40,7 @@
import Icon from 'svelte-awesome'
import { slide } from 'svelte/transition'
import { sendUserToast } from '$lib/toast'
import Urlize from '$lib/components/Urlize.svelte'
let userSettings: UserSettings
@@ -308,8 +309,8 @@
/>
</div>
{#if !emptyString(flow.description)}
<div class="box">
{defaultIfEmptyString(flow.description, 'No description')}
<div class="box overflow-auto break-words whitespace-pre-wrap">
<Urlize text={defaultIfEmptyString(flow.description, 'No description')} />
</div>
{/if}
</div>
@@ -55,6 +55,7 @@
} from '$lib/consts'
import { sendUserToast } from '$lib/toast'
import { scriptToHubUrl } from '$lib/hub'
import Urlize from '$lib/components/Urlize.svelte'
let userSettings: UserSettings
let script: Script | undefined
@@ -411,8 +412,8 @@
/>
</div>
{#if !emptyString(script.description)}
<div class="box">
{defaultIfEmptyString(script.description, 'No description')}
<div class="box overflow-auto break-words whitespace-pre-wrap">
<Urlize text={defaultIfEmptyString(script.description, 'No description')} />
</div>
{/if}
</div>
@@ -5,7 +5,7 @@
import { onMount } from 'svelte'
import { OauthService, SettingsService, UserService, WorkspaceService } from '$lib/gen'
import { clearStores, usersWorkspaceStore, workspaceStore, userStore } from '$lib/stores'
import { classNames } from '$lib/utils'
import { classNames, parseQueryParams } from '$lib/utils'
import { getUserExt } from '$lib/user'
import { Button, Skeleton } from '$lib/components/common'
import { WindmillIcon } from '$lib/components/icons'
@@ -85,12 +85,21 @@
if ($workspaceStore) {
goto(rd ?? '/')
} else {
let workspaceTarget = parseQueryParams(rd ?? undefined)['workspace']
if (rd && workspaceTarget) {
$workspaceStore = workspaceTarget
goto(rd)
return
}
if (!$usersWorkspaceStore) {
try {
usersWorkspaceStore.set(await WorkspaceService.listUserWorkspaces())
} catch {}
}
const allWorkspaces = $usersWorkspaceStore?.workspaces
if (allWorkspaces?.length == 1) {
$workspaceStore = allWorkspaces[0].id
goto('/')
@@ -49,7 +49,8 @@
}
if ($usersWorkspaceStore) {
if (!$workspaceStore) {
switchWorkspace(localStorage.getItem('workspace')?.toString())
const local = localStorage.getItem('workspace')?.toString()
switchWorkspace(local)
}
} else {
const url = $page.url
@@ -63,13 +64,14 @@
})
}
$: {
function handleListWorkspaces() {
if (list_all_as_super_admin) {
loadWorkspacesAsAdmin()
} else {
workspaces = $userWorkspaces
}
}
$: list_all_as_super_admin != undefined && handleListWorkspaces()
$: adminsInstance = workspaces?.find((x) => x.id == 'admins')
@@ -10,6 +10,7 @@
import { getUserExt } from '$lib/user'
import { logoutWithRedirect } from '$lib/logout'
import WindmillIcon from '$lib/components/icons/WindmillIcon.svelte'
import { parseQueryParams } from '$lib/utils'
let error = $page.url.searchParams.get('error')
let clientName = $page.params.client_name
@@ -40,6 +41,13 @@
$userStore = await getUserExt($workspaceStore)
goto(rd ?? '/')
} else {
let workspaceTarget = parseQueryParams(rd ?? undefined)['workspace']
if (rd && workspaceTarget) {
$workspaceStore = workspaceTarget
goto(rd)
return
}
if (!$usersWorkspaceStore) {
try {
usersWorkspaceStore.set(await WorkspaceService.listUserWorkspaces())