mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-25 02:13:00 +08:00
Merge branch 'feat/poc' of github.com:toeverything/AFFiNE into feat/poc
This commit is contained in:
@@ -174,7 +174,11 @@ export const WorkspaceModal = ({ open, onClose }: LoginModalProps) => {
|
|||||||
confirmText: user ? 'Enable' : 'Sign in and Enable',
|
confirmText: user ? 'Enable' : 'Sign in and Enable',
|
||||||
cancelText: 'Skip',
|
cancelText: 'Skip',
|
||||||
}).then(confirm => {
|
}).then(confirm => {
|
||||||
confirm && Login();
|
if (user) {
|
||||||
|
console.log('enable cloud');
|
||||||
|
} else {
|
||||||
|
confirm && Login();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
></CreateWorkspaceModal>
|
></CreateWorkspaceModal>
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import { Button } from '@/ui/button';
|
|||||||
import { getDataCenter } from '@affine/datacenter';
|
import { getDataCenter } from '@affine/datacenter';
|
||||||
import { useRouter } from 'next/router';
|
import { useRouter } from 'next/router';
|
||||||
import { useAppState } from '@/providers/app-state-provider';
|
import { useAppState } from '@/providers/app-state-provider';
|
||||||
|
import { deleteWorkspace, getWorkspaces } from '@/hooks/mock-data/mock';
|
||||||
|
|
||||||
interface WorkspaceDeleteProps {
|
interface WorkspaceDeleteProps {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
@@ -31,7 +32,6 @@ export const WorkspaceDelete = ({
|
|||||||
nextWorkSpaceId,
|
nextWorkSpaceId,
|
||||||
}: WorkspaceDeleteProps) => {
|
}: WorkspaceDeleteProps) => {
|
||||||
const [deleteStr, setDeleteStr] = useState<string>('');
|
const [deleteStr, setDeleteStr] = useState<string>('');
|
||||||
const { refreshWorkspacesMeta } = useAppState();
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
const handlerInputChange = (workspaceName: string) => {
|
const handlerInputChange = (workspaceName: string) => {
|
||||||
@@ -39,10 +39,16 @@ export const WorkspaceDelete = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleDelete = async () => {
|
const handleDelete = async () => {
|
||||||
const dc = await getDataCenter();
|
// const dc = await getDataCenter();
|
||||||
await dc.apis.deleteWorkspace({ id: workspaceId });
|
// await dc.apis.deleteWorkspace({ id: workspaceId });
|
||||||
router.push(`/workspace/${nextWorkSpaceId}`);
|
// router.push(`/workspace/${nextWorkSpaceId}`);
|
||||||
refreshWorkspacesMeta();
|
deleteWorkspace(workspaceId);
|
||||||
|
const workspaceList = getWorkspaces();
|
||||||
|
if (workspaceList.length) {
|
||||||
|
router.push(`/workspace/${workspaceList[0].id}`);
|
||||||
|
} else {
|
||||||
|
router.push(`/workspace`);
|
||||||
|
}
|
||||||
onClose();
|
onClose();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import {
|
|||||||
} from './style';
|
} from './style';
|
||||||
import { StyledSettingH2 } from '../style';
|
import { StyledSettingH2 } from '../style';
|
||||||
|
|
||||||
import { useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { Button } 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';
|
||||||
import { useAppState } from '@/providers/app-state-provider';
|
import { useAppState } from '@/providers/app-state-provider';
|
||||||
@@ -16,7 +16,12 @@ import { Workspace as StoreWorkspace } from '@blocksuite/store';
|
|||||||
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 { getUserInfo, Workspace } from '@/hooks/mock-data/mock';
|
import {
|
||||||
|
getUserInfo,
|
||||||
|
updateWorkspaceMeta,
|
||||||
|
User,
|
||||||
|
Workspace,
|
||||||
|
} from '@/hooks/mock-data/mock';
|
||||||
|
|
||||||
export const GeneralPage = ({
|
export const GeneralPage = ({
|
||||||
workspace,
|
workspace,
|
||||||
@@ -30,8 +35,13 @@ export const GeneralPage = ({
|
|||||||
workspaces,
|
workspaces,
|
||||||
refreshWorkspacesMeta,
|
refreshWorkspacesMeta,
|
||||||
} = useAppState();
|
} = useAppState();
|
||||||
// const user = getUserInfo();
|
useEffect(() => {
|
||||||
|
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>('');
|
||||||
@@ -63,6 +73,9 @@ export const GeneralPage = ({
|
|||||||
const handleCloseLeave = () => {
|
const handleCloseLeave = () => {
|
||||||
setShowLeave(false);
|
setShowLeave(false);
|
||||||
};
|
};
|
||||||
|
const handleUpdateWorkspaceName = () => {
|
||||||
|
updateWorkspaceMeta(workspace.id, { name: workspaceName });
|
||||||
|
};
|
||||||
|
|
||||||
const fileChange = async (file: File) => {
|
const fileChange = async (file: File) => {
|
||||||
setUploading(true);
|
setUploading(true);
|
||||||
@@ -106,7 +119,7 @@ export const GeneralPage = ({
|
|||||||
) : null} */}
|
) : null} */}
|
||||||
{/* <Button shape="round">remove</Button> */}
|
{/* <Button shape="round">remove</Button> */}
|
||||||
</StyledSettingAvatarContent>
|
</StyledSettingAvatarContent>
|
||||||
<StyledSettingH2 marginTop={36}>Workspace Name</StyledSettingH2>
|
<StyledSettingH2 marginTop={20}>Workspace Name</StyledSettingH2>
|
||||||
<StyledSettingInputContainer>
|
<StyledSettingInputContainer>
|
||||||
<Input
|
<Input
|
||||||
width={327}
|
width={327}
|
||||||
@@ -116,15 +129,34 @@ export const GeneralPage = ({
|
|||||||
minLength={1}
|
minLength={1}
|
||||||
onChange={handleChangeWorkSpaceName}
|
onChange={handleChangeWorkSpaceName}
|
||||||
></Input>
|
></Input>
|
||||||
|
<TextButton
|
||||||
|
onClick={() => {
|
||||||
|
handleUpdateWorkspaceName();
|
||||||
|
}}
|
||||||
|
style={{ marginLeft: '10px' }}
|
||||||
|
>
|
||||||
|
✔️
|
||||||
|
</TextButton>
|
||||||
</StyledSettingInputContainer>
|
</StyledSettingInputContainer>
|
||||||
<StyledSettingH2 marginTop={36}>Workspace Owner</StyledSettingH2>
|
{userInfo ? (
|
||||||
|
<div>
|
||||||
|
<StyledSettingH2 marginTop={20}>Workspace Owner</StyledSettingH2>
|
||||||
|
<StyledSettingInputContainer>
|
||||||
|
<Input
|
||||||
|
width={327}
|
||||||
|
disabled
|
||||||
|
value={userInfo?.name}
|
||||||
|
placeholder="Workspace Owner"
|
||||||
|
></Input>
|
||||||
|
</StyledSettingInputContainer>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
''
|
||||||
|
)}
|
||||||
|
|
||||||
|
<StyledSettingH2 marginTop={20}>Workspace Type</StyledSettingH2>
|
||||||
<StyledSettingInputContainer>
|
<StyledSettingInputContainer>
|
||||||
<Input
|
{workspace.type}
|
||||||
width={327}
|
|
||||||
disabled
|
|
||||||
// value={owner.name}
|
|
||||||
placeholder="Workspace Owner"
|
|
||||||
></Input>
|
|
||||||
</StyledSettingInputContainer>
|
</StyledSettingInputContainer>
|
||||||
<StyledDeleteButtonContainer>
|
<StyledDeleteButtonContainer>
|
||||||
{isOwner ? (
|
{isOwner ? (
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ export const StyledSettingInputContainer = styled('div')(() => {
|
|||||||
|
|
||||||
export const StyledDeleteButtonContainer = styled('div')(() => {
|
export const StyledDeleteButtonContainer = styled('div')(() => {
|
||||||
return {
|
return {
|
||||||
marginTop: '154px',
|
marginTop: '30px',
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -116,7 +116,6 @@ export const WorkspaceSetting = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const workspace = getActiveWorkspace();
|
const workspace = getActiveWorkspace();
|
||||||
console.log('workspace: ', workspace);
|
|
||||||
const handleClickClose = () => {
|
const handleClickClose = () => {
|
||||||
onClose && onClose();
|
onClose && onClose();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,15 +2,22 @@ import { Avatar, WorkspaceName, SelectorWrapper } from './styles';
|
|||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { AffineIcon } from '../icons/icons';
|
import { AffineIcon } from '../icons/icons';
|
||||||
import { WorkspaceModal } from '@/components/workspace-modal';
|
import { WorkspaceModal } from '@/components/workspace-modal';
|
||||||
import { getActiveWorkspace } from '@/hooks/mock-data/mock';
|
import { getActiveWorkspace, getWorkspaces } from '@/hooks/mock-data/mock';
|
||||||
|
|
||||||
export const WorkspaceSelector = () => {
|
export const WorkspaceSelector = () => {
|
||||||
const [workspaceListShow, setWorkspaceListShow] = useState(false);
|
const [workspaceListShow, setWorkspaceListShow] = useState(false);
|
||||||
const [workspace, setWorkSpace] = useState(getActiveWorkspace());
|
const [workspace, setWorkSpace] = useState(getActiveWorkspace());
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getWorkspace();
|
setWorkspace();
|
||||||
}, [workspaceListShow]);
|
}, [workspaceListShow]);
|
||||||
const getWorkspace = () => {
|
useEffect(() => {
|
||||||
|
const workspaceList = getWorkspaces();
|
||||||
|
if (workspaceList.length === 0) {
|
||||||
|
setWorkspaceListShow(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const setWorkspace = () => {
|
||||||
const workspace = getActiveWorkspace();
|
const workspace = getActiveWorkspace();
|
||||||
setWorkSpace(workspace);
|
setWorkSpace(workspace);
|
||||||
};
|
};
|
||||||
@@ -38,7 +45,7 @@ export const WorkspaceSelector = () => {
|
|||||||
open={workspaceListShow}
|
open={workspaceListShow}
|
||||||
onClose={() => {
|
onClose={() => {
|
||||||
setWorkspaceListShow(false);
|
setWorkspaceListShow(false);
|
||||||
getWorkspace();
|
setWorkspace();
|
||||||
}}
|
}}
|
||||||
></WorkspaceModal>
|
></WorkspaceModal>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export interface User {
|
|||||||
|
|
||||||
export function updateWorkspaceMeta(
|
export function updateWorkspaceMeta(
|
||||||
workspaceId: string,
|
workspaceId: string,
|
||||||
workspaceData: Workspace
|
workspaceData: { name?: string; avatar?: string }
|
||||||
) {
|
) {
|
||||||
const workspacesMeta = getWorkspaces();
|
const workspacesMeta = getWorkspaces();
|
||||||
const newWorkspacesMeta = workspacesMeta.map((workspace: Workspace) => {
|
const newWorkspacesMeta = workspacesMeta.map((workspace: Workspace) => {
|
||||||
@@ -29,6 +29,10 @@ export function updateWorkspaceMeta(
|
|||||||
return workspace;
|
return workspace;
|
||||||
});
|
});
|
||||||
localStorage.setItem('affine-workspace', JSON.stringify(newWorkspacesMeta));
|
localStorage.setItem('affine-workspace', JSON.stringify(newWorkspacesMeta));
|
||||||
|
const activeWorkspace = getActiveWorkspace();
|
||||||
|
workspaceData.name && (activeWorkspace.name = workspaceData.name);
|
||||||
|
workspaceData.avatar && (activeWorkspace.avatar = workspaceData.avatar);
|
||||||
|
setActiveWorkspace(activeWorkspace);
|
||||||
}
|
}
|
||||||
export function createWorkspace(workspaceName: string) {
|
export function createWorkspace(workspaceName: string) {
|
||||||
const workspaceData = {
|
const workspaceData = {
|
||||||
|
|||||||
Reference in New Issue
Block a user