1
0
mirror of https://github.com/garraflavatra/rolens.git synced 2025-01-18 04:57:59 +00:00

Added copy button to error messages

This commit is contained in:
Romein van Buren 2023-06-23 21:27:55 +02:00
parent 58dd9de4ba
commit a12417d4e9
Signed by: romein
GPG Key ID: 0EFF8478ADDF6C49
3 changed files with 22 additions and 4 deletions

View File

@ -18,7 +18,7 @@
{/if}
<p class="title">{title}</p>
<p>{label}</p>
<p class="label">{label}</p>
<slot />
</div>
@ -38,7 +38,7 @@
height: 150px;
width: auto;
}
.content :global(svg) {
.content > :global(svg) {
height: 40px;
width: auto;
}

View File

@ -1,6 +1,8 @@
<script>
import { onDestroy } from 'svelte';
import BlankState from './blankstate.svelte';
import GridItems from './grid-items.svelte';
import Icon from './icon.svelte';
export let columns = [];
export let items = [];
@ -16,6 +18,17 @@
export let errorTitle = '';
export let errorDescription = '';
export let busy = false;
let copySucceeded = false;
let timeout;
async function copyErrorDescription() {
await navigator.clipboard.writeText(errorDescription);
copySucceeded = true;
timeout = setTimeout(() => copySucceeded = false, 1500);
}
onDestroy(() => clearTimeout(timeout));
</script>
<div class="grid">
@ -33,7 +46,11 @@
{#if busy}
<BlankState label={(busy === true) ? 'Loading…' : busy} icon="loading" />
{:else if errorTitle || errorDescription}
<BlankState title={errorTitle} label={errorDescription} icon="!" />
<BlankState title={errorTitle} label={errorDescription} icon="!">
<button class="button-small" on:click={copyErrorDescription}>
<Icon name={copySucceeded ? 'check' : 'clipboard'} /> Copy error message
</button>
</BlankState>
{:else}
<table>
{#if showHeaders && columns.some(col => col.title)}

View File

@ -61,7 +61,7 @@
}
li {
display: inline-block;
flex-grow: 1;
flex: 1;
position: relative;
}
@ -101,6 +101,7 @@
border-color: #00008b;
cursor: not-allowed;
}
nav.tabs.multiline button.tab .label {
display: block;
margin-top: 4px;