Show busy indicator when updating base branch

- make update button its own component
- show busy while updating
- remove unnecessary log statement
This commit is contained in:
Mattias Granlund 2024-02-04 12:33:27 +01:00
parent 26fdfdbc39
commit 6a56fa582c
3 changed files with 34 additions and 21 deletions

View File

@ -3,12 +3,11 @@
import DomainButton from './DomainButton.svelte';
import Footer from './Footer.svelte';
import ProjectSelector from './ProjectSelector.svelte';
import UpdateBaseButton from './UpdateBaseButton.svelte';
import BaseBranchCard from '$lib/components/BaseBranchCard.svelte';
import Resizer from '$lib/components/Resizer.svelte';
import Tag from '$lib/components/Tag.svelte';
import { persisted } from '$lib/persisted/persisted';
import { SETTINGS_CONTEXT, type SettingsStore } from '$lib/settings/userSettings';
import * as toasts from '$lib/utils/toasts';
import { getContext } from 'svelte';
import type { User } from '$lib/backend/cloud';
import type { Project, ProjectService } from '$lib/backend/projects';
@ -66,23 +65,7 @@
<span>Workspace</span>
{#if ($base$?.behind || 0) > 0}
<Tag
color="error"
help="Merge upstream commits into common base"
filled
clickable
on:click={async (e) => {
e.preventDefault();
e.stopPropagation();
try {
await branchController.updateBaseBranch();
} catch {
toasts.error('Failed update working directory');
}
}}
>
Update
</Tag>
<UpdateBaseButton {branchController} />
{/if}
</DomainButton>
</div>

View File

@ -0,0 +1,32 @@
<script lang="ts">
import Tag from './Tag.svelte';
import * as toasts from '$lib/utils/toasts';
import type { BranchController } from '$lib/vbranches/branchController';
export let branchController: BranchController;
let loading = false;
</script>
<Tag
color="error"
help="Merge upstream commits into common base"
filled
clickable
on:click={async () => {
loading = true;
try {
await branchController.updateBaseBranch();
} catch {
toasts.error('Failed update workspace');
} finally {
loading = false;
}
}}
>
{#if loading}
busy...
{:else}
Update
{/if}
</Tag>

View File

@ -200,8 +200,6 @@ export class BranchController {
async updateBaseBranch() {
try {
await invoke<object>('update_base_branch', { projectId: this.projectId });
} catch (err) {
toasts.error('Failed to update target');
} finally {
this.targetBranchService.reload();
}