Skip to content

Commit

Permalink
Use the exposed state of the integrate upstream modal
Browse files Browse the repository at this point in the history
Export the state of whether the modal is open or not.
Use it in the base branch page and the update base button.
  • Loading branch information
estib-vega committed Sep 24, 2024
1 parent 6ce7755 commit adc6357
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
15 changes: 3 additions & 12 deletions apps/desktop/src/lib/components/BaseBranch.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
let updateTargetModal: Modal;
let integrateUpstreamModal: IntegrateUpstreamModal | undefined;
let integrateUpstreamModalOpen = false;
let mergeUpstreamWarningDismissedCheckbox = false;
$: multiple = base ? base.upstreamCommits.length > 1 || base.upstreamCommits.length === 0 : false;
Expand All @@ -42,13 +41,8 @@
}
}
function closeIntegrateUpstreamModal() {
integrateUpstreamModalOpen = false;
}
function mergeUpstream() {
if (project.succeedingRebases) {
integrateUpstreamModalOpen = true;
integrateUpstreamModal?.show();
} else {
if (mergeUpstreamWarningDismissedCheckbox) {
Expand All @@ -68,16 +62,13 @@
</div>

{#if base.upstreamCommits?.length > 0}
<IntegrateUpstreamModal
bind:this={integrateUpstreamModal}
onClose={closeIntegrateUpstreamModal}
/>
<IntegrateUpstreamModal bind:this={integrateUpstreamModal} />
<Button
style="pop"
kind="solid"
tooltip={`Merges the commits from ${base.branchName} into the base of all applied virtual branches`}
disabled={$mode?.type !== 'OpenWorkspace' || integrateUpstreamModalOpen}
loading={integrateUpstreamModalOpen}
disabled={$mode?.type !== 'OpenWorkspace' || integrateUpstreamModal.imports.open}
loading={integrateUpstreamModal.imports.open}
onclick={mergeUpstream}
>
Merge into common base
Expand Down
6 changes: 6 additions & 0 deletions apps/desktop/src/lib/components/IntegrateUpstreamModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@
await tick();
modal?.show();
}
export const imports = {
get open() {
return modal?.imports.open;
}
};
</script>

<Modal bind:this={modal} title="Integrate upstream changes" {onClose} width="small" noPadding>
Expand Down
9 changes: 2 additions & 7 deletions apps/desktop/src/lib/components/UpdateBaseButton.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,11 @@
let modal = $state<IntegrateUpstreamModal>();
let modalOpen = $state<boolean>(false);
function openModal() {
modalOpen = true;
modal?.show();
}
function onClose() {
modalOpen = false;
}
function onClose() {}
async function updateBaseBranch() {
let infoText = await branchController.updateBaseBranch();
Expand All @@ -54,7 +49,7 @@
updateBaseBranch();
}
}}
loading={modalOpen}
loading={modal?.imports.open}
>
Update
</Button>
Expand Down

0 comments on commit adc6357

Please sign in to comment.