mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-21 14:20:42 +08:00
Right-clicking a revision in the Changes tab picker offers the same comparisons as the activity tab's compare menu, so you don't have to leave the Changes tab to compare revisions.
60 lines
1.5 KiB
Svelte
60 lines
1.5 KiB
Svelte
<script lang="ts">
|
|
import type { RevisionRange } from "@app/lib/revisionCompare";
|
|
import { compareRange, previousOption } from "@app/lib/revisionCompare";
|
|
import { formatOid } from "@app/lib/utils";
|
|
|
|
import ContextMenu from "@app/components/ContextMenu.svelte";
|
|
|
|
interface Props extends RevisionRange {
|
|
x: number;
|
|
y: number;
|
|
target?: HTMLElement;
|
|
// Called with the commit to diff `head` against, or with nothing for the
|
|
// revision's own base.
|
|
onCompare: (from?: string) => void;
|
|
onclose: () => void;
|
|
}
|
|
|
|
const { x, y, target, base, head, previous, onCompare, onclose }: Props =
|
|
$props();
|
|
|
|
const prev = $derived(previousOption({ base, head, previous }));
|
|
</script>
|
|
|
|
<style>
|
|
.item {
|
|
gap: 0.25rem;
|
|
}
|
|
.item.item:disabled {
|
|
color: var(--color-text-disabled);
|
|
cursor: not-allowed;
|
|
background-color: transparent;
|
|
}
|
|
.previous-id {
|
|
color: var(--color-text-brand);
|
|
}
|
|
</style>
|
|
|
|
<!-- Opened from the revision picker, a popover. -->
|
|
<ContextMenu {x} {y} {target} {onclose} styleZIndex="500">
|
|
<button
|
|
class="menu-item item"
|
|
role="menuitem"
|
|
title={compareRange(base, head)}
|
|
onclick={() => onCompare()}>
|
|
Compare to base:
|
|
<span class="txt-id">{formatOid(base)}</span>
|
|
</button>
|
|
{#if prev}
|
|
<button
|
|
class="menu-item item"
|
|
role="menuitem"
|
|
disabled={prev.disabled}
|
|
title={prev.title}
|
|
onclick={() => onCompare(prev.from)}>
|
|
Compare to previous revision:
|
|
<span class="txt-id previous-id">{formatOid(prev.id)}</span>
|
|
</button>
|
|
{/if}
|
|
</ContextMenu>
|