mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-25 13:12:02 +03:00
fix: delete workspace in settings (#3030)
This commit is contained in:
parent
776172bc88
commit
dec0c0d3d1
@ -20,7 +20,7 @@ interface WorkspaceDeleteProps {
|
|||||||
open: boolean;
|
open: boolean;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
workspace: AffineOfficialWorkspace;
|
workspace: AffineOfficialWorkspace;
|
||||||
onDeleteWorkspace: () => Promise<void>;
|
onDeleteWorkspace: (id: string) => Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const WorkspaceDeleteModal = ({
|
export const WorkspaceDeleteModal = ({
|
||||||
@ -37,16 +37,17 @@ export const WorkspaceDeleteModal = ({
|
|||||||
const t = useAFFiNEI18N();
|
const t = useAFFiNEI18N();
|
||||||
|
|
||||||
const handleDelete = useCallback(() => {
|
const handleDelete = useCallback(() => {
|
||||||
onDeleteWorkspace()
|
onDeleteWorkspace(workspace.id)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
toast(t['Successfully deleted'](), {
|
toast(t['Successfully deleted'](), {
|
||||||
portal: document.body,
|
portal: document.body,
|
||||||
});
|
});
|
||||||
|
onClose();
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
// ignore error
|
// ignore error
|
||||||
});
|
});
|
||||||
}, [onDeleteWorkspace, t]);
|
}, [onClose, onDeleteWorkspace, t, workspace.id]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal open={open} onClose={onClose}>
|
<Modal open={open} onClose={onClose}>
|
||||||
|
@ -20,7 +20,7 @@ import { StoragePanel } from './storage';
|
|||||||
|
|
||||||
export type WorkspaceSettingDetailProps = {
|
export type WorkspaceSettingDetailProps = {
|
||||||
workspace: AffineOfficialWorkspace;
|
workspace: AffineOfficialWorkspace;
|
||||||
onDeleteWorkspace: () => Promise<void>;
|
onDeleteWorkspace: (id: string) => Promise<void>;
|
||||||
onTransferWorkspace: <
|
onTransferWorkspace: <
|
||||||
From extends WorkspaceFlavour,
|
From extends WorkspaceFlavour,
|
||||||
To extends WorkspaceFlavour
|
To extends WorkspaceFlavour
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { assertExists } from '@blocksuite/global/utils';
|
import { Suspense, useCallback } from 'react';
|
||||||
import React, { Suspense, useCallback } from 'react';
|
|
||||||
|
|
||||||
import { getUIAdapter } from '../../../../adapters/workspace';
|
import { getUIAdapter } from '../../../../adapters/workspace';
|
||||||
import { useOnTransformWorkspace } from '../../../../hooks/root/use-on-transform-workspace';
|
import { useOnTransformWorkspace } from '../../../../hooks/root/use-on-transform-workspace';
|
||||||
@ -10,11 +9,12 @@ export const WorkSpaceSetting = ({ workspace }: { workspace: Workspace }) => {
|
|||||||
const helper = useAppHelper();
|
const helper = useAppHelper();
|
||||||
const { NewSettingsDetail } = getUIAdapter(workspace.flavour);
|
const { NewSettingsDetail } = getUIAdapter(workspace.flavour);
|
||||||
|
|
||||||
const onDeleteWorkspace = useCallback(async () => {
|
const onDeleteWorkspace = useCallback(
|
||||||
assertExists(currentWorkspace);
|
async (id: string) => {
|
||||||
const workspaceId = currentWorkspace.id;
|
return helper.deleteWorkspace(id);
|
||||||
return helper.deleteWorkspace(workspaceId);
|
},
|
||||||
}, [helper]);
|
[helper]
|
||||||
|
);
|
||||||
const onTransformWorkspace = useOnTransformWorkspace();
|
const onTransformWorkspace = useOnTransformWorkspace();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
2
packages/env/src/workspace.ts
vendored
2
packages/env/src/workspace.ts
vendored
@ -131,7 +131,7 @@ export type WorkspaceHeaderProps<Flavour extends keyof WorkspaceRegistry> =
|
|||||||
|
|
||||||
type NewSettingProps<Flavour extends keyof WorkspaceRegistry> =
|
type NewSettingProps<Flavour extends keyof WorkspaceRegistry> =
|
||||||
UIBaseProps<Flavour> & {
|
UIBaseProps<Flavour> & {
|
||||||
onDeleteWorkspace: () => Promise<void>;
|
onDeleteWorkspace: (id: string) => Promise<void>;
|
||||||
onTransformWorkspace: <
|
onTransformWorkspace: <
|
||||||
From extends keyof WorkspaceRegistry,
|
From extends keyof WorkspaceRegistry,
|
||||||
To extends keyof WorkspaceRegistry
|
To extends keyof WorkspaceRegistry
|
||||||
|
Loading…
Reference in New Issue
Block a user