mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-18 06:22:28 +03:00
fix: ensure pullRequestCard still works in both stacking/non-stacking contexts
This commit is contained in:
parent
41b8734012
commit
b939af8299
@ -12,9 +12,11 @@
|
||||
import CommitList from '$lib/commit/CommitList.svelte';
|
||||
import { projectAiGenEnabled } from '$lib/config/config';
|
||||
import BranchFiles from '$lib/file/BranchFiles.svelte';
|
||||
import { getGitHostChecksMonitor } from '$lib/gitHost/interface/gitHostChecksMonitor';
|
||||
import { getGitHost } from '$lib/gitHost/interface/gitHost';
|
||||
import { createGitHostChecksMonitorStore } from '$lib/gitHost/interface/gitHostChecksMonitor';
|
||||
import { getGitHostListingService } from '$lib/gitHost/interface/gitHostListingService';
|
||||
import { getGitHostPrMonitor } from '$lib/gitHost/interface/gitHostPrMonitor';
|
||||
import { createGitHostPrMonitorStore } from '$lib/gitHost/interface/gitHostPrMonitor';
|
||||
import { createGitHostPrServiceStore } from '$lib/gitHost/interface/gitHostPrService';
|
||||
import { showError } from '$lib/notifications/toasts';
|
||||
import { isFailure } from '$lib/result';
|
||||
import ScrollableContainer from '$lib/scroll/ScrollableContainer.svelte';
|
||||
@ -42,6 +44,28 @@
|
||||
commitBoxOpen
|
||||
}: { isLaneCollapsed: Writable<boolean>; commitBoxOpen: Writable<boolean> } = $props();
|
||||
|
||||
const gitHost = getGitHost();
|
||||
|
||||
const prService = createGitHostPrServiceStore(undefined);
|
||||
$effect(() => prService.set($gitHost?.prService()));
|
||||
|
||||
const hostedListingServiceStore = getGitHostListingService();
|
||||
|
||||
const prStore = $derived($hostedListingServiceStore?.prs);
|
||||
const prs = $derived(prStore ? $prStore : undefined);
|
||||
|
||||
const listedPr = $derived(prs?.find((pr) => pr.sourceBranch === branch.upstream?.givenName));
|
||||
const sourceBranch = $derived(listedPr?.sourceBranch);
|
||||
const prNumber = $derived(listedPr?.number);
|
||||
|
||||
const gitHostPrMonitorStore = createGitHostPrMonitorStore(undefined);
|
||||
const prMonitor = $derived(prNumber ? $prService?.prMonitor(prNumber) : undefined);
|
||||
$effect(() => gitHostPrMonitorStore.set(prMonitor));
|
||||
|
||||
const gitHostChecksMonitorStore = createGitHostChecksMonitorStore(undefined);
|
||||
const checksMonitor = $derived(sourceBranch ? $gitHost?.checksMonitor(sourceBranch) : undefined);
|
||||
$effect(() => gitHostChecksMonitorStore.set(checksMonitor));
|
||||
|
||||
const branchController = getContext(BranchController);
|
||||
const fileIdSelection = getContext(FileIdSelection);
|
||||
const branchStore = getContextStore(VirtualBranch);
|
||||
@ -61,7 +85,6 @@
|
||||
let laneWidth: number | undefined = $state();
|
||||
|
||||
let commitDialog = $state<CommitDialog>();
|
||||
let scrollViewport: HTMLElement | undefined = $state();
|
||||
let rsViewport: HTMLElement | undefined = $state();
|
||||
|
||||
$effect(() => {
|
||||
@ -112,16 +135,14 @@
|
||||
);
|
||||
|
||||
const listingService = getGitHostListingService();
|
||||
const prMonitor = getGitHostPrMonitor();
|
||||
const checksMonitor = getGitHostChecksMonitor();
|
||||
|
||||
async function push() {
|
||||
isPushingCommits = true;
|
||||
try {
|
||||
await branchController.pushBranch(branch.id, branch.requiresForce);
|
||||
$listingService?.refresh();
|
||||
$prMonitor?.refresh();
|
||||
$checksMonitor?.update();
|
||||
prMonitor?.refresh();
|
||||
checksMonitor?.update();
|
||||
} finally {
|
||||
isPushingCommits = false;
|
||||
}
|
||||
@ -139,7 +160,7 @@
|
||||
<div class="collapsed-lane-divider" data-remove-from-draggable></div>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="resizer-wrapper" bind:this={scrollViewport}>
|
||||
<div class="resizer-wrapper">
|
||||
<div class="branch-card hide-native-scrollbar" class:target-branch={branch.selectedForChanges}>
|
||||
<ScrollableContainer
|
||||
wide
|
||||
|
@ -4,11 +4,6 @@
|
||||
import { projectLaneCollapsed } from '$lib/config/config';
|
||||
import { stackingFeature } from '$lib/config/uiFeatureFlags';
|
||||
import FileCard from '$lib/file/FileCard.svelte';
|
||||
import { getGitHost } from '$lib/gitHost/interface/gitHost';
|
||||
import { createGitHostChecksMonitorStore } from '$lib/gitHost/interface/gitHostChecksMonitor';
|
||||
import { getGitHostListingService } from '$lib/gitHost/interface/gitHostListingService';
|
||||
import { createGitHostPrMonitorStore } from '$lib/gitHost/interface/gitHostPrMonitor';
|
||||
import { createGitHostPrServiceStore } from '$lib/gitHost/interface/gitHostPrService';
|
||||
import { SETTINGS, type Settings } from '$lib/settings/userSettings';
|
||||
import Resizer from '$lib/shared/Resizer.svelte';
|
||||
import Stack from '$lib/stack/Stack.svelte';
|
||||
@ -35,34 +30,6 @@
|
||||
|
||||
const { branch }: { branch: VirtualBranch } = $props();
|
||||
|
||||
const gitHost = getGitHost();
|
||||
|
||||
// BRANCH SERVICE
|
||||
const prService = createGitHostPrServiceStore(undefined);
|
||||
$effect(() => prService.set($gitHost?.prService()));
|
||||
|
||||
// Pretty cumbersome way of getting the PR number, would be great if we can
|
||||
// make it more concise somehow.
|
||||
const hostedListingServiceStore = getGitHostListingService();
|
||||
const prStore = $derived($hostedListingServiceStore?.prs);
|
||||
const prs = $derived(prStore ? $prStore : undefined);
|
||||
|
||||
const listedPr = $derived(prs?.find((pr) => pr.sourceBranch === branch.upstream?.givenName));
|
||||
const sourceBranch = $derived(listedPr?.sourceBranch);
|
||||
const prNumber = $derived(listedPr?.number);
|
||||
|
||||
if (!$stackingFeature) {
|
||||
const gitHostPrMonitorStore = createGitHostPrMonitorStore(undefined);
|
||||
const prMonitor = $derived(prNumber ? $prService?.prMonitor(prNumber) : undefined);
|
||||
$effect(() => gitHostPrMonitorStore.set(prMonitor));
|
||||
|
||||
const gitHostChecksMonitorStore = createGitHostChecksMonitorStore(undefined);
|
||||
const checksMonitor = $derived(
|
||||
sourceBranch ? $gitHost?.checksMonitor(sourceBranch) : undefined
|
||||
);
|
||||
$effect(() => gitHostChecksMonitorStore.set(checksMonitor));
|
||||
}
|
||||
|
||||
// BRANCH
|
||||
const branchStore = createContextStore(VirtualBranch, branch);
|
||||
const selectedOwnershipStore = createContextStore(
|
||||
|
@ -76,7 +76,7 @@ class Indexer {
|
||||
get(key: string) {
|
||||
const index = this.getIndex(key);
|
||||
|
||||
return new Entry(this.commitIndexes, index);
|
||||
return new Entry(this.commitIndexes, index ?? 0);
|
||||
}
|
||||
|
||||
private getIndex(key: string) {
|
||||
@ -90,9 +90,11 @@ class Indexer {
|
||||
} else {
|
||||
const index = this.dropzoneIndexes.get(key);
|
||||
|
||||
if (index === undefined) {
|
||||
throw new Error(`Commit ${key} not found in dropzoneIndexes`);
|
||||
}
|
||||
// TODO: Improve reactivity of dropzoneIndexes
|
||||
// Handle integrated state and dont error
|
||||
// if (index === undefined) {
|
||||
// throw new Error(`Commit ${key} not found in dropzoneIndexes`);
|
||||
// }
|
||||
|
||||
return index;
|
||||
}
|
||||
|
@ -143,8 +143,10 @@
|
||||
tooltip="Open in browser"
|
||||
onclick={() => {
|
||||
openExternalUrl($pr.htmlUrl);
|
||||
}}>View PR</Button
|
||||
}}
|
||||
>
|
||||
View PR
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<!--
|
||||
|
@ -3,7 +3,7 @@
|
||||
import { createGitHostChecksMonitorStore } from '$lib/gitHost/interface/gitHostChecksMonitor';
|
||||
import { getGitHostListingService } from '$lib/gitHost/interface/gitHostListingService';
|
||||
import { createGitHostPrMonitorStore } from '$lib/gitHost/interface/gitHostPrMonitor';
|
||||
import { getGitHostPrService } from '$lib/gitHost/interface/gitHostPrService';
|
||||
import { createGitHostPrServiceStore } from '$lib/gitHost/interface/gitHostPrService';
|
||||
import type { PatchSeries } from '$lib/vbranches/types';
|
||||
import type { Snippet } from 'svelte';
|
||||
|
||||
@ -16,7 +16,8 @@
|
||||
|
||||
// Setup PR Store and Monitor on a per-series basis
|
||||
const gitHost = getGitHost();
|
||||
const prService = getGitHostPrService();
|
||||
const prService = createGitHostPrServiceStore(undefined);
|
||||
$effect(() => prService.set($gitHost?.prService()));
|
||||
|
||||
// Pretty cumbersome way of getting the PR number, would be great if we can
|
||||
// make it more concise somehow.
|
||||
|
Loading…
Reference in New Issue
Block a user