Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit 0bf40cd

Browse files
authored
fix(svelte): Fix and cleanup compare page (#63928)
I just noticed that the revision pickers on the compare page don't work. That's because I made a last minute change to rename the parameter but forgot to acutally update the parameter when constructing the URL. This also makes two additional changes: - Remove `{@debug ...}` expression that was accidentally left in (I feel like Svelte should remove this in prod builds). - Adds a `display` prop to button group, and the rev picker, which works the same as in `Button`. Setting `width: 100%` as done previously causes wrapping on the compare page. I don't think inline elements should be set to 100% width. But without it the button doesn't stretch in the sidebar. This new prop allows the caller to influence this behavior. | Before | After | |--------|--------| | ![2024-07-19_00-59](https://github.com/user-attachments/assets/53b9942d-ebf9-4677-8c65-21cd38e78e44) | ![2024-07-19_01-05](https://github.com/user-attachments/assets/c38ee133-7ee7-4923-ae22-caad9e2472f1) | ## Test plan Tested the compare page and verified that the revision picker stretches in the sidebar.
1 parent dca1b96 commit 0bf40cd

File tree

9 files changed

+27
-24
lines changed

9 files changed

+27
-24
lines changed

client/web-sveltekit/src/lib/Avatar.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
{#if avatarURL}
3333
<img src={avatarURL} role="presentation" aria-hidden="true" alt="Avatar of {name}" data-avatar />
3434
{:else}
35-
<div data-avatar title="{name}">
35+
<div data-avatar title={name}>
3636
<span>{getInitials(name)}</span>
3737
</div>
3838
{/if}

client/web-sveltekit/src/lib/repo/GitReferencesTable.svelte

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@
259259
display: flex;
260260
gap: 0.25rem;
261261
262-
263262
li:not(:first-child)::before {
264263
content: '';
265264
padding-right: 0.25rem;

client/web-sveltekit/src/lib/repo/RepositoryRevPicker.svelte

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,27 @@
4444
4545
import Picker from './Picker.svelte'
4646
import RepositoryRevPickerItem from './RepositoryRevPickerItem.svelte'
47+
import type { ComponentProps } from 'svelte'
4748
4849
type $$Props = HTMLButtonAttributes & {
4950
repoURL: string
5051
revision?: string
5152
commitID?: string
5253
defaultBranch: string
54+
display?: ComponentProps<ButtonGroup>['display']
5355
placement?: Placement
5456
onSelect?: (revision: string) => void
5557
getRepositoryTags: (query: string) => PromiseLike<RepositoryTags>
5658
getRepositoryCommits: (query: string) => PromiseLike<RepositoryCommits>
5759
getRepositoryBranches: (query: string) => PromiseLike<RepositoryBranches>
5860
}
5961
60-
export let repoURL: string
61-
export let revision: string | undefined = undefined
62-
export let commitID: string | undefined = undefined
63-
export let defaultBranch: string
64-
export let placement: Placement = 'right-start'
62+
export let repoURL: $$Props['repoURL']
63+
export let revision: $$Props['revision'] = undefined
64+
export let commitID: $$Props['commitID'] = undefined
65+
export let defaultBranch: $$Props['defaultBranch']
66+
export let placement: $$Props['placement'] = 'right-start'
67+
export let display: $$Props['display'] = undefined
6568
/**
6669
* Optional handler for revision selection.
6770
* If not provided, the default handler will replace the revision in the current URL.
@@ -87,7 +90,7 @@
8790

8891
<Popover let:registerTrigger let:registerTarget let:toggle {placement}>
8992
<span use:registerTarget data-repo-rev-picker-trigger>
90-
<ButtonGroup>
93+
<ButtonGroup {display}>
9194
<button use:registerTrigger class="{buttonClass} rev-name" on:click={() => toggle()} {...$$restProps}>
9295
@{revisionLabel}
9396
</button>
@@ -190,11 +193,6 @@
190193
</Popover>
191194

192195
<style lang="scss">
193-
span[data-repo-rev-picker-trigger] > :global(*) {
194-
width: 100%;
195-
height: 100%;
196-
}
197-
198196
.rev-name {
199197
overflow: hidden;
200198
white-space: nowrap;

client/web-sveltekit/src/lib/wildcard/Button.module.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,10 @@
408408
position: relative;
409409
flex: 1 1 auto;
410410
}
411+
412+
&.btn-block {
413+
display: flex;
414+
}
411415
}
412416

413417
.btn-group {

client/web-sveltekit/src/lib/wildcard/ButtonGroup.svelte

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
<script lang="ts">
22
import classNames from 'classnames'
33
4+
import { getButtonDisplay, type BUTTON_DISPLAY } from './Button'
5+
46
import styles from './Button.module.scss'
57
68
const BUTTON_GROUP_DIRECTION = ['vertical', 'horizontal'] as const
79
810
export let direction: typeof BUTTON_GROUP_DIRECTION[number] = 'horizontal'
11+
export let display: typeof BUTTON_DISPLAY[number] | undefined = undefined
912
10-
$: buttonClass = classNames(styles.btnGroup, direction === 'vertical' && styles.btnGroupVertical)
13+
$: buttonClass = classNames(
14+
styles.btnGroup,
15+
direction === 'vertical' && styles.btnGroupVertical,
16+
display && getButtonDisplay({ display })
17+
)
1118
</script>
1219

1320
<slot name="custom" role="group" {buttonClass}>

client/web-sveltekit/src/routes/[...repo=reporev]/(validrev)/(code)/+layout.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
import { fetchSidebarFileTree } from '$lib/repo/api/tree'
6464
import HistoryPanel from '$lib/repo/HistoryPanel.svelte'
6565
import LastCommit from '$lib/repo/LastCommit.svelte'
66+
import RepositoryRevPicker from '$lib/repo/RepositoryRevPicker.svelte'
6667
import { rightSidePanelOpen, fileTreeSidePanel } from '$lib/repo/stores'
6768
import { isViewportMobile } from '$lib/stores'
6869
import TabPanel from '$lib/TabPanel.svelte'
@@ -72,8 +73,6 @@
7273
import { Alert, PanelGroup, Panel, PanelResizeHandle, Button } from '$lib/wildcard'
7374
import { getButtonClassName } from '$lib/wildcard/Button'
7475
75-
import RepositoryRevPicker from '$lib/repo/RepositoryRevPicker.svelte'
76-
7776
import type { LayoutData, Snapshot } from './$types'
7877
import FileTree from './FileTree.svelte'
7978
import { createFileTreeStore } from './fileTreeStore'
@@ -211,6 +210,7 @@
211210
</Tooltip>
212211

213212
<RepositoryRevPicker
213+
display="block"
214214
repoURL={data.repoURL}
215215
revision={data.revision}
216216
commitID={data.resolvedRevision.commitID}

client/web-sveltekit/src/routes/[...repo=reporev]/-/branches/all/+page.svelte

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@
6060
Unable to load branches: {$branchesQuery.error.message}
6161
</Alert>
6262
{:else if !branches || branches.nodes.length === 0}
63-
<Alert variant="info">
64-
No branches found
65-
</Alert>
63+
<Alert variant="info">No branches found</Alert>
6664
{/if}
6765
</div>
6866
</div>

client/web-sveltekit/src/routes/[...repo=reporev]/-/compare/[...rangeSpec]/+page.svelte

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
goto(
4444
resolveRoute('/[...repo=reporev]/-/compare/[...rangeSpec]', {
4545
repo: $page.params.repo,
46-
spec: `${baseRevision}...${headRevision}`,
46+
rangeSpec: `${baseRevision}...${headRevision}`,
4747
})
4848
)
4949
}
@@ -184,7 +184,6 @@
184184
{/if}
185185

186186
{#if !data.error}
187-
{@debug diffs}
188187
{#if diffs}
189188
<ul class="diffs">
190189
{#each diffs as node, index (index)}

client/web-sveltekit/src/routes/[...repo=reporev]/-/tags/+page.svelte

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@
5858
Unable to load tags: {$tagsQuery.error.message}
5959
</Alert>
6060
{:else if !tags || tags.nodes.length === 0}
61-
<Alert variant="info">
62-
No tags found
63-
</Alert>
61+
<Alert variant="info">No tags found</Alert>
6462
{/if}
6563
</div>
6664
</div>

0 commit comments

Comments
 (0)