mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-11-30 05:34:21 +03:00
feat: mock login
This commit is contained in:
parent
97567e2e1f
commit
8d9838614e
@ -2,8 +2,8 @@ import { styled } from '@/styles';
|
|||||||
import { Modal, ModalWrapper, ModalCloseButton } from '@/ui/modal';
|
import { Modal, ModalWrapper, ModalCloseButton } from '@/ui/modal';
|
||||||
import { Button } from '@/ui/button';
|
import { Button } from '@/ui/button';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { createWorkspace } from '@/hooks/mock-data/mock';
|
|
||||||
import Input from '@/ui/input';
|
import Input from '@/ui/input';
|
||||||
|
import useTemporaryHelper from '@/hooks/use-temporary-helper';
|
||||||
interface ICloseParams {
|
interface ICloseParams {
|
||||||
workspaceId?: string;
|
workspaceId?: string;
|
||||||
}
|
}
|
||||||
@ -14,9 +14,10 @@ interface ModalProps {
|
|||||||
|
|
||||||
export const CreateWorkspaceModal = ({ open, onClose }: ModalProps) => {
|
export const CreateWorkspaceModal = ({ open, onClose }: ModalProps) => {
|
||||||
const [workspaceName, setWorkspaceName] = useState('');
|
const [workspaceName, setWorkspaceName] = useState('');
|
||||||
|
const { createWorkspace } = useTemporaryHelper();
|
||||||
const handleCreateWorkspace = () => {
|
const handleCreateWorkspace = () => {
|
||||||
const { workspaceId } = createWorkspace(workspaceName);
|
const { id } = createWorkspace(workspaceName);
|
||||||
onClose({ workspaceId });
|
onClose({ workspaceId: id });
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
@ -1,16 +1,8 @@
|
|||||||
import { styled } from '@/styles';
|
import { styled } from '@/styles';
|
||||||
import { Modal, ModalWrapper, ModalCloseButton } from '@/ui/modal';
|
import { Modal, ModalWrapper, ModalCloseButton } from '@/ui/modal';
|
||||||
import { Button } from '@/ui/button';
|
import { Button } from '@/ui/button';
|
||||||
import { useEffect, useState } from 'react';
|
import { useState } from 'react';
|
||||||
import {
|
import { SignOut } from '@/hooks/mock-data/mock';
|
||||||
getWorkspaces,
|
|
||||||
Workspace,
|
|
||||||
setActiveWorkspace,
|
|
||||||
Login,
|
|
||||||
User,
|
|
||||||
SignOut,
|
|
||||||
updateWorkspaceMeta,
|
|
||||||
} from '@/hooks/mock-data/mock';
|
|
||||||
import { CreateWorkspaceModal } from '../create-workspace';
|
import { CreateWorkspaceModal } from '../create-workspace';
|
||||||
import {
|
import {
|
||||||
CloudUnsyncedIcon,
|
CloudUnsyncedIcon,
|
||||||
@ -28,19 +20,17 @@ interface LoginModalProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const WorkspaceModal = ({ open, onClose }: LoginModalProps) => {
|
export const WorkspaceModal = ({ open, onClose }: LoginModalProps) => {
|
||||||
const [workspaceList, setWorkspaceList] = useState<Workspace[]>([]);
|
|
||||||
const [createWorkspaceOpen, setCreateWorkspaceOpen] = useState(false);
|
const [createWorkspaceOpen, setCreateWorkspaceOpen] = useState(false);
|
||||||
const { confirm } = useConfirm();
|
const { confirm } = useConfirm();
|
||||||
const { user, login } = useTemporaryHelper();
|
const {
|
||||||
useEffect(() => {
|
user,
|
||||||
setList();
|
login,
|
||||||
}, []);
|
workspaceMetaList,
|
||||||
|
setActiveWorkspace,
|
||||||
const setList = () => {
|
updateWorkspaceMeta,
|
||||||
const data = getWorkspaces();
|
} = useTemporaryHelper();
|
||||||
setWorkspaceList(data);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
console.log('workspaceMetaList: ', workspaceMetaList);
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Modal open={open} onClose={onClose}>
|
<Modal open={open} onClose={onClose}>
|
||||||
@ -60,7 +50,7 @@ export const WorkspaceModal = ({ open, onClose }: LoginModalProps) => {
|
|||||||
</Header>
|
</Header>
|
||||||
<Content>
|
<Content>
|
||||||
<WorkspaceList>
|
<WorkspaceList>
|
||||||
{workspaceList.map((item, index) => {
|
{workspaceMetaList.map((item, index) => {
|
||||||
return (
|
return (
|
||||||
<WorkspaceItem
|
<WorkspaceItem
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@ -165,7 +155,6 @@ export const WorkspaceModal = ({ open, onClose }: LoginModalProps) => {
|
|||||||
open={createWorkspaceOpen}
|
open={createWorkspaceOpen}
|
||||||
onClose={({ workspaceId }) => {
|
onClose={({ workspaceId }) => {
|
||||||
setCreateWorkspaceOpen(false);
|
setCreateWorkspaceOpen(false);
|
||||||
setList();
|
|
||||||
onClose();
|
onClose();
|
||||||
confirm({
|
confirm({
|
||||||
title: 'Enable AFFiNE Cloud?',
|
title: 'Enable AFFiNE Cloud?',
|
||||||
@ -182,7 +171,7 @@ export const WorkspaceModal = ({ open, onClose }: LoginModalProps) => {
|
|||||||
});
|
});
|
||||||
}, 1000);
|
}, 1000);
|
||||||
} else {
|
} else {
|
||||||
confirm && Login();
|
confirm && login();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
|
@ -15,24 +15,21 @@ import { MoreVerticalIcon, EmailIcon, TrashIcon } from '@blocksuite/icons';
|
|||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { Button, IconButton } from '@/ui/button';
|
import { Button, IconButton } from '@/ui/button';
|
||||||
import { InviteMembers } from '../invite-members/index';
|
import { InviteMembers } from '../invite-members/index';
|
||||||
// import { Member, getDataCenter } from '@affine/datacenter';
|
|
||||||
// import { Avatar } from '@mui/material';
|
|
||||||
import { Menu, MenuItem } from '@/ui/menu';
|
import { Menu, MenuItem } from '@/ui/menu';
|
||||||
import { Empty } from '@/ui/empty';
|
import { Empty } from '@/ui/empty';
|
||||||
import {
|
import {
|
||||||
deleteMember,
|
deleteMember,
|
||||||
getMembers,
|
getMembers,
|
||||||
getUserInfo,
|
|
||||||
Login,
|
|
||||||
User,
|
User,
|
||||||
Workspace,
|
Workspace,
|
||||||
} from '@/hooks/mock-data/mock';
|
} from '@/hooks/mock-data/mock';
|
||||||
|
import useTemporaryHelper from '@/hooks/use-temporary-helper';
|
||||||
|
|
||||||
// import { useAppState } from '@/providers/app-state-provider';
|
// import { useAppState } from '@/providers/app-state-provider';
|
||||||
export const MembersPage = ({ workspace }: { workspace: Workspace }) => {
|
export const MembersPage = ({ workspace }: { workspace: Workspace }) => {
|
||||||
const [isInviteModalShow, setIsInviteModalShow] = useState(false);
|
const [isInviteModalShow, setIsInviteModalShow] = useState(false);
|
||||||
const [members, setMembers] = useState<User[]>([]);
|
const [members, setMembers] = useState<User[]>([]);
|
||||||
const [userInfo, setUserInfo] = useState<User>();
|
const { user, login } = useTemporaryHelper();
|
||||||
// const refreshMembers = useCallback(() => {
|
// const refreshMembers = useCallback(() => {
|
||||||
// getDataCenter()
|
// getDataCenter()
|
||||||
// .then(dc =>
|
// .then(dc =>
|
||||||
@ -49,15 +46,10 @@ export const MembersPage = ({ workspace }: { workspace: Workspace }) => {
|
|||||||
// }, [workspace.id]);
|
// }, [workspace.id]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setUser();
|
|
||||||
setMembersList();
|
setMembersList();
|
||||||
// refreshMembers();
|
// refreshMembers();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const setUser = () => {
|
|
||||||
const user = getUserInfo();
|
|
||||||
user && setUserInfo(user);
|
|
||||||
};
|
|
||||||
const setMembersList = () => {
|
const setMembersList = () => {
|
||||||
const members = getMembers(workspace.id);
|
const members = getMembers(workspace.id);
|
||||||
members && setMembers(members);
|
members && setMembers(members);
|
||||||
@ -65,7 +57,7 @@ export const MembersPage = ({ workspace }: { workspace: Workspace }) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{userInfo ? (
|
{user ? (
|
||||||
<>
|
<>
|
||||||
<StyledMemberTitleContainer>
|
<StyledMemberTitleContainer>
|
||||||
<StyledMemberNameContainer>
|
<StyledMemberNameContainer>
|
||||||
@ -184,8 +176,7 @@ export const MembersPage = ({ workspace }: { workspace: Workspace }) => {
|
|||||||
<div>
|
<div>
|
||||||
<Button
|
<Button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
Login();
|
login();
|
||||||
setUser();
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Enable AFFiNE Cloud
|
Enable AFFiNE Cloud
|
||||||
|
@ -9,24 +9,18 @@ import { Button } from '@/ui/button';
|
|||||||
import { Menu, MenuItem } from '@/ui/menu';
|
import { Menu, MenuItem } from '@/ui/menu';
|
||||||
import {
|
import {
|
||||||
deleteMember,
|
deleteMember,
|
||||||
getActiveWorkspace,
|
|
||||||
updateWorkspaceMeta,
|
updateWorkspaceMeta,
|
||||||
Workspace,
|
Workspace,
|
||||||
} from '@/hooks/mock-data/mock';
|
} from '@/hooks/mock-data/mock';
|
||||||
|
import useTemporaryHelper from '@/hooks/use-temporary-helper';
|
||||||
|
|
||||||
export const SyncPage = ({ workspace }: { workspace: Workspace }) => {
|
export const SyncPage = ({ workspace }: { workspace: Workspace }) => {
|
||||||
const [workspaceType, setWorkspaceType] = useState('local');
|
const { currentWorkspace, updateWorkspaceMeta } = useTemporaryHelper();
|
||||||
useEffect(() => {
|
|
||||||
setType();
|
|
||||||
});
|
|
||||||
const setType = () => {
|
|
||||||
const ACTIVEworkspace = getActiveWorkspace();
|
|
||||||
ACTIVEworkspace && setWorkspaceType(ACTIVEworkspace.type);
|
|
||||||
};
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<StyledPublishContent>
|
<StyledPublishContent>
|
||||||
{workspaceType === 'local' ? (
|
{currentWorkspace.type === 'local' ? (
|
||||||
<>
|
<>
|
||||||
<StyledPublishExplanation>
|
<StyledPublishExplanation>
|
||||||
{workspace.name} is Local Workspace. All data is stored on the
|
{workspace.name} is Local Workspace. All data is stored on the
|
||||||
@ -40,7 +34,6 @@ export const SyncPage = ({ workspace }: { workspace: Workspace }) => {
|
|||||||
updateWorkspaceMeta(workspace.id, {
|
updateWorkspaceMeta(workspace.id, {
|
||||||
type: 'cloud',
|
type: 'cloud',
|
||||||
});
|
});
|
||||||
setType();
|
|
||||||
}}
|
}}
|
||||||
type="primary"
|
type="primary"
|
||||||
shape="circle"
|
shape="circle"
|
||||||
|
@ -6,7 +6,7 @@ import {
|
|||||||
} from './style';
|
} from './style';
|
||||||
import { StyledSettingH2 } from '../style';
|
import { StyledSettingH2 } from '../style';
|
||||||
|
|
||||||
import { useEffect, useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { Button, TextButton } from '@/ui/button';
|
import { Button, TextButton } from '@/ui/button';
|
||||||
import Input from '@/ui/input';
|
import Input from '@/ui/input';
|
||||||
import { getDataCenter } from '@affine/datacenter';
|
import { getDataCenter } from '@affine/datacenter';
|
||||||
@ -15,22 +15,13 @@ import { WorkspaceDelete } from './delete';
|
|||||||
import { debounce } from '@/utils';
|
import { debounce } from '@/utils';
|
||||||
import { WorkspaceLeave } from './leave';
|
import { WorkspaceLeave } from './leave';
|
||||||
import { Upload } from '@/components/file-upload';
|
import { Upload } from '@/components/file-upload';
|
||||||
import {
|
import { updateWorkspaceMeta, Workspace } from '@/hooks/mock-data/mock';
|
||||||
getUserInfo,
|
|
||||||
updateWorkspaceMeta,
|
|
||||||
User,
|
|
||||||
Workspace,
|
|
||||||
} from '@/hooks/mock-data/mock';
|
|
||||||
import { WorkspaceAvatar } from '@/components/workspace-avatar';
|
import { WorkspaceAvatar } from '@/components/workspace-avatar';
|
||||||
|
import useTemporaryHelper from '@/hooks/use-temporary-helper';
|
||||||
export const GeneralPage = ({ workspace }: { workspace: Workspace }) => {
|
export const GeneralPage = ({ workspace }: { workspace: Workspace }) => {
|
||||||
const { currentWorkspace, refreshWorkspacesMeta } = useAppState();
|
const { refreshWorkspacesMeta } = useAppState();
|
||||||
useEffect(() => {
|
const { currentWorkspace } = useTemporaryHelper();
|
||||||
setWorkspaceName(workspace.name);
|
|
||||||
const user = getUserInfo();
|
|
||||||
setUserInfo(user);
|
|
||||||
}, []);
|
|
||||||
const [showDelete, setShowDelete] = useState<boolean>(false);
|
const [showDelete, setShowDelete] = useState<boolean>(false);
|
||||||
const [userInfo, setUserInfo] = useState<User>();
|
|
||||||
const [showLeave, setShowLeave] = useState<boolean>(false);
|
const [showLeave, setShowLeave] = useState<boolean>(false);
|
||||||
const [uploading, setUploading] = useState<boolean>(false);
|
const [uploading, setUploading] = useState<boolean>(false);
|
||||||
const [workspaceName, setWorkspaceName] = useState<string>('');
|
const [workspaceName, setWorkspaceName] = useState<string>('');
|
||||||
@ -61,18 +52,18 @@ export const GeneralPage = ({ workspace }: { workspace: Workspace }) => {
|
|||||||
|
|
||||||
const fileChange = async (file: File) => {
|
const fileChange = async (file: File) => {
|
||||||
setUploading(true);
|
setUploading(true);
|
||||||
const blob = new Blob([file], { type: file.type });
|
// const blob = new Blob([file], { type: file.type });
|
||||||
const blobId = await getDataCenter()
|
// const blobId = await getDataCenter()
|
||||||
.then(dc => dc.apis.uploadBlob({ blob }))
|
// .then(dc => dc.apis.uploadBlob({ blob }))
|
||||||
.finally(() => {
|
// .finally(() => {
|
||||||
setUploading(false);
|
// setUploading(false);
|
||||||
});
|
// });
|
||||||
if (blobId) {
|
// if (blobId) {
|
||||||
currentWorkspace?.meta.setAvatar(blobId);
|
// currentWorkspace?.meta.setAvatar(blobId);
|
||||||
// workspaces[workspace.id]?.meta.setAvatar(blobId);
|
// // workspaces[workspace.id]?.meta.setAvatar(blobId);
|
||||||
setUploading(false);
|
// setUploading(false);
|
||||||
debouncedRefreshWorkspacesMeta();
|
// debouncedRefreshWorkspacesMeta();
|
||||||
}
|
// }
|
||||||
};
|
};
|
||||||
|
|
||||||
return workspace ? (
|
return workspace ? (
|
||||||
|
@ -17,9 +17,10 @@ import {
|
|||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { GeneralPage } from './general';
|
import { GeneralPage } from './general';
|
||||||
import { getActiveWorkspace } from '@/hooks/mock-data/mock';
|
import { getActiveWorkspace } from '@/hooks/mock-data/mock';
|
||||||
import MembersPage from './MembersPage';
|
import { MembersPage } from './MembersPage';
|
||||||
import PublishPage from './PublishPage';
|
import { PublishPage } from './PublishPage';
|
||||||
import SyncPage from './SyncPage';
|
import { SyncPage } from './SyncPage';
|
||||||
|
import useTemporaryHelper from '@/hooks/use-temporary-helper';
|
||||||
|
|
||||||
enum ActiveTab {
|
enum ActiveTab {
|
||||||
'general' = 'general',
|
'general' = 'general',
|
||||||
@ -114,7 +115,7 @@ export const WorkspaceSetting = ({
|
|||||||
setActiveTab(tab);
|
setActiveTab(tab);
|
||||||
};
|
};
|
||||||
|
|
||||||
const workspace = getActiveWorkspace();
|
const { currentWorkspace } = useTemporaryHelper();
|
||||||
const handleClickClose = () => {
|
const handleClickClose = () => {
|
||||||
onClose && onClose();
|
onClose && onClose();
|
||||||
};
|
};
|
||||||
@ -142,14 +143,16 @@ export const WorkspaceSetting = ({
|
|||||||
) : null}
|
) : null}
|
||||||
<StyledSettingContent>
|
<StyledSettingContent>
|
||||||
{activeTab === ActiveTab.general && (
|
{activeTab === ActiveTab.general && (
|
||||||
<GeneralPage workspace={workspace} />
|
<GeneralPage workspace={currentWorkspace} />
|
||||||
)}
|
)}
|
||||||
{activeTab === ActiveTab.sync && <SyncPage workspace={workspace} />}
|
{activeTab === ActiveTab.sync && (
|
||||||
{activeTab === ActiveTab.members && workspace && (
|
<SyncPage workspace={currentWorkspace} />
|
||||||
<MembersPage workspace={workspace} />
|
)}
|
||||||
|
{activeTab === ActiveTab.members && currentWorkspace && (
|
||||||
|
<MembersPage workspace={currentWorkspace} />
|
||||||
)}
|
)}
|
||||||
{activeTab === ActiveTab.publish && (
|
{activeTab === ActiveTab.publish && (
|
||||||
<PublishPage workspace={workspace} />
|
<PublishPage workspace={currentWorkspace} />
|
||||||
)}
|
)}
|
||||||
</StyledSettingContent>
|
</StyledSettingContent>
|
||||||
</StyledSettingContainer>
|
</StyledSettingContainer>
|
||||||
|
@ -1,25 +1,17 @@
|
|||||||
import { Avatar, WorkspaceName, SelectorWrapper } from './styles';
|
import { Avatar, WorkspaceName, SelectorWrapper } from './styles';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
// import { AffineIcon } from '../icons/icons';
|
|
||||||
import { WorkspaceModal } from '@/components/workspace-modal';
|
import { WorkspaceModal } from '@/components/workspace-modal';
|
||||||
import { WorkspaceAvatar } from '@/components/workspace-avatar';
|
import { WorkspaceAvatar } from '@/components/workspace-avatar';
|
||||||
import { getActiveWorkspace, getWorkspaces } from '@/hooks/mock-data/mock';
|
import useTemporaryHelper from '@/hooks/use-temporary-helper';
|
||||||
export const WorkspaceSelector = () => {
|
export const WorkspaceSelector = () => {
|
||||||
const [workspaceListShow, setWorkspaceListShow] = useState(false);
|
const [workspaceListShow, setWorkspaceListShow] = useState(false);
|
||||||
const [workspace, setWorkSpace] = useState(getActiveWorkspace());
|
const { currentWorkspace, workspaceMetaList } = useTemporaryHelper();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setWorkspace();
|
if (workspaceMetaList.length === 0) {
|
||||||
}, [workspaceListShow]);
|
|
||||||
useEffect(() => {
|
|
||||||
const workspaceList = getWorkspaces();
|
|
||||||
if (workspaceList.length === 0) {
|
|
||||||
setWorkspaceListShow(true);
|
setWorkspaceListShow(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const setWorkspace = () => {
|
|
||||||
const workspace = getActiveWorkspace();
|
|
||||||
setWorkSpace(workspace);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@ -32,25 +24,24 @@ export const WorkspaceSelector = () => {
|
|||||||
<Avatar
|
<Avatar
|
||||||
alt="Affine"
|
alt="Affine"
|
||||||
data-testid="workspace-avatar"
|
data-testid="workspace-avatar"
|
||||||
src={workspace.avatar}
|
src={currentWorkspace.avatar}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
float: 'left',
|
float: 'left',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<WorkspaceAvatar size={28} name={workspace.name} />
|
<WorkspaceAvatar size={28} name={currentWorkspace.name} />
|
||||||
</div>
|
</div>
|
||||||
</Avatar>
|
</Avatar>
|
||||||
<WorkspaceName data-testid="workspace-name">
|
<WorkspaceName data-testid="workspace-name">
|
||||||
{workspace?.name ?? 'AFFiNE'}
|
{currentWorkspace?.name ?? 'AFFiNE'}
|
||||||
</WorkspaceName>
|
</WorkspaceName>
|
||||||
</SelectorWrapper>
|
</SelectorWrapper>
|
||||||
<WorkspaceModal
|
<WorkspaceModal
|
||||||
open={workspaceListShow}
|
open={workspaceListShow}
|
||||||
onClose={() => {
|
onClose={() => {
|
||||||
setWorkspaceListShow(false);
|
setWorkspaceListShow(false);
|
||||||
setWorkspace();
|
|
||||||
}}
|
}}
|
||||||
></WorkspaceModal>
|
></WorkspaceModal>
|
||||||
</>
|
</>
|
||||||
|
@ -17,13 +17,21 @@ export const useTemporaryHelper = () => {
|
|||||||
return {
|
return {
|
||||||
updateWorkspaceMeta: (
|
updateWorkspaceMeta: (
|
||||||
workspaceId: string,
|
workspaceId: string,
|
||||||
workspaceData: { name?: string; avatar?: string; isPublish?: boolean }
|
workspaceData: {
|
||||||
|
name?: string;
|
||||||
|
avatar?: string;
|
||||||
|
isPublish?: boolean;
|
||||||
|
type?: 'local' | 'cloud' | 'join';
|
||||||
|
}
|
||||||
) => {
|
) => {
|
||||||
const workspacesMeta = getWorkspaces();
|
const workspacesMeta = getWorkspaces();
|
||||||
const newWorkspacesMeta = workspacesMeta.map((workspace: Workspace) => {
|
const newWorkspacesMeta = workspacesMeta.map((workspace: Workspace) => {
|
||||||
if (workspace.id === workspaceId) {
|
if (workspace.id === workspaceId) {
|
||||||
workspaceData.name && (workspace.name = workspaceData.name);
|
workspaceData.name && (workspace.name = workspaceData.name);
|
||||||
workspaceData.avatar && (workspace.avatar = workspaceData.avatar);
|
workspaceData.avatar && (workspace.avatar = workspaceData.avatar);
|
||||||
|
workspaceData.type && (workspace.type = workspaceData.type);
|
||||||
|
workspaceData.isPublish &&
|
||||||
|
(workspace.isPublish = workspaceData.isPublish);
|
||||||
return workspace;
|
return workspace;
|
||||||
}
|
}
|
||||||
return workspace;
|
return workspace;
|
||||||
@ -53,7 +61,9 @@ export const useTemporaryHelper = () => {
|
|||||||
const workspacesMeta = getWorkspaces();
|
const workspacesMeta = getWorkspaces();
|
||||||
workspacesMeta.push(workspaceData);
|
workspacesMeta.push(workspaceData);
|
||||||
localStorage.setItem('affine-workspace', JSON.stringify(workspacesMeta));
|
localStorage.setItem('affine-workspace', JSON.stringify(workspacesMeta));
|
||||||
|
console.log('workspacesMeta: ', workspacesMeta);
|
||||||
setWorkspaceMetaList(workspacesMeta);
|
setWorkspaceMetaList(workspacesMeta);
|
||||||
|
return workspaceData;
|
||||||
},
|
},
|
||||||
deleteWorkspace: (workspaceId: string) => {
|
deleteWorkspace: (workspaceId: string) => {
|
||||||
const workspacesMeta = getWorkspaces();
|
const workspacesMeta = getWorkspaces();
|
||||||
@ -82,6 +92,7 @@ export const useTemporaryHelper = () => {
|
|||||||
setWorkspaceMetaList(workspacesMeta);
|
setWorkspaceMetaList(workspacesMeta);
|
||||||
},
|
},
|
||||||
setActiveWorkspace(workspaceData: Workspace) {
|
setActiveWorkspace(workspaceData: Workspace) {
|
||||||
|
console.log('workspaceData: ', workspaceData);
|
||||||
localStorage.setItem(
|
localStorage.setItem(
|
||||||
'affine-active-workspace',
|
'affine-active-workspace',
|
||||||
JSON.stringify(workspaceData)
|
JSON.stringify(workspaceData)
|
||||||
|
Loading…
Reference in New Issue
Block a user