mirror of
https://github.com/kmc7468/arkvault.git
synced 2025-12-14 22:08:45 +00:00
Modal, AdaptiveDiv, BottomDiv 컴포넌트를 molecules 디렉터리로 이동 및 리팩토링
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { Snippet } from "svelte";
|
import type { Snippet } from "svelte";
|
||||||
import { fade, fly } from "svelte/transition";
|
import { fade, fly } from "svelte/transition";
|
||||||
import { AdaptiveDiv } from "$lib/components/divs";
|
import { AdaptiveDiv } from "$lib/components/atoms";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
children: Snippet;
|
children: Snippet;
|
||||||
|
|||||||
@@ -1,35 +1,30 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { Snippet } from "svelte";
|
import type { Snippet } from "svelte";
|
||||||
|
import type { ClassValue } from "svelte/elements";
|
||||||
import { fade } from "svelte/transition";
|
import { fade } from "svelte/transition";
|
||||||
import { AdaptiveDiv } from "$lib/components/divs";
|
import { AdaptiveDiv } from "$lib/components/atoms";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
children: Snippet;
|
children?: Snippet;
|
||||||
onclose?: () => void;
|
class?: ClassValue;
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
|
onclose?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
let { children, onclose, isOpen = $bindable() }: Props = $props();
|
let { children, isOpen = $bindable(), onclose, ...props }: Props = $props();
|
||||||
|
|
||||||
const closeModal = $derived(
|
|
||||||
onclose ||
|
|
||||||
(() => {
|
|
||||||
isOpen = false;
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if isOpen}
|
{#if isOpen}
|
||||||
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
||||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||||
<div
|
<div
|
||||||
onclick={closeModal}
|
onclick={onclose || (() => (isOpen = false))}
|
||||||
class="fixed inset-0 z-10 bg-black bg-opacity-50"
|
class="fixed inset-0 z-10 bg-black bg-opacity-50"
|
||||||
transition:fade={{ duration: 100 }}
|
transition:fade={{ duration: 100 }}
|
||||||
>
|
>
|
||||||
<AdaptiveDiv>
|
<AdaptiveDiv class="h-full">
|
||||||
<div class="flex h-full items-center justify-center px-4">
|
<div class="flex h-full items-center justify-center px-4">
|
||||||
<div onclick={(e) => e.stopPropagation()} class="rounded-2xl bg-white p-4">
|
<div onclick={(e) => e.stopPropagation()} class={["rounded-2xl bg-white p-4", props.class]}>
|
||||||
{@render children?.()}
|
{@render children?.()}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { Component } from "svelte";
|
import type { Component } from "svelte";
|
||||||
import type { ClassValue, SvelteHTMLElements } from "svelte/elements";
|
import type { ClassValue, SvelteHTMLElements } from "svelte/elements";
|
||||||
import { AdaptiveDiv } from "$lib/components/divs";
|
import { AdaptiveDiv } from "$lib/components/atoms";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
icon: Component<SvelteHTMLElements["svg"]>;
|
icon: Component<SvelteHTMLElements["svg"]>;
|
||||||
|
|||||||
15
src/lib/components/atoms/divs/AdaptiveDiv.svelte
Normal file
15
src/lib/components/atoms/divs/AdaptiveDiv.svelte
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import type { Snippet } from "svelte";
|
||||||
|
import type { ClassValue } from "svelte/elements";
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
children?: Snippet;
|
||||||
|
class?: ClassValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
let { children, ...props }: Props = $props();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class={["mx-auto w-full max-w-screen-md", props.class]}>
|
||||||
|
{@render children?.()}
|
||||||
|
</div>
|
||||||
15
src/lib/components/atoms/divs/BottomDiv.svelte
Normal file
15
src/lib/components/atoms/divs/BottomDiv.svelte
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import type { Snippet } from "svelte";
|
||||||
|
import type { ClassValue } from "svelte/elements";
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
children?: Snippet;
|
||||||
|
class?: ClassValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
let { children, ...props }: Props = $props();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class={["sticky bottom-0 bg-white pb-4", props.class]}>
|
||||||
|
{@render children?.()}
|
||||||
|
</div>
|
||||||
2
src/lib/components/atoms/divs/index.ts
Normal file
2
src/lib/components/atoms/divs/index.ts
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
export { default as AdaptiveDiv } from "./AdaptiveDiv.svelte";
|
||||||
|
export { default as BottomDiv } from "./BottomDiv.svelte";
|
||||||
@@ -1,2 +1,4 @@
|
|||||||
export * from "./buttons";
|
export * from "./buttons";
|
||||||
|
export * from "./divs";
|
||||||
export * from "./inputs";
|
export * from "./inputs";
|
||||||
|
export { default as Modal } from "./Modal.svelte";
|
||||||
|
|||||||
@@ -1,26 +1,31 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import type { ClassValue } from "svelte/elements";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
class?: ClassValue;
|
||||||
placeholder: string;
|
placeholder: string;
|
||||||
type?: "text" | "password";
|
type?: "text" | "password";
|
||||||
value?: string;
|
value?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
let { placeholder, type = "text", value = $bindable("") }: Props = $props();
|
let { placeholder, type = "text", value = $bindable(""), ...props }: Props = $props();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="relative mt-5">
|
<div class={props.class}>
|
||||||
<input
|
<div class="relative mt-5">
|
||||||
bind:value
|
<input
|
||||||
{type}
|
bind:value
|
||||||
placeholder=""
|
{type}
|
||||||
class="w-full border-b-2 border-gray-300 py-1 text-xl outline-none transition duration-300 ease-in-out"
|
placeholder=""
|
||||||
/>
|
class="w-full border-b-2 border-gray-300 py-1 text-xl outline-none transition duration-300 ease-in-out"
|
||||||
<!-- svelte-ignore a11y_label_has_associated_control -->
|
/>
|
||||||
<label
|
<!-- svelte-ignore a11y_label_has_associated_control -->
|
||||||
class="pointer-events-none absolute left-0 top-1/2 -translate-y-1/2 transform text-xl text-gray-400 transition-all duration-300 ease-in-out"
|
<label
|
||||||
>
|
class="pointer-events-none absolute left-0 top-1/2 -translate-y-1/2 transform text-xl text-gray-400 transition-all duration-300 ease-in-out"
|
||||||
{placeholder}
|
>
|
||||||
</label>
|
{placeholder}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
let { children } = $props();
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div class="mx-auto h-full w-full max-w-screen-md">
|
|
||||||
{@render children?.()}
|
|
||||||
</div>
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
let { children } = $props();
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div class="sticky bottom-0 flex flex-col items-center gap-y-2 bg-white pb-4">
|
|
||||||
{@render children?.()}
|
|
||||||
</div>
|
|
||||||
@@ -1,3 +1 @@
|
|||||||
export { default as AdaptiveDiv } from "./AdaptiveDiv.svelte";
|
|
||||||
export { default as BottomDiv } from "./BottomDiv.svelte";
|
|
||||||
export { default as TitleDiv } from "./TitleDiv.svelte";
|
export { default as TitleDiv } from "./TitleDiv.svelte";
|
||||||
|
|||||||
@@ -1,3 +1,2 @@
|
|||||||
export { default as BottomSheet } from "./BottomSheet.svelte";
|
export { default as BottomSheet } from "./BottomSheet.svelte";
|
||||||
export { default as Modal } from "./Modal.svelte";
|
|
||||||
export { default as TopBar } from "./TopBar.svelte";
|
export { default as TopBar } from "./TopBar.svelte";
|
||||||
|
|||||||
48
src/lib/components/molecules/ActionModal.svelte
Normal file
48
src/lib/components/molecules/ActionModal.svelte
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
<script module lang="ts">
|
||||||
|
export type ConfirmHandler = () => void | Promise<void> | boolean | Promise<boolean>;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
import type { Snippet } from "svelte";
|
||||||
|
import { Button, Modal } from "$lib/components/atoms";
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
cancelText?: string;
|
||||||
|
children?: Snippet;
|
||||||
|
confirmText: string;
|
||||||
|
isOpen: boolean;
|
||||||
|
onbeforeclose?: () => void;
|
||||||
|
onconfirm: ConfirmHandler;
|
||||||
|
title: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
let {
|
||||||
|
cancelText = "닫기",
|
||||||
|
children,
|
||||||
|
confirmText,
|
||||||
|
isOpen = $bindable(),
|
||||||
|
onbeforeclose,
|
||||||
|
onconfirm,
|
||||||
|
title,
|
||||||
|
}: Props = $props();
|
||||||
|
|
||||||
|
const closeModal = () => {
|
||||||
|
onbeforeclose?.();
|
||||||
|
isOpen = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
const confirmAction = async () => {
|
||||||
|
if ((await onconfirm()) !== false) {
|
||||||
|
closeModal();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Modal bind:isOpen onclose={closeModal} class="flex flex-col gap-y-2">
|
||||||
|
<p class="text-xl font-bold">{title}</p>
|
||||||
|
{@render children?.()}
|
||||||
|
<div class="flex gap-x-2">
|
||||||
|
<Button color="gray" onclick={closeModal} class="flex-1">{cancelText}</Button>
|
||||||
|
<Button onclick={confirmAction} class="flex-1">{confirmText}</Button>
|
||||||
|
</div>
|
||||||
|
</Modal>
|
||||||
2
src/lib/components/molecules/index.ts
Normal file
2
src/lib/components/molecules/index.ts
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
export * from "./ActionModal.svelte";
|
||||||
|
export { default as ActionModal } from "./ActionModal.svelte";
|
||||||
1
src/lib/components/organisms/index.ts
Normal file
1
src/lib/components/organisms/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export * from "./modals";
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { TextInputModal } from "$lib/components/organisms";
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
isOpen: boolean;
|
||||||
|
oncreate: (name: string) => Promise<boolean>;
|
||||||
|
}
|
||||||
|
|
||||||
|
let { isOpen = $bindable(), oncreate }: Props = $props();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<TextInputModal
|
||||||
|
bind:isOpen
|
||||||
|
title="새 카테고리"
|
||||||
|
placeholder="카테고리 이름"
|
||||||
|
submitText="만들기"
|
||||||
|
onsubmit={oncreate}
|
||||||
|
/>
|
||||||
22
src/lib/components/organisms/modals/RenameModal.svelte
Normal file
22
src/lib/components/organisms/modals/RenameModal.svelte
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { TextInputModal } from "$lib/components/organisms";
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
isOpen: boolean;
|
||||||
|
onbeforeclose?: () => void;
|
||||||
|
onrename: (newName: string) => Promise<boolean>;
|
||||||
|
originalName: string | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
let { isOpen = $bindable(), onbeforeclose, onrename, originalName }: Props = $props();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<TextInputModal
|
||||||
|
bind:isOpen
|
||||||
|
{onbeforeclose}
|
||||||
|
title="이름 바꾸기"
|
||||||
|
placeholder="이름"
|
||||||
|
defaultValue={originalName}
|
||||||
|
submitText="바꾸기"
|
||||||
|
onsubmit={onrename}
|
||||||
|
/>
|
||||||
42
src/lib/components/organisms/modals/TextInputModal.svelte
Normal file
42
src/lib/components/organisms/modals/TextInputModal.svelte
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { TextInput } from "$lib/components/atoms";
|
||||||
|
import { ActionModal, type ConfirmHandler } from "$lib/components/molecules";
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
defaultValue?: string;
|
||||||
|
isOpen: boolean;
|
||||||
|
onbeforeclose?: () => void;
|
||||||
|
onsubmit: (value: string) => ReturnType<ConfirmHandler>;
|
||||||
|
placeholder: string;
|
||||||
|
submitText: string;
|
||||||
|
title: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
let {
|
||||||
|
defaultValue = "",
|
||||||
|
isOpen = $bindable(),
|
||||||
|
onbeforeclose,
|
||||||
|
onsubmit,
|
||||||
|
placeholder,
|
||||||
|
submitText,
|
||||||
|
title,
|
||||||
|
}: Props = $props();
|
||||||
|
|
||||||
|
let value = $state(defaultValue);
|
||||||
|
|
||||||
|
$effect.pre(() => {
|
||||||
|
if (isOpen) {
|
||||||
|
value = defaultValue;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<ActionModal
|
||||||
|
bind:isOpen
|
||||||
|
{onbeforeclose}
|
||||||
|
{title}
|
||||||
|
confirmText={submitText}
|
||||||
|
onconfirm={() => onsubmit(value)}
|
||||||
|
>
|
||||||
|
<TextInput bind:value {placeholder} class="mb-5" />
|
||||||
|
</ActionModal>
|
||||||
3
src/lib/components/organisms/modals/index.ts
Normal file
3
src/lib/components/organisms/modals/index.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export { default as CategoryCreateModal } from "./CategoryCreateModal.svelte";
|
||||||
|
export { default as RenameModal } from "./RenameModal.svelte";
|
||||||
|
export { default as TextInputModal } from "./TextInputModal.svelte";
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
import { Modal } from "$lib/components";
|
|
||||||
import { Button, TextInput } from "$lib/components/atoms";
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
onCreateClick: (name: string) => void;
|
|
||||||
isOpen: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
let { onCreateClick, isOpen = $bindable() }: Props = $props();
|
|
||||||
|
|
||||||
let name = $state("");
|
|
||||||
|
|
||||||
const closeModal = () => {
|
|
||||||
name = "";
|
|
||||||
isOpen = false;
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<Modal bind:isOpen onclose={closeModal}>
|
|
||||||
<p class="text-xl font-bold">새 카테고리</p>
|
|
||||||
<div class="mt-2 flex w-full">
|
|
||||||
<TextInput bind:value={name} placeholder="카테고리 이름" />
|
|
||||||
</div>
|
|
||||||
<div class="mt-7 flex gap-x-2">
|
|
||||||
<Button color="gray" onclick={closeModal} class="flex-1">닫기</Button>
|
|
||||||
<Button onclick={() => onCreateClick(name)} class="flex-1">만들기</Button>
|
|
||||||
</div>
|
|
||||||
</Modal>
|
|
||||||
@@ -10,7 +10,8 @@ export const requestCategoryCreation = async (
|
|||||||
) => {
|
) => {
|
||||||
const { dataKey, dataKeyVersion } = await generateDataKey();
|
const { dataKey, dataKeyVersion } = await generateDataKey();
|
||||||
const nameEncrypted = await encryptString(name, dataKey);
|
const nameEncrypted = await encryptString(name, dataKey);
|
||||||
await callPostApi<CategoryCreateRequest>("/api/category/create", {
|
|
||||||
|
const res = await callPostApi<CategoryCreateRequest>("/api/category/create", {
|
||||||
parent: parentId,
|
parent: parentId,
|
||||||
mekVersion: masterKey.version,
|
mekVersion: masterKey.version,
|
||||||
dek: await wrapDataKey(dataKey, masterKey.key),
|
dek: await wrapDataKey(dataKey, masterKey.key),
|
||||||
@@ -18,6 +19,7 @@ export const requestCategoryCreation = async (
|
|||||||
name: nameEncrypted.ciphertext,
|
name: nameEncrypted.ciphertext,
|
||||||
nameIv: nameEncrypted.iv,
|
nameIv: nameEncrypted.iv,
|
||||||
});
|
});
|
||||||
|
return res.ok;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const requestFileRemovalFromCategory = async (fileId: number, categoryId: number) => {
|
export const requestFileRemovalFromCategory = async (fileId: number, categoryId: number) => {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { AdaptiveDiv } from "$lib/components/divs";
|
import { AdaptiveDiv } from "$lib/components/atoms";
|
||||||
|
|
||||||
let { children } = $props();
|
let { children } = $props();
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { goto } from "$app/navigation";
|
import { goto } from "$app/navigation";
|
||||||
import { TopBar } from "$lib/components";
|
import { TopBar } from "$lib/components";
|
||||||
import { Button, TextInput } from "$lib/components/atoms";
|
import { Button, BottomDiv, TextInput } from "$lib/components/atoms";
|
||||||
import { TitleDiv, BottomDiv } from "$lib/components/divs";
|
import { TitleDiv } from "$lib/components/divs";
|
||||||
import { requestPasswordChange } from "./service";
|
import { requestPasswordChange } from "./service";
|
||||||
|
|
||||||
let oldPassword = $state("");
|
let oldPassword = $state("");
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { goto } from "$app/navigation";
|
import { goto } from "$app/navigation";
|
||||||
import { Button, TextButton, TextInput } from "$lib/components/atoms";
|
import { Button, TextButton, BottomDiv, TextInput } from "$lib/components/atoms";
|
||||||
import { TitleDiv, BottomDiv } from "$lib/components/divs";
|
import { TitleDiv } from "$lib/components/divs";
|
||||||
import { clientKeyStore, masterKeyStore } from "$lib/stores";
|
import { clientKeyStore, masterKeyStore } from "$lib/stores";
|
||||||
import { requestLogin, requestSessionUpgrade, requestMasterKeyDownload } from "./service";
|
import { requestLogin, requestSessionUpgrade, requestMasterKeyDownload } from "./service";
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@
|
|||||||
<TextInput bind:value={password} placeholder="비밀번호" type="password" />
|
<TextInput bind:value={password} placeholder="비밀번호" type="password" />
|
||||||
</div>
|
</div>
|
||||||
</TitleDiv>
|
</TitleDiv>
|
||||||
<BottomDiv>
|
<BottomDiv class="flex flex-col items-center gap-y-2">
|
||||||
<Button onclick={login} class="w-full">로그인</Button>
|
<Button onclick={login} class="w-full">로그인</Button>
|
||||||
<TextButton>계정이 없어요</TextButton>
|
<TextButton>계정이 없어요</TextButton>
|
||||||
</BottomDiv>
|
</BottomDiv>
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { Writable } from "svelte/store";
|
import type { Writable } from "svelte/store";
|
||||||
import { BottomSheet } from "$lib/components";
|
import { BottomSheet } from "$lib/components";
|
||||||
import { Button } from "$lib/components/atoms";
|
import { Button, BottomDiv } from "$lib/components/atoms";
|
||||||
import { BottomDiv } from "$lib/components/divs";
|
import { CategoryCreateModal } from "$lib/components/organisms/modals";
|
||||||
import { getCategoryInfo, type CategoryInfo } from "$lib/modules/filesystem";
|
import { getCategoryInfo, type CategoryInfo } from "$lib/modules/filesystem";
|
||||||
import SubCategories from "$lib/molecules/SubCategories.svelte";
|
import SubCategories from "$lib/molecules/SubCategories.svelte";
|
||||||
import CreateCategoryModal from "$lib/organisms/CreateCategoryModal.svelte";
|
|
||||||
import { masterKeyStore } from "$lib/stores";
|
import { masterKeyStore } from "$lib/stores";
|
||||||
import { requestCategoryCreation } from "./service";
|
import { requestCategoryCreation } from "./service";
|
||||||
|
|
||||||
@@ -18,15 +17,7 @@
|
|||||||
|
|
||||||
let category: Writable<CategoryInfo | null> | undefined = $state();
|
let category: Writable<CategoryInfo | null> | undefined = $state();
|
||||||
|
|
||||||
let isCreateCategoryModalOpen = $state(false);
|
let isCategoryCreateModalOpen = $state(false);
|
||||||
|
|
||||||
const createCategory = async (name: string) => {
|
|
||||||
if (!$category) return; // TODO: Error handling
|
|
||||||
|
|
||||||
await requestCategoryCreation(name, $category.id, $masterKeyStore?.get(1)!);
|
|
||||||
isCreateCategoryModalOpen = false;
|
|
||||||
category = getCategoryInfo($category.id, $masterKeyStore?.get(1)?.key!); // TODO: FIXME
|
|
||||||
};
|
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
if (isOpen) {
|
if (isOpen) {
|
||||||
@@ -43,7 +34,7 @@
|
|||||||
info={$category}
|
info={$category}
|
||||||
onSubCategoryClick={({ id }) =>
|
onSubCategoryClick={({ id }) =>
|
||||||
(category = getCategoryInfo(id, $masterKeyStore?.get(1)?.key!))}
|
(category = getCategoryInfo(id, $masterKeyStore?.get(1)?.key!))}
|
||||||
onSubCategoryCreateClick={() => (isCreateCategoryModalOpen = true)}
|
onSubCategoryCreateClick={() => (isCategoryCreateModalOpen = true)}
|
||||||
subCategoryCreatePosition="top"
|
subCategoryCreatePosition="top"
|
||||||
/>
|
/>
|
||||||
{#if $category.id !== "root"}
|
{#if $category.id !== "root"}
|
||||||
@@ -57,4 +48,13 @@
|
|||||||
</div>
|
</div>
|
||||||
</BottomSheet>
|
</BottomSheet>
|
||||||
|
|
||||||
<CreateCategoryModal bind:isOpen={isCreateCategoryModalOpen} onCreateClick={createCategory} />
|
<CategoryCreateModal
|
||||||
|
bind:isOpen={isCategoryCreateModalOpen}
|
||||||
|
oncreate={async (name: string) => {
|
||||||
|
if (await requestCategoryCreation(name, $category!.id, $masterKeyStore?.get(1)!)) {
|
||||||
|
category = getCategoryInfo($category!.id, $masterKeyStore?.get(1)?.key!); // TODO: FIXME
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import FileSaver from "file-saver";
|
import FileSaver from "file-saver";
|
||||||
import { goto } from "$app/navigation";
|
import { goto } from "$app/navigation";
|
||||||
import { Button, TextButton } from "$lib/components/atoms";
|
import { Button, TextButton, BottomDiv } from "$lib/components/atoms";
|
||||||
import { TitleDiv, BottomDiv } from "$lib/components/divs";
|
import { TitleDiv } from "$lib/components/divs";
|
||||||
import { clientKeyStore } from "$lib/stores";
|
import { clientKeyStore } from "$lib/stores";
|
||||||
import BeforeContinueBottomSheet from "./BeforeContinueBottomSheet.svelte";
|
import BeforeContinueBottomSheet from "./BeforeContinueBottomSheet.svelte";
|
||||||
import BeforeContinueModal from "./BeforeContinueModal.svelte";
|
import BeforeContinueModal from "./BeforeContinueModal.svelte";
|
||||||
@@ -100,7 +100,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</TitleDiv>
|
</TitleDiv>
|
||||||
<BottomDiv>
|
<BottomDiv class="flex flex-col items-center gap-y-2">
|
||||||
<Button onclick={exportClientKeys} class="w-full">암호 키 내보내기</Button>
|
<Button onclick={exportClientKeys} class="w-full">암호 키 내보내기</Button>
|
||||||
<TextButton onclick={() => (isBeforeContinueModalOpen = true)}>내보내지 않을래요</TextButton>
|
<TextButton onclick={() => (isBeforeContinueModalOpen = true)}>내보내지 않을래요</TextButton>
|
||||||
</BottomDiv>
|
</BottomDiv>
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { BottomSheet } from "$lib/components";
|
import { BottomSheet } from "$lib/components";
|
||||||
import { Button } from "$lib/components/atoms";
|
import { Button, BottomDiv } from "$lib/components/atoms";
|
||||||
import { BottomDiv } from "$lib/components/divs";
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
onRetryClick: () => void;
|
onRetryClick: () => void;
|
||||||
@@ -21,11 +20,9 @@
|
|||||||
한 번 확인해 주세요.
|
한 번 확인해 주세요.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<BottomDiv>
|
<BottomDiv class="flex gap-x-2">
|
||||||
<div class="flex w-full gap-x-2">
|
<Button color="gray" onclick={onRetryClick} class="flex-1">다시 저장할래요</Button>
|
||||||
<Button color="gray" onclick={onRetryClick} class="flex-1">다시 저장할래요</Button>
|
<Button onclick={onContinueClick} class="flex-1">잘 저장되었어요</Button>
|
||||||
<Button onclick={onContinueClick} class="flex-1">잘 저장되었어요</Button>
|
|
||||||
</div>
|
|
||||||
</BottomDiv>
|
</BottomDiv>
|
||||||
</div>
|
</div>
|
||||||
</BottomSheet>
|
</BottomSheet>
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Modal } from "$lib/components";
|
import { Button, Modal } from "$lib/components/atoms";
|
||||||
import { Button } from "$lib/components/atoms";
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
onContinueClick: () => void;
|
onContinueClick: () => void;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { onMount } from "svelte";
|
import { onMount } from "svelte";
|
||||||
import { goto } from "$app/navigation";
|
import { goto } from "$app/navigation";
|
||||||
import { Button, TextButton } from "$lib/components/atoms";
|
import { Button, TextButton, BottomDiv } from "$lib/components/atoms";
|
||||||
import { TitleDiv, BottomDiv } from "$lib/components/divs";
|
import { TitleDiv } from "$lib/components/divs";
|
||||||
import { gotoStateful } from "$lib/hooks";
|
import { gotoStateful } from "$lib/hooks";
|
||||||
import { clientKeyStore } from "$lib/stores";
|
import { clientKeyStore } from "$lib/stores";
|
||||||
import Order from "./Order.svelte";
|
import Order from "./Order.svelte";
|
||||||
@@ -79,7 +79,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</TitleDiv>
|
</TitleDiv>
|
||||||
<BottomDiv>
|
<BottomDiv class="flex flex-col items-center gap-y-2">
|
||||||
<Button onclick={generateKeys} class="w-full">새 암호 키 생성하기</Button>
|
<Button onclick={generateKeys} class="w-full">새 암호 키 생성하기</Button>
|
||||||
<TextButton>키를 갖고 있어요</TextButton>
|
<TextButton>키를 갖고 있어요</TextButton>
|
||||||
</BottomDiv>
|
</BottomDiv>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { AdaptiveDiv } from "$lib/components/divs";
|
import { AdaptiveDiv } from "$lib/components/atoms";
|
||||||
import BottomBar from "./BottomBar.svelte";
|
import BottomBar from "./BottomBar.svelte";
|
||||||
|
|
||||||
let { children } = $props();
|
let { children } = $props();
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
<div class="flex h-screen flex-col justify-between">
|
<div class="flex h-screen flex-col justify-between">
|
||||||
<div class="flex-grow">
|
<div class="flex-grow">
|
||||||
<AdaptiveDiv>
|
<AdaptiveDiv class="h-full">
|
||||||
{@render children()}
|
{@render children()}
|
||||||
</AdaptiveDiv>
|
</AdaptiveDiv>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { goto } from "$app/navigation";
|
import { goto } from "$app/navigation";
|
||||||
import { page } from "$app/state";
|
import { page } from "$app/state";
|
||||||
import { AdaptiveDiv } from "$lib/components/divs";
|
import { AdaptiveDiv } from "$lib/components/atoms";
|
||||||
|
|
||||||
import IconHome from "~icons/material-symbols/home";
|
import IconHome from "~icons/material-symbols/home";
|
||||||
import IconFolder from "~icons/material-symbols/folder";
|
import IconFolder from "~icons/material-symbols/folder";
|
||||||
|
|||||||
@@ -2,14 +2,13 @@
|
|||||||
import type { Writable } from "svelte/store";
|
import type { Writable } from "svelte/store";
|
||||||
import { goto } from "$app/navigation";
|
import { goto } from "$app/navigation";
|
||||||
import { TopBar } from "$lib/components";
|
import { TopBar } from "$lib/components";
|
||||||
|
import { CategoryCreateModal, RenameModal } from "$lib/components/organisms";
|
||||||
import { getCategoryInfo, type CategoryInfo } from "$lib/modules/filesystem";
|
import { getCategoryInfo, type CategoryInfo } from "$lib/modules/filesystem";
|
||||||
import type { SelectedCategory } from "$lib/molecules/Categories";
|
import type { SelectedCategory } from "$lib/molecules/Categories";
|
||||||
import Category from "$lib/organisms/Category";
|
import Category from "$lib/organisms/Category";
|
||||||
import CreateCategoryModal from "$lib/organisms/CreateCategoryModal.svelte";
|
|
||||||
import { masterKeyStore } from "$lib/stores";
|
import { masterKeyStore } from "$lib/stores";
|
||||||
import CategoryMenuBottomSheet from "./CategoryMenuBottomSheet.svelte";
|
import CategoryMenuBottomSheet from "./CategoryMenuBottomSheet.svelte";
|
||||||
import DeleteCategoryModal from "./DeleteCategoryModal.svelte";
|
import DeleteCategoryModal from "./DeleteCategoryModal.svelte";
|
||||||
import RenameCategoryModal from "./RenameCategoryModal.svelte";
|
|
||||||
import {
|
import {
|
||||||
requestCategoryCreation,
|
requestCategoryCreation,
|
||||||
requestFileRemovalFromCategory,
|
requestFileRemovalFromCategory,
|
||||||
@@ -24,17 +23,11 @@
|
|||||||
|
|
||||||
let isFileRecursive = $state(false);
|
let isFileRecursive = $state(false);
|
||||||
|
|
||||||
let isCreateCategoryModalOpen = $state(false);
|
let isCategoryCreateModalOpen = $state(false);
|
||||||
let isSubCategoryMenuBottomSheetOpen = $state(false);
|
let isSubCategoryMenuBottomSheetOpen = $state(false);
|
||||||
let isRenameCategoryModalOpen = $state(false);
|
let isCategoryRenameModalOpen = $state(false);
|
||||||
let isDeleteCategoryModalOpen = $state(false);
|
let isDeleteCategoryModalOpen = $state(false);
|
||||||
|
|
||||||
const createCategory = async (name: string) => {
|
|
||||||
await requestCategoryCreation(name, data.id, $masterKeyStore?.get(1)!);
|
|
||||||
isCreateCategoryModalOpen = false;
|
|
||||||
info = getCategoryInfo(data.id, $masterKeyStore?.get(1)?.key!); // TODO: FIXME
|
|
||||||
};
|
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
info = getCategoryInfo(data.id, $masterKeyStore?.get(1)?.key!);
|
info = getCategoryInfo(data.id, $masterKeyStore?.get(1)?.key!);
|
||||||
});
|
});
|
||||||
@@ -59,7 +52,7 @@
|
|||||||
info = getCategoryInfo(data.id, $masterKeyStore?.get(1)?.key!); // TODO: FIXME
|
info = getCategoryInfo(data.id, $masterKeyStore?.get(1)?.key!); // TODO: FIXME
|
||||||
}}
|
}}
|
||||||
onSubCategoryClick={({ id }) => goto(`/category/${id}`)}
|
onSubCategoryClick={({ id }) => goto(`/category/${id}`)}
|
||||||
onSubCategoryCreateClick={() => (isCreateCategoryModalOpen = true)}
|
onSubCategoryCreateClick={() => (isCategoryCreateModalOpen = true)}
|
||||||
onSubCategoryMenuClick={(subCategory) => {
|
onSubCategoryMenuClick={(subCategory) => {
|
||||||
selectedSubCategory = subCategory;
|
selectedSubCategory = subCategory;
|
||||||
isSubCategoryMenuBottomSheetOpen = true;
|
isSubCategoryMenuBottomSheetOpen = true;
|
||||||
@@ -69,26 +62,35 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<CreateCategoryModal bind:isOpen={isCreateCategoryModalOpen} onCreateClick={createCategory} />
|
<CategoryCreateModal
|
||||||
|
bind:isOpen={isCategoryCreateModalOpen}
|
||||||
|
oncreate={async (name: string) => {
|
||||||
|
if (await requestCategoryCreation(name, data.id, $masterKeyStore?.get(1)!)) {
|
||||||
|
info = getCategoryInfo(data.id, $masterKeyStore?.get(1)?.key!); // TODO: FIXME
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
<CategoryMenuBottomSheet
|
<CategoryMenuBottomSheet
|
||||||
bind:isOpen={isSubCategoryMenuBottomSheetOpen}
|
bind:isOpen={isSubCategoryMenuBottomSheetOpen}
|
||||||
bind:selectedCategory={selectedSubCategory}
|
bind:selectedCategory={selectedSubCategory}
|
||||||
onRenameClick={() => {
|
onRenameClick={() => {
|
||||||
isSubCategoryMenuBottomSheetOpen = false;
|
isSubCategoryMenuBottomSheetOpen = false;
|
||||||
isRenameCategoryModalOpen = true;
|
isCategoryRenameModalOpen = true;
|
||||||
}}
|
}}
|
||||||
onDeleteClick={() => {
|
onDeleteClick={() => {
|
||||||
isSubCategoryMenuBottomSheetOpen = false;
|
isSubCategoryMenuBottomSheetOpen = false;
|
||||||
isDeleteCategoryModalOpen = true;
|
isDeleteCategoryModalOpen = true;
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<RenameCategoryModal
|
<RenameModal
|
||||||
bind:isOpen={isRenameCategoryModalOpen}
|
bind:isOpen={isCategoryRenameModalOpen}
|
||||||
bind:selectedCategory={selectedSubCategory}
|
onbeforeclose={() => (selectedSubCategory = undefined)}
|
||||||
onRenameClick={async (newName) => {
|
originalName={selectedSubCategory?.name}
|
||||||
if (selectedSubCategory) {
|
onrename={async (newName: string) => {
|
||||||
await requestCategoryRename(selectedSubCategory, newName);
|
if (await requestCategoryRename(selectedSubCategory!, newName)) {
|
||||||
info = getCategoryInfo(data.id, $masterKeyStore?.get(1)?.key!); // TODO: FIXME
|
info = getCategoryInfo(data.id, $masterKeyStore?.get(1)?.key!); // TODO: FIXME
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Modal } from "$lib/components";
|
import { Button, Modal } from "$lib/components/atoms";
|
||||||
import { Button } from "$lib/components/atoms";
|
|
||||||
import type { SelectedCategory } from "$lib/molecules/Categories";
|
import type { SelectedCategory } from "$lib/molecules/Categories";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
|||||||
@@ -1,46 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
import { Modal } from "$lib/components";
|
|
||||||
import { Button, TextInput } from "$lib/components/atoms";
|
|
||||||
import type { SelectedCategory } from "$lib/molecules/Categories";
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
onRenameClick: (newName: string) => Promise<boolean>;
|
|
||||||
isOpen: boolean;
|
|
||||||
selectedCategory: SelectedCategory | undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
let { onRenameClick, isOpen = $bindable(), selectedCategory = $bindable() }: Props = $props();
|
|
||||||
|
|
||||||
let name = $state("");
|
|
||||||
|
|
||||||
const closeModal = () => {
|
|
||||||
name = "";
|
|
||||||
isOpen = false;
|
|
||||||
selectedCategory = undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
const renameCategory = async () => {
|
|
||||||
// TODO: Validation
|
|
||||||
|
|
||||||
if (await onRenameClick(name)) {
|
|
||||||
closeModal();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
$effect(() => {
|
|
||||||
if (selectedCategory) {
|
|
||||||
name = selectedCategory.name;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<Modal bind:isOpen onclose={closeModal}>
|
|
||||||
<p class="text-xl font-bold">이름 바꾸기</p>
|
|
||||||
<div class="mt-2 flex w-full">
|
|
||||||
<TextInput bind:value={name} placeholder="이름" />
|
|
||||||
</div>
|
|
||||||
<div class="mt-7 flex gap-x-2">
|
|
||||||
<Button color="gray" onclick={closeModal} class="flex-1">닫기</Button>
|
|
||||||
<Button onclick={renameCategory} class="flex-1">바꾸기</Button>
|
|
||||||
</div>
|
|
||||||
</Modal>
|
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
import { goto } from "$app/navigation";
|
import { goto } from "$app/navigation";
|
||||||
import { TopBar } from "$lib/components";
|
import { TopBar } from "$lib/components";
|
||||||
import { FloatingButton } from "$lib/components/atoms";
|
import { FloatingButton } from "$lib/components/atoms";
|
||||||
|
import { RenameModal } from "$lib/components/organisms";
|
||||||
import { getDirectoryInfo, type DirectoryInfo } from "$lib/modules/filesystem";
|
import { getDirectoryInfo, type DirectoryInfo } from "$lib/modules/filesystem";
|
||||||
import { masterKeyStore, hmacSecretStore } from "$lib/stores";
|
import { masterKeyStore, hmacSecretStore } from "$lib/stores";
|
||||||
import CreateBottomSheet from "./CreateBottomSheet.svelte";
|
import CreateBottomSheet from "./CreateBottomSheet.svelte";
|
||||||
@@ -13,7 +14,6 @@
|
|||||||
import DirectoryEntryMenuBottomSheet from "./DirectoryEntryMenuBottomSheet.svelte";
|
import DirectoryEntryMenuBottomSheet from "./DirectoryEntryMenuBottomSheet.svelte";
|
||||||
import DownloadStatusCard from "./DownloadStatusCard.svelte";
|
import DownloadStatusCard from "./DownloadStatusCard.svelte";
|
||||||
import DuplicateFileModal from "./DuplicateFileModal.svelte";
|
import DuplicateFileModal from "./DuplicateFileModal.svelte";
|
||||||
import RenameDirectoryEntryModal from "./RenameDirectoryEntryModal.svelte";
|
|
||||||
import UploadStatusCard from "./UploadStatusCard.svelte";
|
import UploadStatusCard from "./UploadStatusCard.svelte";
|
||||||
import {
|
import {
|
||||||
requestHmacSecretDownload,
|
requestHmacSecretDownload,
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
let isDuplicateFileModalOpen = $state(false);
|
let isDuplicateFileModalOpen = $state(false);
|
||||||
|
|
||||||
let isDirectoryEntryMenuBottomSheetOpen = $state(false);
|
let isDirectoryEntryMenuBottomSheetOpen = $state(false);
|
||||||
let isRenameDirectoryEntryModalOpen = $state(false);
|
let isDirectoryEntryRenameModalOpen = $state(false);
|
||||||
let isDeleteDirectoryEntryModalOpen = $state(false);
|
let isDeleteDirectoryEntryModalOpen = $state(false);
|
||||||
|
|
||||||
const createDirectory = async (name: string) => {
|
const createDirectory = async (name: string) => {
|
||||||
@@ -159,20 +159,23 @@
|
|||||||
bind:selectedEntry
|
bind:selectedEntry
|
||||||
onRenameClick={() => {
|
onRenameClick={() => {
|
||||||
isDirectoryEntryMenuBottomSheetOpen = false;
|
isDirectoryEntryMenuBottomSheetOpen = false;
|
||||||
isRenameDirectoryEntryModalOpen = true;
|
isDirectoryEntryRenameModalOpen = true;
|
||||||
}}
|
}}
|
||||||
onDeleteClick={() => {
|
onDeleteClick={() => {
|
||||||
isDirectoryEntryMenuBottomSheetOpen = false;
|
isDirectoryEntryMenuBottomSheetOpen = false;
|
||||||
isDeleteDirectoryEntryModalOpen = true;
|
isDeleteDirectoryEntryModalOpen = true;
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<RenameDirectoryEntryModal
|
<RenameModal
|
||||||
bind:isOpen={isRenameDirectoryEntryModalOpen}
|
bind:isOpen={isDirectoryEntryRenameModalOpen}
|
||||||
bind:selectedEntry
|
onbeforeclose={() => (selectedEntry = undefined)}
|
||||||
onRenameClick={async (newName) => {
|
originalName={selectedEntry?.name}
|
||||||
await requestDirectoryEntryRename(selectedEntry!, newName);
|
onrename={async (newName: string) => {
|
||||||
info = getDirectoryInfo(data.id, $masterKeyStore?.get(1)?.key!); // TODO: FIXME
|
if (await requestDirectoryEntryRename(selectedEntry!, newName)) {
|
||||||
return true;
|
info = getDirectoryInfo(data.id, $masterKeyStore?.get(1)?.key!); // TODO: FIXME
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<DeleteDirectoryEntryModal
|
<DeleteDirectoryEntryModal
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Modal } from "$lib/components";
|
import { Button, Modal, TextInput } from "$lib/components/atoms";
|
||||||
import { Button, TextInput } from "$lib/components/atoms";
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
onCreateClick: (name: string) => void;
|
onCreateClick: (name: string) => void;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Modal } from "$lib/components";
|
import { Button, Modal } from "$lib/components/atoms";
|
||||||
import { Button } from "$lib/components/atoms";
|
|
||||||
import type { SelectedDirectoryEntry } from "./service";
|
import type { SelectedDirectoryEntry } from "./service";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Modal } from "$lib/components";
|
import { Button, Modal } from "$lib/components/atoms";
|
||||||
import { Button } from "$lib/components/atoms";
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
file: File | undefined;
|
file: File | undefined;
|
||||||
|
|||||||
@@ -1,46 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
import { Modal } from "$lib/components";
|
|
||||||
import { Button, TextInput } from "$lib/components/atoms";
|
|
||||||
import type { SelectedDirectoryEntry } from "./service";
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
onRenameClick: (newName: string) => Promise<boolean>;
|
|
||||||
isOpen: boolean;
|
|
||||||
selectedEntry: SelectedDirectoryEntry | undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
let { onRenameClick, isOpen = $bindable(), selectedEntry = $bindable() }: Props = $props();
|
|
||||||
|
|
||||||
let name = $state("");
|
|
||||||
|
|
||||||
const closeModal = () => {
|
|
||||||
name = "";
|
|
||||||
isOpen = false;
|
|
||||||
selectedEntry = undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
const renameEntry = async () => {
|
|
||||||
// TODO: Validation
|
|
||||||
|
|
||||||
if (await onRenameClick(name)) {
|
|
||||||
closeModal();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
$effect(() => {
|
|
||||||
if (selectedEntry) {
|
|
||||||
name = selectedEntry.name;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<Modal bind:isOpen onclose={closeModal}>
|
|
||||||
<p class="text-xl font-bold">이름 바꾸기</p>
|
|
||||||
<div class="mt-2 flex w-full">
|
|
||||||
<TextInput bind:value={name} placeholder="이름" />
|
|
||||||
</div>
|
|
||||||
<div class="mt-7 flex gap-x-2">
|
|
||||||
<Button color="gray" onclick={closeModal} class="flex-1">닫기</Button>
|
|
||||||
<Button onclick={renameEntry} class="flex-1">바꾸기</Button>
|
|
||||||
</div>
|
|
||||||
</Modal>
|
|
||||||
@@ -72,19 +72,21 @@ export const requestDirectoryEntryRename = async (
|
|||||||
) => {
|
) => {
|
||||||
const newNameEncrypted = await encryptString(newName, entry.dataKey);
|
const newNameEncrypted = await encryptString(newName, entry.dataKey);
|
||||||
|
|
||||||
|
let res;
|
||||||
if (entry.type === "directory") {
|
if (entry.type === "directory") {
|
||||||
await callPostApi<DirectoryRenameRequest>(`/api/directory/${entry.id}/rename`, {
|
res = await callPostApi<DirectoryRenameRequest>(`/api/directory/${entry.id}/rename`, {
|
||||||
dekVersion: entry.dataKeyVersion.toISOString(),
|
dekVersion: entry.dataKeyVersion.toISOString(),
|
||||||
name: newNameEncrypted.ciphertext,
|
name: newNameEncrypted.ciphertext,
|
||||||
nameIv: newNameEncrypted.iv,
|
nameIv: newNameEncrypted.iv,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
await callPostApi<FileRenameRequest>(`/api/file/${entry.id}/rename`, {
|
res = await callPostApi<FileRenameRequest>(`/api/file/${entry.id}/rename`, {
|
||||||
dekVersion: entry.dataKeyVersion.toISOString(),
|
dekVersion: entry.dataKeyVersion.toISOString(),
|
||||||
name: newNameEncrypted.ciphertext,
|
name: newNameEncrypted.ciphertext,
|
||||||
nameIv: newNameEncrypted.iv,
|
nameIv: newNameEncrypted.iv,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
return res.ok;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const requestDirectoryEntryDeletion = async (entry: SelectedDirectoryEntry) => {
|
export const requestDirectoryEntryDeletion = async (entry: SelectedDirectoryEntry) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user