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

Fix workflow counts and reactive selectedId #2319

Merged
merged 2 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
2 changes: 1 addition & 1 deletion src/lib/components/event/event-summary-row.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
export let active = false;
export let onRowClick: () => void = noop;

let selectedId = isEventGroup(event)
$: selectedId = isEventGroup(event)
? Array.from(event.events.keys()).pop()
: event.id;

Expand Down
40 changes: 33 additions & 7 deletions src/lib/components/workflow/workflow-counts.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,25 @@

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

import Link from '$lib/holocene/link.svelte';
import Skeleton from '$lib/holocene/skeleton/index.svelte';
import { workflowStatuses } from '$lib/models/workflow-status';
import { fetchWorkflowCountByExecutionStatus } from '$lib/services/workflow-counts';
import { workflowFilters } from '$lib/stores/filters';
import { currentPageKey } from '$lib/stores/pagination';
import {
queryWithParentWorkflowId,
refresh,
workflowCount,
} from '$lib/stores/workflows';
import type { WorkflowStatus } from '$lib/types/workflows';
import {
SEARCH_ATTRIBUTE_TYPE,
type WorkflowStatus,
} from '$lib/types/workflows';
import { decodePayload } from '$lib/utilities/decode-payload';
import { toListWorkflowQueryFromFilters } from '$lib/utilities/query/filter-workflow-query';
import { combineFilters } from '$lib/utilities/query/to-list-workflow-filters';
import { getExponentialBackoffSeconds } from '$lib/utilities/refresh-rate';
import { updateQueryParameters } from '$lib/utilities/update-query-parameters';

import WorkflowCountStatus from './workflow-count-status.svelte';

Expand Down Expand Up @@ -116,24 +123,43 @@
}
};

const onStatusClick = (status) => {
const filter = {
attribute: 'ExecutionStatus',
type: SEARCH_ATTRIBUTE_TYPE.KEYWORD,
value: status,
operator: '',
conditional: '=',
parenthesis: '',
};
Comment on lines +127 to +134
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a type or a function to generate this filter?

Copy link
Contributor Author

@Alex-Tideman Alex-Tideman Sep 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function to create a filter is tangled up in the Context for the workflow filter search stuff. But it's typed and would blow up if in the $workflowFilters = [...$workflowFilters, filter] logic

$workflowFilters = [...$workflowFilters, filter];
const searchQuery = toListWorkflowQueryFromFilters(
combineFilters($workflowFilters),
);
updateQueryParameters({
url: $page.url,
parameter: 'query',
value: searchQuery,
allowEmpty: true,
clearParameters: [currentPageKey],
});
};

$: query, namespace, $refresh, fetchCounts();
</script>

<div class="flex min-h-[24px] flex-wrap items-center gap-2">
{#each statusGroups as { count, status } (status)}
{#if !loading}
<Link
href={`/namespaces/${namespace}/workflows?query=%60ExecutionStatus%60%3D"${status}"`}
role="button"
>
<button on:click={() => onStatusClick(status)}>
<WorkflowCountStatus
{status}
{count}
newCount={newStatusGroups.find((g) => g.status === status)
? newStatusGroups.find((g) => g.status === status).count - count
: 0}
/>
</Link>
</button>
{:else}
<Skeleton class="h-6 w-24 rounded" />
{/if}
Expand Down
Loading