inline modal for 2 phase comits

This commit is contained in:
Kiril Videlov 2023-07-21 11:08:36 +02:00 committed by Kiril Videlov
parent 0892f58a10
commit 2e64a268a1
3 changed files with 69 additions and 116 deletions

47
butler/Cargo.lock generated
View File

@ -1689,7 +1689,7 @@ dependencies = [
"thiserror",
"timed",
"tokio",
"tokio-tungstenite 0.18.0",
"tokio-tungstenite",
"tokio-util",
"url",
"urlencoding",
@ -2435,9 +2435,9 @@ dependencies = [
[[package]]
name = "libsqlite3-sys"
version = "0.25.2"
version = "0.26.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29f835d03d717946d28b1d1ed632eb6f0e24a299388ee623d0c23118d3e8a7fa"
checksum = "afc22eff61b133b115c6e8c74e818c628d6d5e7a502afea6f64dee076dd94326"
dependencies = [
"cc",
"pkg-config",
@ -3772,11 +3772,11 @@ dependencies = [
[[package]]
name = "rusqlite"
version = "0.28.0"
version = "0.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "01e213bc3ecb39ac32e81e51ebe31fd888a940515173e3a18a35f8c6e896422a"
checksum = "549b9d036d571d42e6e85d1c1425e2ac83491075078ca9a15be021c56b1641f2"
dependencies = [
"bitflags 1.3.2",
"bitflags 2.3.3",
"fallible-iterator",
"fallible-streaming-iterator",
"hashlink",
@ -4924,7 +4924,7 @@ dependencies = [
"tauri",
"thiserror",
"tokio",
"tokio-tungstenite 0.19.0",
"tokio-tungstenite",
]
[[package]]
@ -5211,18 +5211,6 @@ dependencies = [
"tokio",
]
[[package]]
name = "tokio-tungstenite"
version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "54319c93411147bced34cb5609a80e0a8e44c5999c93903a81cd866630ec0bfd"
dependencies = [
"futures-util",
"log",
"tokio",
"tungstenite 0.18.0",
]
[[package]]
name = "tokio-tungstenite"
version = "0.19.0"
@ -5234,7 +5222,7 @@ dependencies = [
"native-tls",
"tokio",
"tokio-native-tls",
"tungstenite 0.19.0",
"tungstenite",
]
[[package]]
@ -5378,25 +5366,6 @@ version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed"
[[package]]
name = "tungstenite"
version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "30ee6ab729cd4cf0fd55218530c4522ed30b7b6081752839b68fcec8d0960788"
dependencies = [
"base64 0.13.1",
"byteorder",
"bytes",
"http",
"httparse",
"log",
"rand 0.8.5",
"sha1",
"thiserror",
"url",
"utf-8",
]
[[package]]
name = "tungstenite"
version = "0.19.0"

View File

@ -120,7 +120,7 @@
$: renderedRows = diffRows.rows.map((row) => ({ ...row, render: renderRowContent(row) }));
type RenderedRow = (typeof renderedRows)[0];
type RenderedRow = typeof renderedRows[0];
const padHighlighted = (rows: RenderedRow[]): RenderedRow[] => {
const chunks: (RenderedRow[] | RenderedRow)[] = [];

View File

@ -13,6 +13,7 @@
import type { BranchController } from '$lib/vbranches';
import { BRANCH_CONTROLLER_KEY } from '$lib/vbranches/branchController';
import FileCardNext from './FileCardNext.svelte';
import { slide } from 'svelte/transition';
export let branchId: string;
export let projectPath: string;
@ -118,9 +119,7 @@
return `${repoBaseUrl}/compare/${baseBranchName}...${branchName}`;
}
function onUpdateFromModal() {
commitMessage = commitTiteInput.value + '\n\n' + commitDescription;
}
let commitDialogShown = false;
</script>
<div
@ -217,31 +216,69 @@
</PopupMenuItem>
</PopupMenu>
<div class="flex flex-col pt-2">
<div class="mb-2 flex items-center">
<textarea
bind:this={textAreaInput}
bind:value={commitMessage}
on:change={() => {
commitTitle = commitMessage?.split('\n')?.at(0) || '';
commitDescription = commitMessage?.split('\n')?.slice(1)?.join('\n').trim() || '';
}}
class="shrink-0 flex-grow cursor-text resize-none overflow-x-auto overflow-y-auto border border-white bg-white p-2 font-mono text-dark-700 outline-none hover:border-light-400 focus:border-purple-600 focus:ring-0 dark:border-dark-500 dark:bg-dark-700 dark:text-light-400 dark:hover:border-dark-300"
placeholder="Your commit message here"
rows={messageRows}
required
/>
</div>
<div class="mb-2 mr-2 text-right">
<div class="flex flex-col">
<div class="mb-4 mr-2 flex justify-end gap-2 text-right">
{#if localCommits.length > 0}
<Button on:click={push} loading={isPushing} kind="outlined" color="purple" height="small">
<span class="purple">Push</span>
<Button class="w-20" on:click={push} loading={isPushing} color="purple" height="small">
Push
</Button>
{/if}
<Button height="small" color="purple" on:click={() => commitBranchModal.show()}>
Commit
<Button
class="w-20"
height="small"
color="purple"
on:click={() => (commitDialogShown = !commitDialogShown)}
>
{#if !commitDialogShown}
Commit
{:else}
Cancel
{/if}
</Button>
</div>
{#if commitDialogShown}
<div
class="mb-2 border-t border-light-400 py-4 dark:border-dark-400"
transition:slide={{ duration: 150 }}
>
<div class="mb-2 flex items-center">
<textarea
bind:this={textAreaInput}
bind:value={commitMessage}
on:change={() => {
commitTitle = commitMessage?.split('\n')?.at(0) || '';
commitDescription = commitMessage?.split('\n')?.slice(1)?.join('\n').trim() || '';
}}
class="shrink-0 flex-grow cursor-text resize-none overflow-x-auto overflow-y-auto border border-white bg-white p-2 font-mono text-dark-700 outline-none hover:border-light-400 focus:border-purple-600 focus:ring-0 dark:border-dark-500 dark:bg-dark-700 dark:text-light-400 dark:hover:border-dark-300"
placeholder="Your commit message here"
rows={messageRows}
required
/>
</div>
<div class="flex flex-grow justify-end gap-2 px-2">
<Button
tabindex={-1}
kind="outlined"
class="text-light-500"
height="small"
icon={IconAISparkles}
on:click={() => toasts.error('Not implemented yet')}
>
Generate message
</Button>
<Button
class="w-20"
height="small"
on:click={() => {
if (commitMessage) commit();
commitDialogShown = false;
}}
>
Commit
</Button>
</div>
</div>
{/if}
<div class="flex flex-shrink flex-col gap-y-2">
<div class="drop-zone-marker hidden border p-6 text-center">
Drop here to add to virtual branch
@ -319,57 +356,4 @@
{/each}
</div>
</div>
<!-- Commit modal -->
<Modal icon={IconBranch} bind:this={commitBranchModal}>
<svelte:fragment slot="title">{name}</svelte:fragment>
<div class="flex w-full flex-col gap-y-2">
<div class="flex items-center gap-x-2">
<input
bind:this={commitTiteInput}
bind:value={commitTitle}
on:change={onUpdateFromModal}
on:keydown={(e) => {
if (e.key == 'Enter') descriptionTextArea.focus();
}}
class="h-6 shrink-0 flex-grow cursor-text resize-none overflow-x-auto overflow-y-auto rounded border-0 bg-white p-0 font-mono text-xl text-dark-700 outline-none focus:ring-0 dark:bg-dark-1000 dark:text-white"
placeholder="Your commit title"
required
/>
<Button
tabindex={-1}
kind="outlined"
class="text-light-500"
height="small"
icon={IconAISparkles}
on:click={() => toasts.error('Not implemented yet')}
/>
</div>
<textarea
bind:this={descriptionTextArea}
bind:value={commitDescription}
on:change={onUpdateFromModal}
class="shrink-0 flex-grow cursor-text resize-none overflow-x-auto overflow-y-auto rounded border-0 bg-white p-0 font-mono text-light-800 outline-none focus:ring-0 dark:bg-dark-1000 dark:text-dark-50"
placeholder="Your commit message here"
rows={descriptionRows}
required
/>
</div>
<svelte:fragment slot="controls" let:close>
<Button height="small" kind="outlined" on:click={close}>Cancel</Button>
<Button
height="small"
color="purple"
on:click={() => {
if (commitMessage) commit();
close();
}}
>
Commit
</Button>
</svelte:fragment>
</Modal>
</div>