mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-08 08:04:25 +00:00
feat(frontend): add a way to customise the link's label (#2591)
This commit is contained in:
@@ -3,6 +3,15 @@
|
||||
|
||||
export let type: 'text' | 'badge' | 'link' = 'text'
|
||||
export let value: any
|
||||
|
||||
type LinkObject = {
|
||||
href: string
|
||||
label: string
|
||||
}
|
||||
|
||||
function isLinkObject(value: any): value is LinkObject {
|
||||
return value && typeof value === 'object' && 'href' in value && 'label' in value
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if type === 'badge'}
|
||||
@@ -10,7 +19,13 @@
|
||||
{value}
|
||||
</Badge>
|
||||
{:else if type === 'link'}
|
||||
<a href={value} class="underline" target="_blank">{value}</a>
|
||||
{#if isLinkObject(value)}
|
||||
<a href={value.href} class="underline" target="_blank">
|
||||
{value.label}
|
||||
</a>
|
||||
{:else}
|
||||
<a href={value} class="underline" target="_blank">{value}</a>
|
||||
{/if}
|
||||
{:else}
|
||||
{value}
|
||||
{/if}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { Popup } from '../common'
|
||||
import Alert from '../common/alert/Alert.svelte'
|
||||
import Label from '../Label.svelte'
|
||||
import Toggle from '../Toggle.svelte'
|
||||
import Tooltip from '../Tooltip.svelte'
|
||||
@@ -52,5 +53,20 @@
|
||||
<option value="link">Link</option>
|
||||
</select>
|
||||
</Label>
|
||||
|
||||
{#if column.type === 'link'}
|
||||
<Alert type="info" title="Label" size="xs">
|
||||
They are two ways to define a link:
|
||||
<ul class="list-disc list-inside">
|
||||
<li>
|
||||
<strong>String</strong>: The string will be used as the link and the label.
|
||||
</li>
|
||||
<li>
|
||||
<strong>Object</strong>: The object must have a <code>href</code> and a
|
||||
<code>label</code> property.
|
||||
</li>
|
||||
</ul>
|
||||
</Alert>
|
||||
{/if}
|
||||
</div>
|
||||
</Popup>
|
||||
|
||||
Reference in New Issue
Block a user