mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-19 05:10:41 +08:00
Improve code review usability
This patch moves the revision list from the tab bar drop-down to a sidebar
on wide screens and above the current revision on narrow screens. This
way all revisions are visible at all times.
We also move and nest the revision reviews into that list so that one
can see whether there's anything actionable at a glance.
Other tweaks:
- added comment counts to revisions and reviews
- displayed unresolved comment thread counts per review
- swapped icons for accepted/rejected and neutral reviews to avoid clashing
with resolved/unresolved comment icons
- made label and assignee sections more compact with hover-triggered "+" buttons
- added author and status sections to the sidebar
- enabled patch state changes from the title bar
- made "Review revision" the primary action and "Checkout patch" secondary
- added "Draft" label to draft patches
- capitalized all badges for consistent UI text
This commit is contained in:
@@ -0,0 +1,120 @@
|
||||
<script lang="ts">
|
||||
import type { ComponentProps } from "svelte";
|
||||
import type { State } from "@bindings/cob/patch/State";
|
||||
|
||||
import capitalize from "lodash/capitalize";
|
||||
|
||||
import { closeFocused } from "@app/components/Popover.svelte";
|
||||
import { patchStatusBackgroundColor, patchStatusColor } from "@app/lib/utils";
|
||||
|
||||
import Border from "@app/components/Border.svelte";
|
||||
import DropdownList from "@app/components/DropdownList.svelte";
|
||||
import DropdownListItem from "@app/components/DropdownListItem.svelte";
|
||||
import Icon from "@app/components/Icon.svelte";
|
||||
import Popover from "@app/components/Popover.svelte";
|
||||
|
||||
interface Props {
|
||||
selectedState: State;
|
||||
onSelect: (newState: State) => void;
|
||||
}
|
||||
|
||||
const { selectedState, onSelect }: Props = $props();
|
||||
let focus = $state(false);
|
||||
|
||||
let popoverExpanded: boolean = $state(false);
|
||||
|
||||
function icon(): ComponentProps<typeof Icon>["name"] {
|
||||
if (selectedState.status === "merged") {
|
||||
return "patch-merged";
|
||||
} else if (focus) {
|
||||
return "chevron-down";
|
||||
} else {
|
||||
if (selectedState.status === "open") {
|
||||
return "patch";
|
||||
} else {
|
||||
return `patch-${selectedState.status}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
button {
|
||||
cursor: pointer;
|
||||
border: 0;
|
||||
background: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: var(--font-size-small);
|
||||
}
|
||||
button:disabled {
|
||||
cursor: inherit;
|
||||
}
|
||||
|
||||
.badge {
|
||||
height: 2.5rem;
|
||||
width: 2.5rem;
|
||||
gap: 0.375rem;
|
||||
padding-right: 0.625rem;
|
||||
}
|
||||
</style>
|
||||
|
||||
<Popover
|
||||
popoverPadding="0"
|
||||
popoverPositionTop="3rem"
|
||||
popoverPositionLeft="0"
|
||||
bind:expanded={popoverExpanded}>
|
||||
{#snippet toggle(onclick)}
|
||||
<button
|
||||
onmouseenter={() => (focus = true)}
|
||||
onfocus={() => (focus = true)}
|
||||
onblur={() => (focus = false)}
|
||||
onmouseleave={() => (focus = false)}
|
||||
disabled={selectedState.status === "merged"}
|
||||
{onclick}
|
||||
title={selectedState.status === "merged"
|
||||
? "The state of merged patches can not be changed"
|
||||
: "Click to change patch state"}>
|
||||
<span
|
||||
class="global-counter badge"
|
||||
style:color={patchStatusColor[selectedState.status]}
|
||||
style:background-color={patchStatusBackgroundColor[
|
||||
selectedState.status
|
||||
]}>
|
||||
<Icon name={icon()} />
|
||||
</span>
|
||||
</button>
|
||||
{/snippet}
|
||||
{#snippet popover()}
|
||||
<Border variant="ghost">
|
||||
<DropdownList
|
||||
items={[
|
||||
{ status: "open" },
|
||||
{ status: "draft" },
|
||||
{ status: "archived" },
|
||||
] as State[]}>
|
||||
{#snippet item(state)}
|
||||
<DropdownListItem
|
||||
selected={selectedState.status === state.status}
|
||||
onclick={() => {
|
||||
onSelect(state);
|
||||
closeFocused();
|
||||
}}>
|
||||
<span
|
||||
class="global-flex"
|
||||
style:color={patchStatusColor[state.status]}>
|
||||
<Icon
|
||||
name={state.status === "open"
|
||||
? "patch"
|
||||
: `patch-${state.status}`} />
|
||||
{capitalize(state.status)}
|
||||
</span>
|
||||
</DropdownListItem>
|
||||
{/snippet}
|
||||
</DropdownList>
|
||||
</Border>
|
||||
{/snippet}
|
||||
</Popover>
|
||||
Reference in New Issue
Block a user