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

Dt 1142 deep linking activities #1659

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
715dad9
stopping point
GraceGardner Aug 3, 2023
2531ca8
update environment
GraceGardner Aug 4, 2023
4dc9da7
stop
GraceGardner Aug 7, 2023
54a1bb3
merge main
GraceGardner Aug 31, 2023
ac925a7
WIP
GraceGardner Aug 31, 2023
159d947
really bad code
GraceGardner Sep 12, 2023
7f404b4
Use goto to scroll
Alex-Tideman Sep 12, 2023
b63c4df
Merge branch 'main' into DT-1142-deep-linking-activities
Alex-Tideman Sep 12, 2023
ae5dc7c
stop
GraceGardner Sep 28, 2023
2848bd1
pull
GraceGardner Sep 28, 2023
94e4a1f
merge main
GraceGardner Sep 28, 2023
c78dd60
rm break
GraceGardner Sep 28, 2023
079593d
remove store from things
GraceGardner Oct 2, 2023
ccb46ae
format
GraceGardner Oct 2, 2023
0d88875
remove hash if target doesn't exist in event history
GraceGardner Oct 3, 2023
e011fca
add handlePageChange to bottom pagination buttons
GraceGardner Oct 3, 2023
bf59034
Add "Not equal to" option to Text filter search (#1652)
laurakwhit Sep 28, 2023
d90815b
Update Copyable UI (#1656)
laurakwhit Oct 2, 2023
3711ea3
Add single quote eslint rule (#1660)
laurakwhit Oct 2, 2023
e947ab2
Timeline Improvements (#1658)
Alex-Tideman Oct 3, 2023
199b611
Fix Input and Results CodeBlock overflow (#1663)
laurakwhit Oct 3, 2023
795e8d1
Make TimezoneSelect position responsive based on screen width (#1664)
laurakwhit Oct 4, 2023
4de13b9
Add aria-hidden to Icon component if no title provided (#1662)
laurakwhit Oct 4, 2023
d304ee8
The Great Cypress Delete (#1666)
Alex-Tideman Oct 4, 2023
756a01a
2.18.9 (#1665)
Alex-Tideman Oct 4, 2023
426ebd4
Fix query param types
Alex-Tideman Oct 4, 2023
9f9c5af
Merge branch 'main' into DT-1142-deep-linking-activities
Alex-Tideman Oct 4, 2023
7b0f036
Remove exposing store in slot
Alex-Tideman Oct 4, 2023
05f3fbd
Add timeout on timeline fit if hash exists
Alex-Tideman Oct 4, 2023
a5e4a00
pull
GraceGardner Oct 5, 2023
4448344
fix ts issues
GraceGardner Oct 12, 2023
d98f72c
main
GraceGardner Oct 12, 2023
ebc1723
merge main
GraceGardner Oct 12, 2023
8ff4fad
add handleclick function to group details
GraceGardner Oct 13, 2023
feb909f
add back store
GraceGardner Oct 13, 2023
1028c77
Remove unused values and bump timeout
Alex-Tideman Oct 13, 2023
6733a68
set expanded onmount
GraceGardner 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
26 changes: 24 additions & 2 deletions src/lib/components/event/event-group-details.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<script lang="ts">
import { goto } from '$app/navigation';
import { page } from '$app/stores';

import Table from '$lib/holocene/table/table.svelte';
import type { EventGroup } from '$lib/models/event-groups/event-groups';
import {
Expand All @@ -7,10 +10,27 @@
eventOrGroupIsTerminated,
} from '$lib/models/event-groups/get-event-in-group';
import { isLocalActivityMarkerEvent } from '$lib/utilities/is-event-type';
import { routeForEventHistory } from '$lib/utilities/route-for';

export let eventGroup: EventGroup;
export let selectedId: string;
export let onGroupClick: (id: string) => void;

const handleGroupClick = (id: string) => {
const { namespace, workflow, run } = $page.params;
Copy link
Member

Choose a reason for hiding this comment

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

We can probably just store these variables in the top-level instead of fetching them every time.

const queryParams: Record<string, string> = {};
$page.url.searchParams.forEach((value, key) => {
Copy link
Member

Choose a reason for hiding this comment

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

Why not just use a reduce? This can probably be broken out into a utility function and unit tested. Now that I think about it, that's probably true for this entire function.

queryParams[key] = value;
});
const route = routeForEventHistory({
queryParams,
namespace,
workflow,
run,
});
goto(`${route}#${id}`, { noScroll: true });
onGroupClick(id);
};
</script>

<div class="w-full border-gray-700 lg:w-1/3 lg:border-r-2">
Expand All @@ -22,11 +42,13 @@
class:failure={eventOrGroupIsFailureOrTimedOut(eventInGroup)}
class:canceled={eventOrGroupIsCanceled(eventInGroup)}
class:terminated={eventOrGroupIsTerminated(eventInGroup)}
on:click|preventDefault|stopPropagation={() => onGroupClick(id)}
on:click|preventDefault|stopPropagation={() => handleGroupClick(id)}
>
<td class="w-1/12" />
<td class="w-24">
<p class="truncate text-sm text-gray-500 md:text-base">{id}</p>
<p class="truncate text-sm text-gray-500 md:text-base">
{id}
</p>
</td>
<td>
<p class="event-type truncate text-sm md:text-base">
Expand Down
11 changes: 10 additions & 1 deletion src/lib/components/event/event-history-timeline.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import { onMount } from 'svelte';
import { DataSet, Timeline } from 'vis-timeline/standalone';

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

import Accordion from '$lib/holocene/accordion.svelte';
import Icon from '$lib/holocene/icon/icon.svelte';
import ToggleButton from '$lib/holocene/toggle-button/toggle-button.svelte';
Expand Down Expand Up @@ -150,7 +152,14 @@
): void => {
timeline.setGroups(groups);
timeline.setItems(items);
timeline.fit();

if ($page.url.hash) {
setTimeout(() => {
Copy link
Member

Choose a reason for hiding this comment

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

Why are we using a setTimeout here?

timeline.fit();
}, 2000);
} else {
timeline.fit();
}
};

const filterHistory = (
Expand Down
28 changes: 25 additions & 3 deletions src/lib/components/event/event-summary-row.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<script lang="ts">
import { noop } from 'svelte/internal';
import { noop, onMount } from 'svelte/internal';
import { fade } from 'svelte/transition';

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

import Icon from '$lib/holocene/icon/icon.svelte';
import Link from '$lib/holocene/link.svelte';
import { isEventGroup } from '$lib/models/event-groups';
Expand All @@ -18,6 +21,7 @@
import { formatDistanceAbbreviated } from '$lib/utilities/format-time';
import { getSingleAttributeForEvent } from '$lib/utilities/get-single-attribute-for-event';
import { isLocalActivityMarkerEvent } from '$lib/utilities/is-event-type';
import { routeForEventHistory } from '$lib/utilities/route-for';

import EventDetailsFull from './event-details-full.svelte';
import EventDetailsRow from './event-details-row.svelte';
Expand All @@ -30,11 +34,16 @@
export let active = false;
export let onRowClick: () => void = noop;

onMount(() => {
const hash = $page.url.hash;
if (`#${event.id}` === hash && !expanded) expanded = true;
});

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

$: expanded = expandAll || active;
$: expanded = expandAll;

$: descending = $eventFilterSort === 'descending';
$: showElapsed = $eventShowElapsed === 'true';
Expand All @@ -61,6 +70,19 @@

const onLinkClick = () => {
expanded = !expanded;
// Dont delete query params like ?per-page
const { namespace, workflow, run } = $page.params;
const queryParams: Record<string, string> = {};
Copy link
Member

Choose a reason for hiding this comment

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

Yea, if we're doing this more than once, then we should definitely break it out.

$page.url.searchParams.forEach((value, key) => {
queryParams[key] = value;
});
const route = routeForEventHistory({
queryParams,
namespace,
workflow,
run,
});
goto(`${route}#${event.id}`, { noScroll: true });
onRowClick();
};

Expand All @@ -79,7 +101,7 @@
class:terminated
class:typedError
data-testid="event-summary-row"
on:click|stopPropagation={onLinkClick}
on:click|preventDefault|stopPropagation={onLinkClick}
>
<td />
<td class="w-24 text-left">
Expand Down
25 changes: 24 additions & 1 deletion src/lib/components/event/event-summary.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<script lang="ts">
import { onMount } from 'svelte';

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

import EventSummaryRow from '$lib/components/event/event-summary-row.svelte';
Expand Down Expand Up @@ -31,12 +34,29 @@
$: ({ namespace, workflow: workflowId, run: runId } = $page.params);

let loading = true;
let hash = '';

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

onMount(() => {
hash = $page.url.hash;
});

function scrollIntoView(target, eventHistory) {
Copy link
Member

Choose a reason for hiding this comment

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

This should be broken out.

if (parseInt(target) > eventHistory.length) {
window.location.hash = '';
return;
}
const element = document.getElementById(target);
if (!element) return;
goto(`${$page.url}`, { noScroll: true }).then(() => {
element.scrollIntoView({ behavior: 'smooth', block: 'center' });
});
}

const fetchEvents = async (
namespace: string,
workflowId: string,
Expand All @@ -54,6 +74,9 @@
sort: compact ? 'ascending' : sort,
});
loading = false;
setTimeout(() => {
Copy link
Member

Choose a reason for hiding this comment

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

The setTimeout here feels a little bit like a code smell.

scrollIntoView(hash.slice(1), $fullEventHistory);
}, 50);
};

$: $refresh, fetchEvents(namespace, workflowId, runId, $eventFilterSort);
Expand Down Expand Up @@ -112,7 +135,7 @@
{compact}
expandAll={$expandAllEvents === 'true'}
{initialItem}
active={activeRowIndex === index}
active={activeRowIndex === index || event.id === hash.slice(1)}
onRowClick={() => setActiveRowIndex(index)}
/>
{:else}
Expand Down
12 changes: 10 additions & 2 deletions src/lib/holocene/pagination.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
$: floatStyle = getFloatStyle({ width, height, screenWidth });

async function handleKeydown(event: KeyboardEvent) {
console.log(event);
switch (event.code) {
case 'ArrowRight':
case 'KeyL':
Expand Down Expand Up @@ -206,6 +207,7 @@
initialItem={$store.initialItem}
activeRowIndex={$store.activeRowIndex}
setActiveRowIndex={store.setActiveRowIndex}
store={$store}
/>
<nav
class={`flex ${
Expand All @@ -228,7 +230,10 @@
<button
class="caret"
disabled={!$store.hasPrevious}
on:click={() => store.previous()}
on:click={() => {
store.previous();
handlePageChange();
}}
aria-label={previousButtonLabel}
>
<span
Expand All @@ -247,7 +252,10 @@
<button
class="caret"
disabled={!$store.hasNext}
on:click={() => store.next()}
on:click={() => {
store.next();
handlePageChange();
}}
aria-label={nextButtonLabel}
>
<span
Expand Down
Loading