-
-
Notifications
You must be signed in to change notification settings - Fork 507
Add supported stack sort controls to the Svelte UI #2278
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
Open
Copilot
wants to merge
5
commits into
main
Choose a base branch
from
copilot/make-more-columns-sortable
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
640a9cf
Initial plan
Copilot d05b347
Enable stack and session duration column sorting
Copilot f636dfb
Merge remote-tracking branch 'origin/main' into copilot/make-more-col…
niemyjski b6d3929
Fix stack sorting UI contract
niemyjski 6c7a4eb
Fix stack sort test portability
niemyjski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
...ceptionless.Web/ClientApp/src/lib/features/events/components/table/options.svelte.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import type { EventSummaryModel, StackSummaryModel, SummaryTemplateKeys } from '$features/events/components/summary'; | ||
|
|
||
| import { describe, expect, it } from 'vitest'; | ||
|
|
||
| import { getColumns } from './options.svelte'; | ||
|
|
||
| describe('getColumns', () => { | ||
| it('uses dedicated stack-mode controls instead of API sort parameters', () => { | ||
| const result = getColumns<StackSummaryModel<SummaryTemplateKeys>>('stack_frequent'); | ||
| const columnsById = Object.fromEntries(result.map((column) => [column.id, column])); | ||
|
|
||
| expect(columnsById.events?.enableSorting).toBe(false); | ||
| expect(columnsById.first?.enableSorting).toBe(false); | ||
| expect(columnsById.last?.enableSorting).toBe(false); | ||
| expect(columnsById.events?.header).toBeTypeOf('function'); | ||
| expect(columnsById.first?.header).toBeTypeOf('function'); | ||
| expect(columnsById.last?.header).toBeTypeOf('function'); | ||
| }); | ||
|
|
||
| it('keeps summary message column unsortable', () => { | ||
| const result = getColumns<EventSummaryModel<SummaryTemplateKeys>>('summary'); | ||
| const columnsById = Object.fromEntries(result.map((column) => [column.id, column])); | ||
|
|
||
| expect(columnsById.message?.enableSorting).toBe(false); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
...ptionless.Web/ClientApp/src/lib/features/events/components/table/stack-sort-header.svelte
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| <script lang="ts"> | ||
| import { Button } from '$comp/ui/button'; | ||
| import ArrowDown from '@lucide/svelte/icons/arrow-down'; | ||
|
|
||
| interface Props { | ||
| active: boolean; | ||
| label: string; | ||
| onclick: () => void; | ||
| } | ||
|
|
||
| let { active, label, onclick }: Props = $props(); | ||
| </script> | ||
|
|
||
| <Button aria-label={`Sort by ${label} descending`} aria-pressed={active} class="h-8" {onclick} variant="ghost"> | ||
| {label} | ||
| {#if active} | ||
| <ArrowDown aria-hidden="true" /> | ||
| {/if} | ||
| </Button> |
24 changes: 24 additions & 0 deletions
24
...s.Web/ClientApp/src/lib/features/events/components/table/stack-sort-header.svelte.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import { fireEvent, render, screen } from '@testing-library/svelte'; | ||
| import { describe, expect, it, vi } from 'vitest'; | ||
|
|
||
| import StackSortHeader from './stack-sort-header.svelte'; | ||
|
|
||
| describe('StackSortHeader', () => { | ||
| it('exposes the active descending sort and handles selection', async () => { | ||
| const onclick = vi.fn(); | ||
| render(StackSortHeader, { active: true, label: 'Events', onclick }); | ||
|
|
||
| const button = screen.getByRole('button', { name: 'Sort by Events descending' }); | ||
| expect(button.getAttribute('aria-pressed')).toBe('true'); | ||
|
|
||
| await fireEvent.click(button); | ||
|
|
||
| expect(onclick).toHaveBeenCalledOnce(); | ||
| }); | ||
|
|
||
| it('does not mark inactive sort modes as selected', () => { | ||
| render(StackSortHeader, { active: false, label: 'First', onclick: vi.fn() }); | ||
|
|
||
| expect(screen.getByRole('button', { name: 'Sort by First descending' }).getAttribute('aria-pressed')).toBe('false'); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When users click the First header with any time range, this sends
mode=stack_new; the server does not only sort by first occurrence for that mode, it also adds afirst_occurrence:[range]filter inEventController.GetInternalAsyncviaAddFirstOccurrenceFilter, so stacks whose first occurrence predates the current range disappear even if they have matching recent events. A column header presented as sorting the current stack list should not change the result set/count; either avoid exposing this as a sort or use an API mode that preserves all matching stacks.Useful? React with 👍 / 👎.