Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PayloadDecoder #1651

Merged
merged 22 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
282e9a9
Fix prettier and update to eslint-plugin-svelte (#1621)
rossedfort Sep 13, 2023
bb0d798
Add codefreeze branch regex to actions (#1636)
Alex-Tideman Sep 13, 2023
777cdc9
CodeMirror for CodeBlock (#1635)
Alex-Tideman Sep 13, 2023
b05d922
WIP: get decoding working on expand
Alex-Tideman Sep 14, 2023
c98291c
Show the full payloadable, add to input and results
Alex-Tideman Sep 26, 2023
3604b17
Clean up all the functions
Alex-Tideman Sep 26, 2023
b517d79
Merge conflicts
Alex-Tideman Sep 26, 2023
e86d88a
Merge branch 'main' into decodable-code-block
Alex-Tideman Oct 2, 2023
ee39a86
Use onMount instead
Alex-Tideman Oct 2, 2023
282a9d2
Fix merge conflicts
Alex-Tideman Oct 4, 2023
acab2da
Try to check the hash
Alex-Tideman Oct 6, 2023
71ac142
Remove blakejs
Alex-Tideman Oct 9, 2023
7a70f9d
Add cloneAllPotentialPayloadsWithCodec fn
Alex-Tideman Oct 11, 2023
fc9bbdf
Show null values
Alex-Tideman Oct 11, 2023
de53cbb
Merge branch 'main' into decodable-code-block
Alex-Tideman Oct 13, 2023
4b644a2
Delete all the port code, fix all tests and types and linting
Alex-Tideman Oct 13, 2023
9547426
Remove console.log
Alex-Tideman Oct 13, 2023
0c33e65
Don't add check, always use payloads key
Alex-Tideman Oct 13, 2023
26942d8
Remove console.log and add key block on json navigator
Alex-Tideman Oct 13, 2023
faba28d
Remove port test
Alex-Tideman Oct 13, 2023
509294c
Refactor fetchAllEvents to the workflow-history-layout. Fix timeline …
Alex-Tideman Oct 16, 2023
9c131ef
Add back loading check for empty row
Alex-Tideman Oct 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions src/lib/components/codec-endpoint-settings.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,3 @@
{/if}
</div>
</div>

<style lang="postcss">
.error {
@apply outline-red-700;
}
</style>
14 changes: 0 additions & 14 deletions src/lib/components/data-converter-port-settings.svelte

This file was deleted.

6 changes: 0 additions & 6 deletions src/lib/components/data-encoder-settings.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import Link from '$lib/holocene/link.svelte';
import { clickOutside } from '$lib/holocene/outside-click';
import { translate } from '$lib/i18n/translate';
import { dataConverterPort } from '$lib/stores/data-converter-config';
import {
codecEndpoint,
includeCredentials,
Expand All @@ -20,7 +19,6 @@
import { validateHttpOrHttps, validateHttps } from '$lib/utilities/is-http';

import CodecEndpointSettings from './codec-endpoint-settings.svelte';
import DataConverterPortSettings from './data-converter-port-settings.svelte';

export const viewDataEncoderSettings = writable<boolean>(false);
</script>
Expand All @@ -30,7 +28,6 @@
import RadioInput from '$lib/holocene/radio-input/radio-input.svelte';

let endpoint = $codecEndpoint ?? '';
let port = $dataConverterPort ?? '';
let passToken = $passAccessToken ?? false;
let includeCreds = $includeCredentials ?? false;
let override = writable($overrideRemoteCodecConfiguration);
Expand All @@ -56,7 +53,6 @@

const onCancel = () => {
endpoint = $codecEndpoint;
port = $dataConverterPort;
passToken = $passAccessToken;
includeCreds = $includeCredentials;
$override = $overrideRemoteCodecConfiguration;
Expand All @@ -68,7 +64,6 @@
$codecEndpoint = endpoint;
$passAccessToken = passToken;
$includeCredentials = includeCreds;
$dataConverterPort = port;
$viewDataEncoderSettings = false;
$overrideRemoteCodecConfiguration = $override;

Expand Down Expand Up @@ -139,7 +134,6 @@
bind:includeCreds
{error}
/>
<DataConverterPortSettings bind:port />
<div class="flex items-center gap-4">
<Button
disabled={Boolean(error)}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/data-encoder-status.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</script>

<div class="mx-1 flex items-center">
{#if $dataEncoder?.hasEndpointOrPortConfigured}
{#if $dataEncoder?.endpoint}
{#if $dataEncoder?.hasNotRequested}
<Tooltip
bottomRight
Expand Down
30 changes: 23 additions & 7 deletions src/lib/components/event/event-details-row-expanded.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
routeForTaskQueue,
} from '$lib/utilities/route-for';

import PayloadDecoder from './payload-decoder.svelte';

export let key: string;
export let value: string | Record<string, unknown>;
export let attributes: CombinedAttributes;
Expand All @@ -38,13 +40,27 @@
>
<div class="flex flex-col {stackTrace ? 'lg:w-1/2' : ''}">
<p class="text-sm">{format(key)}</p>
<CodeBlock
content={codeBlockValue}
class="h-auto {stackTrace ? 'mb-2' : ''} max-h-96 overflow-auto"
{inline}
copyIconTitle={translate('copy-icon-title')}
copySuccessIconTitle={translate('copy-success-icon-title')}
/>
{#if value?.payloads}
<PayloadDecoder {value} key="payloads" let:decodedValue>
<CodeBlock
content={decodedValue}
class="h-auto {stackTrace ? 'mb-2' : ''} max-h-96 overflow-auto"
{inline}
copyIconTitle={translate('copy-icon-title')}
copySuccessIconTitle={translate('copy-success-icon-title')}
/>
</PayloadDecoder>
{:else}
<PayloadDecoder value={codeBlockValue} let:decodedValue>
<CodeBlock
content={decodedValue}
class="h-auto {stackTrace ? 'mb-2' : ''} max-h-96 overflow-auto"
{inline}
copyIconTitle={translate('copy-icon-title')}
copySuccessIconTitle={translate('copy-success-icon-title')}
/>
</PayloadDecoder>
{/if}
</div>
{#if stackTrace && !inline}
<div class="flex flex-col lg:w-1/2">
Expand Down
20 changes: 12 additions & 8 deletions src/lib/components/event/event-details-row.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import Copyable from '$lib/holocene/copyable/index.svelte';
import Link from '$lib/holocene/link.svelte';
import { translate } from '$lib/i18n/translate';
import type { Payloads } from '$lib/types';
import { format } from '$lib/utilities/format-camel-case';
import type { CombinedAttributes } from '$lib/utilities/format-event-attributes';
import {
getCodeBlockValue,
shouldDisplayAsExecutionLink,
shouldDisplayAsPlainText,
shouldDisplayAsTaskQueueLink,
Expand All @@ -19,8 +19,10 @@
routeForTaskQueue,
} from '$lib/utilities/route-for';

import PayloadDecoder from './payload-decoder.svelte';

export let key: string;
export let value: string | Record<string, unknown>;
export let value: string | Record<string, unknown> | Payloads;
export let attributes: CombinedAttributes;
export let inline = false;

Expand All @@ -37,12 +39,14 @@
<p class="min-w-fit text-sm">
{format(key)}
</p>
<CodeBlock
content={getCodeBlockValue(value)}
{inline}
copyIconTitle={translate('copy-icon-title')}
copySuccessIconTitle={translate('copy-success-icon-title')}
/>
<PayloadDecoder {value} key="payloads" let:decodedValue>
<CodeBlock
content={decodedValue}
{inline}
copyIconTitle={translate('copy-icon-title')}
copySuccessIconTitle={translate('copy-success-icon-title')}
/>
</PayloadDecoder>
</div>
{:else if shouldDisplayAsExecutionLink(key)}
<div class="flex w-full flex-wrap items-center gap-1 pr-1">
Expand Down
26 changes: 18 additions & 8 deletions src/lib/components/event/event-history-timeline.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import Accordion from '$lib/holocene/accordion.svelte';
import Icon from '$lib/holocene/icon/icon.svelte';
import Loading from '$lib/holocene/loading.svelte';
import ToggleButton from '$lib/holocene/toggle-button/toggle-button.svelte';
import ToggleButtons from '$lib/holocene/toggle-button/toggle-buttons.svelte';
import { translate } from '$lib/i18n/translate';
Expand Down Expand Up @@ -197,12 +198,17 @@
$workflowRun.workflow &&
history.length &&
visualizationRef;

const drawTimeline = () => {
if (timeline) {
timeline.destroy();
}
buildTimeline(category);
};

$: {
if (readyToDraw) {
if (timeline) {
timeline.destroy();
}
buildTimeline(category);
drawTimeline();
}
}
</script>
Expand All @@ -221,20 +227,24 @@
<ToggleButtons>
<ToggleButton
data-testid="zoom-in"
on:click={() => timeline.zoomIn(1)}>+</ToggleButton
on:click={() => timeline?.zoomIn(1)}>+</ToggleButton
>
<ToggleButton
data-testid="zoom-in"
on:click={() => timeline.zoomOut(1)}>-</ToggleButton
on:click={() => timeline?.zoomOut(1)}>-</ToggleButton
>
<ToggleButton
data-testid="zoom-in"
on:click={() => timeline.focus('workflow')}>Fit</ToggleButton
on:click={() => timeline?.focus('workflow')}>Fit</ToggleButton
>
</ToggleButtons>
</div>
</div>
<div class="timeline" bind:this={visualizationRef} />
<div class="timeline" bind:this={visualizationRef}>
{#if !timeline}
<Loading title="Building Timeline..." />
{/if}
</div>
</div>
</Accordion>

Expand Down
43 changes: 2 additions & 41 deletions src/lib/components/event/event-summary.svelte
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
<script lang="ts">
import { page } from '$app/stores';

import EventSummaryRow from '$lib/components/event/event-summary-row.svelte';
import EventSummaryTable from '$lib/components/event/event-summary-table.svelte';
import Pagination from '$lib/holocene/pagination.svelte';
import { translate } from '$lib/i18n/translate';
import { groupEvents } from '$lib/models/event-groups';
import { CATEGORIES } from '$lib/models/event-history/get-event-categorization';
import { fetchAllEvents } from '$lib/services/events-service';
import { authUser } from '$lib/stores/auth-user';
import {
eventFilterSort,
type EventSortOrder,
expandAllEvents,
} from '$lib/stores/event-view';
import { eventFilterSort, expandAllEvents } from '$lib/stores/event-view';
import { eventHistory, fullEventHistory } from '$lib/stores/events';
import { eventCategoryFilter } from '$lib/stores/filters';
import { refresh } from '$lib/stores/workflow-run';
import type {
CommonHistoryEvent,
EventTypeCategory,
Expand All @@ -28,36 +19,6 @@

export let compact = false;

$: ({ namespace, workflow: workflowId, run: runId } = $page.params);

let loading = true;

const resetFullHistory = () => {
$fullEventHistory = [];
loading = true;
};

const fetchEvents = async (
namespace: string,
workflowId: string,
runId: string,
sort: EventSortOrder,
) => {
const { settings } = $page.data;
resetFullHistory();
$fullEventHistory = await fetchAllEvents({
namespace,
workflowId,
runId,
settings,
accessToken: $authUser?.accessToken,
sort: compact ? 'ascending' : sort,
});
loading = false;
};

$: $refresh, fetchEvents(namespace, workflowId, runId, $eventFilterSort);

function handleExpandChange(event: CustomEvent) {
$expandAllEvents = event.detail.expanded;
}
Expand Down Expand Up @@ -116,7 +77,7 @@
onRowClick={() => setActiveRowIndex(index)}
/>
{:else}
<EventEmptyRow {loading} />
<EventEmptyRow loading={!intialEvents.length} />
{/each}
</EventSummaryTable>
</Pagination>
65 changes: 65 additions & 0 deletions src/lib/components/event/payload-decoder.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<script lang="ts">
import { onMount } from 'svelte';

import { page } from '$app/stores';

import { authUser } from '$lib/stores/auth-user';
import type { EventAttribute, WorkflowEvent } from '$lib/types/events';
import {
cloneAllPotentialPayloadsWithCodec,
decodePayloadAttributes,
type PotentiallyDecodable,
} from '$lib/utilities/decode-payload';
import {
getCodecEndpoint,
getCodecIncludeCredentials,
getCodecPassAccessToken,
} from '$lib/utilities/get-codec';
import { stringifyWithBigInt } from '$lib/utilities/parse-with-big-int';

export let value: PotentiallyDecodable | EventAttribute | WorkflowEvent;
export let key = '';

$: endpoint = getCodecEndpoint($page.data.settings);
$: passAccessToken = getCodecPassAccessToken($page.data.settings);
$: includeCredentials = getCodecIncludeCredentials($page.data.settings);
$: settings = {
...$page.data.settings,
codec: {
...$page.data.settings?.codec,
endpoint,
passAccessToken,
includeCredentials,
},
};

const decodePayloads = async () => {
try {
const convertedAttributes = await cloneAllPotentialPayloadsWithCodec(
value,
$page.params.namespace,
settings,
$authUser.accessToken,
);
const decodedAttributes = decodePayloadAttributes(
convertedAttributes,
) as object;
const keyExists = key && decodedAttributes?.[key];
if (keyExists) {
decodedValue = stringifyWithBigInt(keyExists);
} else {
decodedValue = stringifyWithBigInt(decodedAttributes);
}
} catch (e) {
return stringifyWithBigInt(value);
}
};

onMount(() => {
decodePayloads();
});

let decodedValue = '';
</script>

<slot {decodedValue} />
12 changes: 3 additions & 9 deletions src/lib/components/import/event-history-file-import.svelte
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
<script lang="ts">
import { goto } from '$app/navigation';
import { page } from '$app/stores';

import Button from '$lib/holocene/button.svelte';
import { translate } from '$lib/i18n/translate';
import { groupEvents } from '$lib/models/event-groups';
import { toEventHistory } from '$lib/models/event-history';
import { authUser } from '$lib/stores/auth-user';
import { importEventGroups, importEvents } from '$lib/stores/import-events';
import { lastUsedNamespace } from '$lib/stores/namespaces';
import { toaster } from '$lib/stores/toaster';
Expand Down Expand Up @@ -40,14 +38,10 @@
};

const onConfirm = async () => {
const { settings } = $page.data;
try {
const events = await toEventHistory({
response: Array.isArray(rawEvents) ? rawEvents : rawEvents?.events,
namespace: $lastUsedNamespace,
settings,
accessToken: $authUser.accessToken,
});
const events = await toEventHistory(
Array.isArray(rawEvents) ? rawEvents : rawEvents?.events,
);
const eventGroups = groupEvents(events);
importEvents.set(events);
importEventGroups.set(eventGroups);
Expand Down
Loading
Loading