There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
fix: delete workspace in settings (#3030)
Peng Xiaodec0c0d3d194
diff --git a/apps/web/src/components/affine/new-workspace-setting-detail/delete-leave-workspace/delete/index.tsx b/apps/web/src/components/affine/new-workspace-setting-detail/delete-leave-workspace/delete/index.tsxindex 5f9e6d7cd8..bfbd1ffb74 100644--- a/apps/web/src/components/affine/new-workspace-setting-detail/delete-leave-workspace/delete/index.tsx+++ b/apps/web/src/components/affine/new-workspace-setting-detail/delete-leave-workspace/delete/index.tsx@@ -20,7 +20,7 @@ interface WorkspaceDeleteProps {open: boolean;onClose: () => void;workspace: AffineOfficialWorkspace;- onDeleteWorkspace: () => Promise<void>;+ onDeleteWorkspace: (id: string) => Promise<void>;}export const WorkspaceDeleteModal = ({@@ -37,16 +37,17 @@ export const WorkspaceDeleteModal = ({const t = useAFFiNEI18N();const handleDelete = useCallback(() => {- onDeleteWorkspace()+ onDeleteWorkspace(workspace.id).then(() => {toast(t['Successfully deleted'](), {portal: document.body,});+ onClose();}).catch(() => {// ignore error});- }, [onDeleteWorkspace, t]);+ }, [onClose, onDeleteWorkspace, t, workspace.id]);return (<Modal open={open} onClose={onClose}>diff --git a/apps/web/src/components/affine/new-workspace-setting-detail/index.tsx b/apps/web/src/components/affine/new-workspace-setting-detail/index.tsxindex 74569b7507..4c9a96841c 100644--- a/apps/web/src/components/affine/new-workspace-setting-detail/index.tsx+++ b/apps/web/src/components/affine/new-workspace-setting-detail/index.tsx@@ -20,7 +20,7 @@ import { StoragePanel } from './storage';export type WorkspaceSettingDetailProps = {workspace: AffineOfficialWorkspace;- onDeleteWorkspace: () => Promise<void>;+ onDeleteWorkspace: (id: string) => Promise<void>;onTransferWorkspace: <From extends WorkspaceFlavour,To extends WorkspaceFlavourdiff --git a/apps/web/src/components/affine/setting-modal/workspace-setting/index.tsx b/apps/web/src/components/affine/setting-modal/workspace-setting/index.tsxindex dfc608bcbe..bfc13e354c 100644--- a/apps/web/src/components/affine/setting-modal/workspace-setting/index.tsx+++ b/apps/web/src/components/affine/setting-modal/workspace-setting/index.tsx@@ -1,5 +1,4 @@-import { assertExists } from '@blocksuite/global/utils';-import React, { Suspense, useCallback } from 'react';+import { Suspense, useCallback } from 'react';import { getUIAdapter } from '../../../../adapters/workspace';import { useOnTransformWorkspace } from '../../../../hooks/root/use-on-transform-workspace';@@ -10,11 +9,12 @@ export const WorkSpaceSetting = ({ workspace }: { workspace: Workspace }) => {const helper = useAppHelper();const { NewSettingsDetail } = getUIAdapter(workspace.flavour);- const onDeleteWorkspace = useCallback(async () => {- assertExists(currentWorkspace);- const workspaceId = currentWorkspace.id;- return helper.deleteWorkspace(workspaceId);- }, [helper]);+ const onDeleteWorkspace = useCallback(+ async (id: string) => {+ return helper.deleteWorkspace(id);+ },+ [helper]+ );const onTransformWorkspace = useOnTransformWorkspace();return (diff --git a/packages/env/src/workspace.ts b/packages/env/src/workspace.tsindex edfee60e1a..688f808234 100644--- a/packages/env/src/workspace.ts+++ b/packages/env/src/workspace.ts@@ -131,7 +131,7 @@ export type WorkspaceHeaderProps<Flavour extends keyof WorkspaceRegistry> =type NewSettingProps<Flavour extends keyof WorkspaceRegistry> =UIBaseProps<Flavour> & {- onDeleteWorkspace: () => Promise<void>;+ onDeleteWorkspace: (id: string) => Promise<void>;onTransformWorkspace: <From extends keyof WorkspaceRegistry,To extends keyof WorkspaceRegistry