From 8498e35d9f919c7b5b1973a4e334afeb2a0121e0 Mon Sep 17 00:00:00 2001 From: Pavel Laptev Date: Tue, 19 Mar 2024 16:24:54 +0100 Subject: [PATCH] new component `PassphraseBox` --- .../lib/components/CommitListFooter.svelte | 24 ++++++- .../src/lib/components/PassphraseBox.svelte | 71 +++++++++++++++++++ .../src/lib/components/TextBox.svelte | 7 +- 3 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 gitbutler-ui/src/lib/components/PassphraseBox.svelte diff --git a/gitbutler-ui/src/lib/components/CommitListFooter.svelte b/gitbutler-ui/src/lib/components/CommitListFooter.svelte index 1f447ade8..5b3f1df36 100644 --- a/gitbutler-ui/src/lib/components/CommitListFooter.svelte +++ b/gitbutler-ui/src/lib/components/CommitListFooter.svelte @@ -1,4 +1,5 @@ {#if !isUnapplied && type != 'integrated'}
- {#if githubService.isEnabled && (type == 'local' || type == 'remote')} + {#if isPassphraseBoxVisible} + { + isSubmitting = true; + setTimeout(() => { + isSubmitting = false; + }, 2000); + }} + on:cancel={() => { + isPassphraseBoxVisible = false; + }} + /> + {:else if githubService.isEnabled && (type == 'local' || type == 'remote')} + import Button from './Button.svelte'; + import TextBox from './TextBox.svelte'; + import { createEventDispatcher } from 'svelte'; + + export let prompt: string = 'passphrase'; + export let value: string = ''; + export let submitLabel: string = 'Submit'; + export let submitDisabled: boolean = false; + export let isSubmitting: boolean = true; + export let loadingLabel: string = 'Pushing'; + + const dispatch = createEventDispatcher<{ + change: string; + input: string; + submit: void; + cancel: void; + }>(); + + +
+ To push your changes, please provide your {prompt} + dispatch('change', e.detail)} + on:input={(e) => dispatch('input', e.detail)} + on:keydown={(e) => { + if (e.detail.key === 'Enter') { + dispatch('submit'); + } + }} + /> +
+ + +
+
+ + diff --git a/gitbutler-ui/src/lib/components/TextBox.svelte b/gitbutler-ui/src/lib/components/TextBox.svelte index 19eb19730..0ecc92514 100644 --- a/gitbutler-ui/src/lib/components/TextBox.svelte +++ b/gitbutler-ui/src/lib/components/TextBox.svelte @@ -20,7 +20,11 @@ export let type: 'text' | 'password' | 'select' = 'text'; - const dispatch = createEventDispatcher<{ input: string; change: string }>(); + const dispatch = createEventDispatcher<{ + input: string; + change: string; + keydown: KeyboardEvent; + }>(); let showPassword = false; @@ -60,6 +64,7 @@ on:mousedown on:input={(e) => dispatch('input', e.currentTarget.value)} on:change={(e) => dispatch('change', e.currentTarget.value)} + on:keydown={(e) => dispatch('keydown', e)} /> {#if type == 'password'}