Skip to content

Commit

Permalink
feat: add mergeAll btn
Browse files Browse the repository at this point in the history
  • Loading branch information
ndom91 committed Nov 20, 2024
1 parent 72d3869 commit 537e88e
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 17 deletions.
39 changes: 26 additions & 13 deletions apps/desktop/src/lib/pr/MergeButton.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,35 @@
import { MergeMethod } from '$lib/forge/interface/types';
import DropDownButton from '$lib/shared/DropDownButton.svelte';
import { persisted, type Persisted } from '@gitbutler/shared/persisted';
import { createEventDispatcher } from 'svelte';
import { type Props as ButtonProps } from '@gitbutler/ui/Button.svelte';
export let projectId: string;
export let loading = false;
export let disabled = false;
export let wide = false;
export let tooltip = '';
interface Props {
projectId: string;
onclick: (method: MergeMethod) => void;
loading?: boolean;
disabled?: boolean;
wide?: boolean;
tooltip?: string;
style?: ButtonProps['style'];
outline?: boolean;
}
const {
projectId,
onclick,
loading = false,
disabled = false,
wide = false,
tooltip = '',
style = 'ghost',
outline = true
}: Props = $props();
function persistedAction(projectId: string): Persisted<MergeMethod> {
const key = 'projectMergeMethod';
return persisted<MergeMethod>(MergeMethod.Merge, key + projectId);
}
const dispatch = createEventDispatcher<{ click: { method: MergeMethod } }>();
const action = persistedAction(projectId);
let dropDown: ReturnType<typeof DropDownButton> | undefined;
Expand All @@ -30,16 +45,14 @@
</script>

<DropDownButton
style="ghost"
outline
{loading}
bind:this={dropDown}
onclick={() => onclick($action)}
{outline}
{style}
{loading}
{wide}
{tooltip}
{disabled}
onclick={() => {
dispatch('click', { method: $action });
}}
>
{labels[$action]}
{#snippet contextMenuSlot()}
Expand Down
3 changes: 1 addition & 2 deletions apps/desktop/src/lib/pr/PullRequestCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,9 @@
disabled={mergability.disabled}
tooltip={mergability.tooltip}
loading={isMerging}
on:click={async (e) => {
onclick={async (method) => {
if (!pr) return;
isMerging = true;
const method = e.detail.method;
try {
await $prService?.merge(method, pr.number);
await baseBranchService.fetchFromRemotes();
Expand Down
16 changes: 14 additions & 2 deletions apps/desktop/src/lib/stack/Stack.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,23 @@
import laneNewSvg from '$lib/assets/empty-state/lane-new.svg?raw';
import noChangesSvg from '$lib/assets/empty-state/lane-no-changes.svg?raw';
import { Project } from '$lib/backend/projects';
import { BaseBranchService } from '$lib/baseBranch/baseBranchService';
import Dropzones from '$lib/branch/Dropzones.svelte';
import { getForgeListingService } from '$lib/forge/interface/forgeListingService';
import { getForgePrService } from '$lib/forge/interface/forgePrService';
import { type MergeMethod } from '$lib/forge/interface/types';

Check failure on line 12 in apps/desktop/src/lib/stack/Stack.svelte

View workflow job for this annotation

GitHub Actions / lint-node

'MergeMethod' is defined but never used. Allowed unused vars must match /^_/u
import { showError } from '$lib/notifications/toasts';

Check failure on line 13 in apps/desktop/src/lib/stack/Stack.svelte

View workflow job for this annotation

GitHub Actions / lint-node

'showError' is defined but never used. Allowed unused vars must match /^_/u
import MergeButton from '$lib/pr/MergeButton.svelte';

Check failure on line 14 in apps/desktop/src/lib/stack/Stack.svelte

View workflow job for this annotation

GitHub Actions / lint-node

'MergeButton' is defined but never used. Allowed unused vars must match /^_/u
import ScrollableContainer from '$lib/scroll/ScrollableContainer.svelte';
import { SETTINGS, type Settings } from '$lib/settings/userSettings';
import Resizer from '$lib/shared/Resizer.svelte';
import CollapsedLane from '$lib/stack/CollapsedLane.svelte';
import { intersectionObserver } from '$lib/utils/intersectionObserver';
import * as toasts from '$lib/utils/toasts';

Check failure on line 20 in apps/desktop/src/lib/stack/Stack.svelte

View workflow job for this annotation

GitHub Actions / lint-node

'toasts' is defined but never used. Allowed unused vars must match /^_/u
import { BranchController } from '$lib/vbranches/branchController';
import { FileIdSelection } from '$lib/vbranches/fileIdSelection';
import { DetailedCommit, VirtualBranch } from '$lib/vbranches/types';
import { VirtualBranchService } from '$lib/vbranches/virtualBranch';
import { getContext, getContextStore, getContextStoreBySymbol } from '@gitbutler/shared/context';
import { persisted } from '@gitbutler/shared/persisted';
import Button from '@gitbutler/ui/Button.svelte';
Expand All @@ -29,20 +36,24 @@
commitBoxOpen
}: { isLaneCollapsed: Writable<boolean>; commitBoxOpen: Writable<boolean> } = $props();
const vbranchService = getContext(VirtualBranchService);

Check failure on line 39 in apps/desktop/src/lib/stack/Stack.svelte

View workflow job for this annotation

GitHub Actions / lint-node

'vbranchService' is assigned a value but never used. Allowed unused vars must match /^_/u
const branchController = getContext(BranchController);
const fileIdSelection = getContext(FileIdSelection);
const branchStore = getContextStore(VirtualBranch);
const baseBranchService = getContext(BaseBranchService);

Check failure on line 43 in apps/desktop/src/lib/stack/Stack.svelte

View workflow job for this annotation

GitHub Actions / lint-node

'baseBranchService' is assigned a value but never used. Allowed unused vars must match /^_/u
const project = getContext(Project);
const prService = getForgePrService();

Check failure on line 45 in apps/desktop/src/lib/stack/Stack.svelte

View workflow job for this annotation

GitHub Actions / lint-node

'prService' is assigned a value but never used. Allowed unused vars must match /^_/u
const branch = $derived($branchStore);
const userSettings = getContextStoreBySymbol<Settings>(SETTINGS);
const defaultBranchWidthRem = persisted<number>(24, 'defaulBranchWidth' + project.id);
const laneWidthKey = 'laneWidth_';
let lastPush = $state<Date | undefined>();
let canMergeAll = $state(true);

Check failure on line 51 in apps/desktop/src/lib/stack/Stack.svelte

View workflow job for this annotation

GitHub Actions / lint-node

'canMergeAll' is assigned a value but never used. Allowed unused vars must match /^_/u
const laneWidthKey = 'laneWidth_';
let laneWidth: number | undefined = $state();
let rsViewport = $state<HTMLElement>();
const branchHasFiles = $derived(branch.files !== undefined && branch.files.length > 0);
const branchHasNoCommits = $derived(branch.commits !== undefined && branch.commits.length === 0);
Expand All @@ -58,6 +69,7 @@
let scrollEndVisible = $state(true);
let isPushingCommits = $state(false);
let isMergingSeries = $state(false);

Check failure on line 72 in apps/desktop/src/lib/stack/Stack.svelte

View workflow job for this annotation

GitHub Actions / lint-node

'isMergingSeries' is assigned a value but never used. Allowed unused vars must match /^_/u
const { upstreamPatches, branchPatches, hasConflicts } = $derived.by(() => {
let hasConflicts = false;
Expand Down

0 comments on commit 537e88e

Please sign in to comment.