From f26eb0fa490c25669f82a4e04185e9f21007b125 Mon Sep 17 00:00:00 2001 From: nichenqin Date: Wed, 9 Oct 2024 16:07:37 +0800 Subject: [PATCH] feat: create from shared base --- .../(share)/create-from-share/[shareId]/+page.svelte | 4 ++-- .../src/routes/(share)/s/b/[shareId]/+layout.svelte | 10 +++------- .../src/handlers/create-from-share.command-handler.ts | 6 +++++- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/apps/frontend/src/routes/(authed)/(share)/create-from-share/[shareId]/+page.svelte b/apps/frontend/src/routes/(authed)/(share)/create-from-share/[shareId]/+page.svelte index ac81bfe87..2d4cc04cf 100644 --- a/apps/frontend/src/routes/(authed)/(share)/create-from-share/[shareId]/+page.svelte +++ b/apps/frontend/src/routes/(authed)/(share)/create-from-share/[shareId]/+page.svelte @@ -99,8 +99,8 @@
- Create from template - Create a new base from a template. + Create from share + Create a new base from a shared base.
diff --git a/apps/frontend/src/routes/(share)/s/b/[shareId]/+layout.svelte b/apps/frontend/src/routes/(share)/s/b/[shareId]/+layout.svelte index 148e63e04..08b972a94 100644 --- a/apps/frontend/src/routes/(share)/s/b/[shareId]/+layout.svelte +++ b/apps/frontend/src/routes/(share)/s/b/[shareId]/+layout.svelte @@ -4,6 +4,8 @@ import type { PaneAPI } from "paneforge" import type { LayoutData } from "./$types" import Logo from "$lib/images/logo.svg" + import { Button } from "$lib/components/ui/button" + import { page } from "$app/stores" export let data: LayoutData @@ -34,13 +36,7 @@ Undb - +
diff --git a/packages/command-handlers/src/handlers/create-from-share.command-handler.ts b/packages/command-handlers/src/handlers/create-from-share.command-handler.ts index 272e0cc3b..cd30d345c 100644 --- a/packages/command-handlers/src/handlers/create-from-share.command-handler.ts +++ b/packages/command-handlers/src/handlers/create-from-share.command-handler.ts @@ -8,6 +8,7 @@ import { type ICommandHandler } from "@undb/domain" import { createLogger } from "@undb/logger" import { injectShareRepository, WithShareId, type IShareRepository } from "@undb/share" import { injectTableService, type ITableService } from "@undb/table" +import { getNextName } from "@undb/utils" @commandHandler(CreateFromShareCommand) @singleton() @@ -44,12 +45,15 @@ export class CreateFromShareCommandHandler implements ICommandHandler base.name.value) + const spec = new WithBaseId(new BaseId(baseId)).and(new WithBaseSpaceId(spaceId)) const base = (await this.baseRepository.findOne(spec)).expect("Base not found") const duplicatedBase = await this.tableService.duplicateBase(base, spaceId, targetSpaceId, { id: baseId, - name: command.name, + name: getNextName(baseNames, command.name), includeData: command.includeData, })