|
5 | 5 | import { persistedCommitMessage, projectRunCommitHooks } from '$lib/config/config';
|
6 | 6 | import { cloudCommunicationFunctionality } from '$lib/config/uiFeatureFlags';
|
7 | 7 | import { SyncedSnapshotService } from '$lib/history/syncedSnapshotService';
|
| 8 | + import { showError } from '$lib/notifications/toasts'; |
8 | 9 | import DropDownButton from '$lib/shared/DropDownButton.svelte';
|
9 | 10 | import { intersectionObserver } from '$lib/utils/intersectionObserver';
|
10 | 11 | import { BranchController } from '$lib/vbranches/branchController';
|
|
35 | 36 |
|
36 | 37 | let commitMessageInput = $state<CommitMessageInput>();
|
37 | 38 | let isCommitting = $state(false);
|
| 39 | + let isRunningHooks = $state(false); |
38 | 40 | let commitMessageValid = $state(false);
|
39 | 41 | let isInViewport = $state(false);
|
40 | 42 |
|
|
44 | 46 | try {
|
45 | 47 | await branchController.commitBranch(
|
46 | 48 | $stack.id,
|
47 |
| - $stack.name, |
48 | 49 | message.trim(),
|
49 | 50 | $selectedOwnership.toString(),
|
50 | 51 | $runCommitHooks
|
|
60 | 61 | }
|
61 | 62 |
|
62 | 63 | async function runHooks() {
|
63 |
| - await branchController.runHooks(projectId, $selectedOwnership.toString()); |
| 64 | + isRunningHooks = true; |
| 65 | + try { |
| 66 | + await branchController.runHooks(projectId, $selectedOwnership.toString()); |
| 67 | + } catch (err: unknown) { |
| 68 | + showError('Failed to run hooks', err); |
| 69 | + } finally { |
| 70 | + isRunningHooks = false; |
| 71 | + } |
64 | 72 | }
|
65 | 73 |
|
66 | 74 | function close() {
|
|
110 | 118 | {#if $expanded && !isCommitting}
|
111 | 119 | <div class="cancel-btn-wrapper" transition:slideFade={{ duration: 200, axis: 'x' }}>
|
112 | 120 | <Button style="ghost" outline id="commit-to-branch" onclick={close}>Cancel</Button>
|
| 121 | + {#if $expanded} |
| 122 | + <Button |
| 123 | + onclick={() => { |
| 124 | + runHooks(); |
| 125 | + }} |
| 126 | + style="pop" |
| 127 | + loading={isRunningHooks} |
| 128 | + kind="solid" |
| 129 | + disabled={isRunningHooks || $selectedOwnership.nothingSelected()} |
| 130 | + id="run-hooks" |
| 131 | + > |
| 132 | + Run hooks |
| 133 | + </Button> |
| 134 | + {/if} |
113 | 135 | </div>
|
114 | 136 | {/if}
|
115 | 137 | {#if $expanded && canShowCommitAndPublish}
|
|
153 | 175 | {/snippet}
|
154 | 176 | </DropDownButton>
|
155 | 177 | {:else}
|
156 |
| - <Button |
157 |
| - onclick={() => { |
158 |
| - runHooks(); |
159 |
| - }} |
160 |
| - style="pop" |
161 |
| - kind="solid">Run hooks</Button |
162 |
| - > |
163 | 178 | <Button
|
164 | 179 | style="pop"
|
165 | 180 | kind="solid"
|
|
208 | 223 | .cancel-btn-wrapper {
|
209 | 224 | overflow: hidden;
|
210 | 225 | margin-right: 6px;
|
| 226 | + white-space: nowrap; |
211 | 227 | }
|
212 | 228 |
|
213 | 229 | /* MODIFIERS */
|
|
0 commit comments