display result nits

This commit is contained in:
Ruben Fiszel
2024-03-29 17:08:13 +01:00
parent d7f6adbdd2
commit 387946f536
2 changed files with 24 additions and 40 deletions
@@ -99,6 +99,9 @@
if (result !== undefined) {
if (typeof result === 'string') {
length = 0
largeObject = false
is_render_all = false
return 'plain'
}
try {
@@ -270,7 +273,7 @@
{#if result != undefined && length != undefined && largeObject != undefined}
<div class="flex justify-between items-center w-full pb-1">
<div class="text-tertiary text-sm flex items-center">
{#if (resultKind && !['json', 's3object', 's3object-list', 'table-col', 'table-row'].includes(resultKind) && !hideAsJson) || isTableDisplay}
{#if (resultKind && typeof result == 'object' && !['json', 's3object', 's3object-list', 'table-col', 'table-row'].includes(resultKind) && !hideAsJson) || isTableDisplay}
<ToggleButtonGroup
class="h-6"
selected={isTableDisplay
@@ -306,9 +309,7 @@
<button on:click={jsonViewer.openDrawer}><Expand size={16} /></button>
{/if}
</div>
</div>
{#if !forceJson && resultKind == 'table-col'}
</div>{#if !forceJson && resultKind == 'table-col'}
{@const data = 'table-col' in result ? result['table-col'] : result}
<AutoDataTable objects={transform(data)} />
{:else if !forceJson && resultKind == 'table-row'}
@@ -392,9 +393,19 @@
src="data:image/gif;base64,{contentOrRootString(result.gif)}"
/>
</div>
{:else if !forceJson && resultKind == 'plain'}
<div class="h-full text-2xs">
<pre>{result?.['result']}</pre>
{:else if !forceJson && resultKind == 'plain'}<div class="h-full text-2xs"
><pre>{typeof result == 'string' ? result : result?.['result']}</pre>{#if !noControls}
<div class="flex">
<Button
on:click={() =>
copyToClipboard(typeof result == 'string' ? result : result?.['result'])}
color="light"
size="xs"
>
<div class="flex gap-2 items-center">Copy <ClipboardCopy size={12} /> </div>
</Button>
</div>
{/if}
</div>
{:else if !forceJson && resultKind == 'file'}
<div>
@@ -552,9 +563,7 @@
<ObjectViewer json={result} />
{/if}
{:else if typeof result == 'string' && result.length > 0}
<pre class="text-sm">{result}</pre>
{#if !noControls}
<div class="flex">
<pre class="text-sm">{result}</pre>{#if !noControls}<div class="flex">
<Button on:click={() => copyToClipboard(result)} color="light" size="xs">
<div class="flex gap-2 items-center">Copy <ClipboardCopy size={12} /> </div>
</Button>
@@ -74,41 +74,16 @@
<Pane size={frontendJob ? 70 : 50} minSize={10} class="text-sm text-tertiary">
{#if frontendJob}
<pre class="overflow-x-auto break-words relative h-full px-2"
><DisplayResult result={frontendJob}>
<!-- <svelte:fragment slot="copilot-fix">
{#if lang && editor && diffEditor && stepArgs && testJob?.result?.error}
<ScriptFix
error={JSON.stringify(testJob.result.error)}
{lang}
{editor}
{diffEditor}
args={stepArgs}
/>
{/if}
</svelte:fragment> -->
</DisplayResult>
</pre>
><DisplayResult result={frontendJob} /></pre
>
{:else if testJob != undefined && 'result' in testJob && testJob.result != undefined}
<pre class="overflow-x-auto break-words relative h-full px-2"
><DisplayResult
workspaceId={testJob?.workspace_id}
jobId={testJob?.id}
result={testJob.result}>
<!-- <svelte:fragment slot="copilot-fix">
{#if lang && editor && diffEditor && stepArgs && testJob?.result?.error}
<ScriptFix
error={JSON.stringify(testJob.result.error)}
{lang}
{editor}
{diffEditor}
args={stepArgs}
/>
{/if}
</svelte:fragment> -->
</DisplayResult>
</pre>
result={testJob.result}
/></pre
>
{:else}
<div class="p-2">
{#if testIsLoading}