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:
Rūdolfs Ošiņš
2025-07-03 11:46:39 +02:00
parent 18f5aa9065
commit a55a138a7f
20 changed files with 933 additions and 649 deletions
+144
View File
@@ -0,0 +1,144 @@
<script lang="ts">
import type { Author } from "@bindings/cob/Author";
import type { Config } from "@bindings/config/Config";
import type { Patch } from "@bindings/cob/patch/Patch";
import type { RepoInfo } from "@bindings/repo/RepoInfo";
import * as roles from "@app/lib/roles";
import { announce } from "@app/components/AnnounceSwitch.svelte";
import { invoke } from "@app/lib/invoke";
import { nodeRunning } from "@app/lib/events";
import AssigneeInput from "@app/components/AssigneeInput.svelte";
import LabelInput from "@app/components/LabelInput.svelte";
import NodeId from "./NodeId.svelte";
import { authorForNodeId } from "@app/lib/utils";
import PatchStateButton from "./PatchStateButton.svelte";
interface Props {
config: Config;
horizontal?: boolean;
loadPatch: () => Promise<void>;
patch: Patch;
repo: RepoInfo;
saveState: (newState: Patch["state"]) => Promise<void>;
}
const {
config,
horizontal = false,
loadPatch,
patch,
repo,
saveState,
}: Props = $props();
let labelSaveInProgress: boolean = $state(false);
let assigneesSaveInProgress: boolean = $state(false);
async function saveLabels(labels: string[]) {
try {
labelSaveInProgress = true;
await invoke("edit_patch", {
rid: repo.rid,
cobId: patch.id,
action: {
type: "label",
labels,
},
opts: { announce: $nodeRunning && $announce },
});
} catch (error) {
console.error("Editing labels failed", error);
} finally {
labelSaveInProgress = false;
await loadPatch();
}
}
async function saveAssignees(assignees: Author[]) {
try {
assigneesSaveInProgress = true;
await invoke("edit_patch", {
rid: repo.rid,
cobId: patch.id,
action: {
type: "assign",
assignees,
},
opts: { announce: $nodeRunning && $announce },
});
} catch (error) {
console.error("Editing assignees failed", error);
} finally {
assigneesSaveInProgress = false;
await loadPatch();
}
}
</script>
<style>
.metadata-section {
padding: 0.5rem;
font-size: var(--font-size-small);
display: flex;
flex-direction: column;
align-items: flex;
height: 100%;
}
.metadata-section-title {
margin-bottom: 0.5rem;
color: var(--color-foreground-dim);
}
</style>
<div
class="global-flex"
style:flex-direction={horizontal ? "row" : "column"}
style:align-items="flex-start">
<div
class="metadata-section"
style={horizontal ? "flex: 1;" : "width: 100%;"}>
<div class="metadata-section-title">Author</div>
<NodeId {...authorForNodeId(patch.author)} />
</div>
<div
class="metadata-section"
style={horizontal ? "flex: 1;" : "width: 100%;"}>
<div class="metadata-section-title">Status</div>
<PatchStateButton
selectedState={patch.state}
onSelect={newState => {
void saveState(newState);
}} />
</div>
<div
class="metadata-section"
style={horizontal ? "flex: 1;" : "width: 100%;"}>
<LabelInput
allowedToEdit={!!roles.isDelegateOrAuthor(
config.publicKey,
repo.delegates.map(delegate => delegate.did),
patch.author.did,
)}
labels={patch.labels}
submitInProgress={labelSaveInProgress}
save={saveLabels} />
</div>
<div
class="metadata-section"
style={horizontal ? "flex: 1;" : "width: 100%;"}>
<AssigneeInput
allowedToEdit={!!roles.isDelegateOrAuthor(
config.publicKey,
repo.delegates.map(delegate => delegate.did),
patch.author.did,
)}
assignees={patch.assignees}
submitInProgress={assigneesSaveInProgress}
save={saveAssignees} />
</div>
</div>