-
-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
475 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
apps/frontend/src/lib/components/blocks/base/duplicate-base.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<script lang="ts"> | ||
import { goto, invalidateAll } from "$app/navigation" | ||
import Button from "$lib/components/ui/button/button.svelte" | ||
import * as Dialog from "$lib/components/ui/dialog" | ||
import { closeModal, DUPLICATE_BASE_MODAL, isModalOpen } from "$lib/store/modal.store" | ||
import { trpc } from "$lib/trpc/client" | ||
import { createMutation } from "@tanstack/svelte-query" | ||
import type { Base, IBaseDTO } from "@undb/base" | ||
import { LoaderCircleIcon } from "lucide-svelte" | ||
import { toast } from "svelte-sonner" | ||
export let base: Omit<IBaseDTO, "spaceId"> | ||
const duplicateBaseMutation = createMutation({ | ||
mutationFn: trpc.base.duplicate.mutate, | ||
onSuccess: async (data) => { | ||
await invalidateAll() | ||
closeModal(DUPLICATE_BASE_MODAL) | ||
await goto(`/bases/${data}`) | ||
}, | ||
onError: (error) => { | ||
toast.error(error.message) | ||
}, | ||
}) | ||
</script> | ||
|
||
<Dialog.Root | ||
open={$isModalOpen(DUPLICATE_BASE_MODAL)} | ||
onOpenChange={(open) => { | ||
if (!open) { | ||
closeModal(DUPLICATE_BASE_MODAL) | ||
} | ||
}} | ||
> | ||
<Dialog.Content> | ||
<Dialog.Header> | ||
<Dialog.Title>Duplicate Base {base.name}</Dialog.Title> | ||
<Dialog.Description>Create a new base include all tables in base.</Dialog.Description> | ||
</Dialog.Header> | ||
|
||
<div class="item-center flex justify-end gap-2"> | ||
<Button | ||
on:click={() => { | ||
closeModal(DUPLICATE_BASE_MODAL) | ||
}} | ||
variant="outline" | ||
> | ||
Cancel | ||
</Button> | ||
<Button | ||
disabled={$duplicateBaseMutation.isPending} | ||
on:click={() => { | ||
$duplicateBaseMutation.mutate({ id: base.id }) | ||
}} | ||
> | ||
{#if $duplicateBaseMutation.isPending} | ||
<LoaderCircleIcon class="mr-2 h-5 w-5 animate-spin" /> | ||
{/if} | ||
Duplicate | ||
</Button> | ||
</div> | ||
</Dialog.Content> | ||
</Dialog.Root> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { CompositeSpecification, Ok, Result } from "@undb/domain" | ||
import type { Base } from "../base" | ||
import type { IBaseSpecVisitor } from "../interface" | ||
|
||
export class DuplicatedBaseSpecification extends CompositeSpecification<Base, IBaseSpecVisitor> { | ||
constructor( | ||
public readonly originalBase: Base, | ||
public readonly duplicatedBase: Base, | ||
) { | ||
super() | ||
} | ||
isSatisfiedBy(t: Base): boolean { | ||
throw new Error("Method not implemented.") | ||
} | ||
mutate(t: Base): Result<Base, string> { | ||
return Ok(t) | ||
} | ||
accept(v: IBaseSpecVisitor): Result<void, string> { | ||
v.duplicatedBase(this) | ||
return Ok(undefined) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
import { baseIdSchema } from "@undb/base" | ||
import { spaceIdSchema } from "@undb/space" | ||
import { z } from "@undb/zod" | ||
import { tableId } from "../table-id.vo" | ||
|
||
export const duplicateTableDTO = z.object({ | ||
tableId, | ||
baseId: baseIdSchema.optional(), | ||
spaceId: spaceIdSchema.optional(), | ||
}) | ||
|
||
export type IDuplicateTableDTO = z.infer<typeof duplicateTableDTO> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
export * from "./dto" | ||
export * from "./fields" | ||
export * from "./schema.vo" | ||
export * from "./schema.util" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.