mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
fix: deepscan error and warning (#728)
This commit is contained in:
@@ -94,7 +94,7 @@ export const QuickSearch = ({ open, onClose }: TransitionsModalProps) => {
|
|||||||
setShowCreatePage={setShowCreatePage}
|
setShowCreatePage={setShowCreatePage}
|
||||||
/>
|
/>
|
||||||
</StyledContent>
|
</StyledContent>
|
||||||
{currentWorkspace?.isPublish ? (
|
{currentWorkspace?.published ? (
|
||||||
<></>
|
<></>
|
||||||
) : showCreatePage ? (
|
) : showCreatePage ? (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ export const PublishPage = ({ workspace }: { workspace: WorkspaceUnit }) => {
|
|||||||
{workspace.provider === 'affine' ? (
|
{workspace.provider === 'affine' ? (
|
||||||
<div>
|
<div>
|
||||||
<StyledPublishContent>
|
<StyledPublishContent>
|
||||||
{workspace?.published ? (
|
{workspace.published ? (
|
||||||
<>
|
<>
|
||||||
<StyledPublishExplanation>
|
<StyledPublishExplanation>
|
||||||
{t('Publishing')}
|
{t('Publishing')}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export const SyncPage = ({ workspace }: { workspace: WorkspaceUnit }) => {
|
|||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<StyledPublishContent>
|
<StyledPublishContent>
|
||||||
{workspace?.provider === 'local' ? (
|
{workspace.provider === 'local' ? (
|
||||||
<>
|
<>
|
||||||
<StyledPublishExplanation>
|
<StyledPublishExplanation>
|
||||||
{t('Sync Description', {
|
{t('Sync Description', {
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ export const MembersPage = ({ workspace }: { workspace: WorkspaceUnit }) => {
|
|||||||
{loaded && members.length === 0 && (
|
{loaded && members.length === 0 && (
|
||||||
<Empty width={648} sx={{ marginTop: '60px' }} height={300} />
|
<Empty width={648} sx={{ marginTop: '60px' }} height={300} />
|
||||||
)}
|
)}
|
||||||
{loaded && members.length && (
|
{loaded && members.length > 0 && (
|
||||||
<>
|
<>
|
||||||
<StyledMemberTitleContainer>
|
<StyledMemberTitleContainer>
|
||||||
<StyledMemberNameContainer>
|
<StyledMemberNameContainer>
|
||||||
|
|||||||
@@ -1,183 +0,0 @@
|
|||||||
// import { InformationIcon, LogOutIcon } from '@blocksuite/icons';
|
|
||||||
// import { styled } from '@/styles';
|
|
||||||
// import { Divider } from '@/ui/divider';
|
|
||||||
// import { useAppState } from '@/providers/app-state-provider';
|
|
||||||
// import { SelectorPopperContainer } from './styles';
|
|
||||||
// import {
|
|
||||||
// PrivateWorkspaceItem,
|
|
||||||
// WorkspaceItem,
|
|
||||||
// CreateWorkspaceItem,
|
|
||||||
// ListItem,
|
|
||||||
// LoginItem,
|
|
||||||
// } from './WorkspaceItem';
|
|
||||||
// import { WorkspaceSetting } from '@/components/workspace-setting';
|
|
||||||
// import { useCallback, useEffect, useState } from 'react';
|
|
||||||
// import { WorkspaceInfo } from '@affine/datacenter';
|
|
||||||
// import { useModal } from '@/providers/GlobalModalProvider';
|
|
||||||
|
|
||||||
// export type WorkspaceDetails = Record<
|
|
||||||
// string,
|
|
||||||
// { memberCount: number; owner: { id: string; name: string } }
|
|
||||||
// >;
|
|
||||||
|
|
||||||
// type SelectorPopperContentProps = {
|
|
||||||
// isShow: boolean;
|
|
||||||
// };
|
|
||||||
|
|
||||||
// export const SelectorPopperContent = ({
|
|
||||||
// isShow,
|
|
||||||
// }: SelectorPopperContentProps) => {
|
|
||||||
// const { user, workspacesMeta, refreshWorkspacesMeta } = useAppState();
|
|
||||||
// const [settingWorkspaceId, setSettingWorkspaceId] = useState<string | null>(
|
|
||||||
// null
|
|
||||||
// );
|
|
||||||
// const [workSpaceDetails, setWorkSpaceDetails] = useState<WorkspaceDetails>(
|
|
||||||
// {}
|
|
||||||
// );
|
|
||||||
// const { triggerContactModal } = useModal();
|
|
||||||
|
|
||||||
// const handleClickSettingWorkspace = (workspaceId: string) => {
|
|
||||||
// setSettingWorkspaceId(workspaceId);
|
|
||||||
// };
|
|
||||||
// const handleCloseWorkSpace = () => {
|
|
||||||
// setSettingWorkspaceId(null);
|
|
||||||
// };
|
|
||||||
// const settingWorkspace = settingWorkspaceId
|
|
||||||
// ? workspacesMeta.find(workspace => workspace.id === settingWorkspaceId)
|
|
||||||
// : undefined;
|
|
||||||
|
|
||||||
// const refreshDetails = useCallback(async () => {
|
|
||||||
// const workspaceDetailList = await Promise.all(
|
|
||||||
// workspacesMeta.map(async ({ id, type }) => {
|
|
||||||
// if (user) {
|
|
||||||
// if (type === WorkspaceType.Private) {
|
|
||||||
// return { id, member_count: 1, owner: user };
|
|
||||||
// } else {
|
|
||||||
// // const dc = await getDataCenter();
|
|
||||||
// // const data = await dc.apis.getWorkspaceDetail({ id });
|
|
||||||
// // return { id, ...data } || { id, member_count: 0, owner: user };
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// );
|
|
||||||
// const workSpaceDetails: WorkspaceDetails = {};
|
|
||||||
// workspaceDetailList.forEach(details => {
|
|
||||||
// if (details) {
|
|
||||||
// const { id, member_count, owner } = details;
|
|
||||||
// if (!owner) return;
|
|
||||||
// workSpaceDetails[id] = {
|
|
||||||
// memberCount: member_count || 1,
|
|
||||||
// owner: {
|
|
||||||
// id: owner.id,
|
|
||||||
// name: owner.name,
|
|
||||||
// },
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// setWorkSpaceDetails(workSpaceDetails);
|
|
||||||
// }, [user, workspacesMeta]);
|
|
||||||
|
|
||||||
// useEffect(() => {
|
|
||||||
// if (isShow) {
|
|
||||||
// setSettingWorkspaceId(null);
|
|
||||||
// refreshWorkspacesMeta();
|
|
||||||
// refreshDetails();
|
|
||||||
// }
|
|
||||||
// // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
||||||
// }, [isShow]);
|
|
||||||
|
|
||||||
// return !user ? (
|
|
||||||
// <SelectorPopperContainer placement="bottom-start">
|
|
||||||
// <LoginItem />
|
|
||||||
// <StyledDivider />
|
|
||||||
// <ListItem
|
|
||||||
// icon={<InformationIcon />}
|
|
||||||
// name="About AFFiNE"
|
|
||||||
// onClick={() => triggerContactModal()}
|
|
||||||
// />
|
|
||||||
// </SelectorPopperContainer>
|
|
||||||
// ) : (
|
|
||||||
// <SelectorPopperContainer placement="bottom-start">
|
|
||||||
// <PrivateWorkspaceItem
|
|
||||||
// privateWorkspaceId={
|
|
||||||
// workspacesMeta.find(
|
|
||||||
// workspace => workspace.type === WorkspaceType.Private
|
|
||||||
// )?.id
|
|
||||||
// }
|
|
||||||
// />
|
|
||||||
// <StyledDivider />
|
|
||||||
// <WorkspaceGroupTitle>Workspace</WorkspaceGroupTitle>
|
|
||||||
// <WorkspaceWrapper>
|
|
||||||
// {workspacesMeta.map(workspace => {
|
|
||||||
// return workspace.type !== WorkspaceType.Private ? (
|
|
||||||
// <WorkspaceItem
|
|
||||||
// type={workspace.type}
|
|
||||||
// key={workspace.id}
|
|
||||||
// id={workspace.id}
|
|
||||||
// icon={`loading...`}
|
|
||||||
// onClickSetting={handleClickSettingWorkspace}
|
|
||||||
// name={`loading...`}
|
|
||||||
// memberCount={workSpaceDetails[workspace.id]?.memberCount || 1}
|
|
||||||
// />
|
|
||||||
// ) : null;
|
|
||||||
// })}
|
|
||||||
// </WorkspaceWrapper>
|
|
||||||
// <CreateWorkspaceItem />
|
|
||||||
// {settingWorkspace ? (
|
|
||||||
// <WorkspaceSetting
|
|
||||||
// isShow={false}
|
|
||||||
// onClose={handleCloseWorkSpace}
|
|
||||||
// // workspace={settingWorkspace}
|
|
||||||
// // owner={
|
|
||||||
// // (settingWorkspaceId &&
|
|
||||||
// // workSpaceDetails[settingWorkspaceId]?.owner) || {
|
|
||||||
// // id: user.id,
|
|
||||||
// // name: user.name,
|
|
||||||
// // }
|
|
||||||
// // }
|
|
||||||
// />
|
|
||||||
// ) : null}
|
|
||||||
// <StyledDivider />
|
|
||||||
// <ListItem
|
|
||||||
// icon={<InformationIcon />}
|
|
||||||
// name="About AFFiNE"
|
|
||||||
// onClick={() => triggerContactModal()}
|
|
||||||
// />
|
|
||||||
// <ListItem
|
|
||||||
// icon={<LogOutIcon />}
|
|
||||||
// name="Sign out"
|
|
||||||
// onClick={() => {
|
|
||||||
// console.log('Sign out');
|
|
||||||
// // FIXME: remove token from local storage and reload the page
|
|
||||||
// localStorage.removeItem('affine_token');
|
|
||||||
// window.location.reload();
|
|
||||||
// }}
|
|
||||||
// />
|
|
||||||
// </SelectorPopperContainer>
|
|
||||||
// );
|
|
||||||
// };
|
|
||||||
|
|
||||||
// const StyledDivider = styled(Divider)({
|
|
||||||
// margin: '8px 12px',
|
|
||||||
// width: 'calc(100% - 24px)',
|
|
||||||
// });
|
|
||||||
|
|
||||||
// const WorkspaceGroupTitle = styled('div')(({ theme }) => {
|
|
||||||
// return {
|
|
||||||
// color: theme.colors.iconColor,
|
|
||||||
// fontSize: theme.font.sm,
|
|
||||||
// lineHeight: '30px',
|
|
||||||
// height: '30px',
|
|
||||||
// padding: '0 12px',
|
|
||||||
// };
|
|
||||||
// });
|
|
||||||
|
|
||||||
// const WorkspaceWrapper = styled('div')(() => {
|
|
||||||
// return {
|
|
||||||
// maxHeight: '200px',
|
|
||||||
// overflow: 'auto',
|
|
||||||
// };
|
|
||||||
// });
|
|
||||||
export const test = () => {
|
|
||||||
return <></>;
|
|
||||||
};
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
import { useState } from 'react';
|
|
||||||
import { AddIcon } from '@blocksuite/icons';
|
|
||||||
import { styled } from '@/styles';
|
|
||||||
import {
|
|
||||||
WorkspaceItemAvatar,
|
|
||||||
WorkspaceItemWrapper,
|
|
||||||
WorkspaceItemContent,
|
|
||||||
} from '../styles';
|
|
||||||
import { WorkspaceCreate } from './workspace-create';
|
|
||||||
|
|
||||||
const name = 'Create new Workspace';
|
|
||||||
|
|
||||||
export const CreateWorkspaceItem = () => {
|
|
||||||
const [open, setOpen] = useState(false);
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<WorkspaceItemWrapper onClick={() => setOpen(true)}>
|
|
||||||
<WorkspaceItemAvatar>
|
|
||||||
<AddIcon />
|
|
||||||
</WorkspaceItemAvatar>
|
|
||||||
<WorkspaceItemContent>
|
|
||||||
<Name title={name}>{name}</Name>
|
|
||||||
</WorkspaceItemContent>
|
|
||||||
</WorkspaceItemWrapper>
|
|
||||||
<WorkspaceCreate open={open} onClose={() => setOpen(false)} />
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const Name = styled('div')(({ theme }) => {
|
|
||||||
return {
|
|
||||||
color: theme.colors.quoteColor,
|
|
||||||
fontSize: theme.font.base,
|
|
||||||
fontWeight: 400,
|
|
||||||
overflow: 'hidden',
|
|
||||||
textOverflow: 'ellipsis',
|
|
||||||
whiteSpace: 'nowrap',
|
|
||||||
};
|
|
||||||
});
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
export * from './CreateWorkspaceItem';
|
|
||||||
@@ -1,123 +0,0 @@
|
|||||||
// import { getDataCenter } from '@affine/datacenter';
|
|
||||||
import Modal from '@/ui/modal';
|
|
||||||
import Input from '@/ui/input';
|
|
||||||
import {
|
|
||||||
StyledModalHeader,
|
|
||||||
StyledTextContent,
|
|
||||||
StyledModalWrapper,
|
|
||||||
StyledInputContent,
|
|
||||||
StyledButtonContent,
|
|
||||||
StyledButton,
|
|
||||||
} from './style';
|
|
||||||
import { useState } from 'react';
|
|
||||||
import { ModalCloseButton } from '@/ui/modal';
|
|
||||||
// import router from 'next/router';
|
|
||||||
// import { useAppState } from '@/providers/app-state-provider';
|
|
||||||
|
|
||||||
interface WorkspaceCreateProps {
|
|
||||||
open: boolean;
|
|
||||||
onClose: () => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
const DefaultHeadImgColors = [
|
|
||||||
['#C6F2F3', '#0C6066'],
|
|
||||||
['#FFF5AB', '#896406'],
|
|
||||||
['#FFCCA7', '#8F4500'],
|
|
||||||
['#FFCECE', '#AF1212'],
|
|
||||||
['#E3DEFF', '#511AAB'],
|
|
||||||
];
|
|
||||||
|
|
||||||
export const WorkspaceCreate = ({ open, onClose }: WorkspaceCreateProps) => {
|
|
||||||
const [workspaceName, setWorkspaceId] = useState<string>('');
|
|
||||||
const [creating, setCreating] = useState<boolean>(false);
|
|
||||||
// const { refreshWorkspacesMeta } = useAppState();
|
|
||||||
const handlerInputChange = (workspaceName: string) => {
|
|
||||||
setWorkspaceId(workspaceName);
|
|
||||||
};
|
|
||||||
const createDefaultHeadImg = (workspaceName: string) => {
|
|
||||||
const canvas = document.createElement('canvas');
|
|
||||||
canvas.height = 100;
|
|
||||||
canvas.width = 100;
|
|
||||||
const ctx = canvas.getContext('2d');
|
|
||||||
return new Promise<string>((resolve, reject) => {
|
|
||||||
if (ctx) {
|
|
||||||
const randomNumber = Math.floor(Math.random() * 5);
|
|
||||||
const randomColor = DefaultHeadImgColors[randomNumber];
|
|
||||||
ctx.fillStyle = randomColor[0];
|
|
||||||
ctx.fillRect(0, 0, 100, 100);
|
|
||||||
ctx.font = "600 50px 'PingFang SC', 'Microsoft Yahei'";
|
|
||||||
ctx.fillStyle = randomColor[1];
|
|
||||||
ctx.textAlign = 'center';
|
|
||||||
ctx.textBaseline = 'middle';
|
|
||||||
ctx.fillText(workspaceName[0], 50, 50);
|
|
||||||
canvas.toBlob(blob => {
|
|
||||||
if (blob) {
|
|
||||||
// const blobId = getDataCenter().then(dc =>
|
|
||||||
// dc.apis.uploadBlob({ blob })
|
|
||||||
// );
|
|
||||||
// resolve(blobId);
|
|
||||||
} else {
|
|
||||||
reject();
|
|
||||||
}
|
|
||||||
}, 'image/png');
|
|
||||||
} else {
|
|
||||||
reject();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
const handleCreateWorkspace = async () => {
|
|
||||||
setCreating(true);
|
|
||||||
const blobId = await createDefaultHeadImg(workspaceName).catch(() => {
|
|
||||||
setCreating(false);
|
|
||||||
});
|
|
||||||
if (blobId) {
|
|
||||||
// getDataCenter()
|
|
||||||
// .then(dc =>
|
|
||||||
// dc.apis.createWorkspace({ name: workspaceName, avatar: blobId })
|
|
||||||
// )
|
|
||||||
// .then(async data => {
|
|
||||||
// await refreshWorkspacesMeta();
|
|
||||||
// // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
||||||
// // @ts-ignore
|
|
||||||
// router.push(`/workspace/${data.id}`);
|
|
||||||
// onClose();
|
|
||||||
// })
|
|
||||||
// .catch(err => {
|
|
||||||
// console.log(err, 'err');
|
|
||||||
// })
|
|
||||||
// .finally(() => {
|
|
||||||
// setCreating(false);
|
|
||||||
// });
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return (
|
|
||||||
<Modal open={open} onClose={onClose}>
|
|
||||||
<StyledModalWrapper>
|
|
||||||
<ModalCloseButton onClick={onClose} />
|
|
||||||
<StyledModalHeader>Create new Workspace</StyledModalHeader>
|
|
||||||
<StyledTextContent>
|
|
||||||
Workspaces are shared environments where teams can collaborate. After
|
|
||||||
creating a Workspace, you can invite others to join.
|
|
||||||
</StyledTextContent>
|
|
||||||
<StyledInputContent>
|
|
||||||
<Input
|
|
||||||
onChange={handlerInputChange}
|
|
||||||
placeholder="Set a Workspace name"
|
|
||||||
value={workspaceName}
|
|
||||||
></Input>
|
|
||||||
</StyledInputContent>
|
|
||||||
<StyledButtonContent>
|
|
||||||
<StyledButton
|
|
||||||
disabled={!workspaceName.length || creating}
|
|
||||||
onClick={handleCreateWorkspace}
|
|
||||||
loading={creating}
|
|
||||||
>
|
|
||||||
Create
|
|
||||||
</StyledButton>
|
|
||||||
</StyledButtonContent>
|
|
||||||
</StyledModalWrapper>
|
|
||||||
</Modal>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default WorkspaceCreate;
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
export * from './WorkspaceCreate';
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
import { styled } from '@/styles';
|
|
||||||
import { Button } from '@/ui/button';
|
|
||||||
|
|
||||||
export const StyledModalWrapper = styled('div')(({ theme }) => {
|
|
||||||
return {
|
|
||||||
position: 'relative',
|
|
||||||
padding: '0px',
|
|
||||||
width: '460px',
|
|
||||||
background: theme.colors.popoverBackground,
|
|
||||||
borderRadius: '12px',
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
export const StyledModalHeader = styled('div')(({ theme }) => {
|
|
||||||
return {
|
|
||||||
margin: '44px 0px 12px 0px',
|
|
||||||
width: '460px',
|
|
||||||
fontWeight: '600',
|
|
||||||
fontSize: '20px;',
|
|
||||||
textAlign: 'center',
|
|
||||||
color: theme.colors.popoverColor,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
// export const StyledModalContent = styled('div')(({ theme }) => {});
|
|
||||||
|
|
||||||
export const StyledTextContent = styled('div')(() => {
|
|
||||||
return {
|
|
||||||
margin: 'auto',
|
|
||||||
width: '425px',
|
|
||||||
fontFamily: 'Avenir Next',
|
|
||||||
fontStyle: 'normal',
|
|
||||||
fontWeight: '400',
|
|
||||||
fontSize: '18px',
|
|
||||||
lineHeight: '26px',
|
|
||||||
textAlign: 'center',
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
export const StyledInputContent = styled('div')(() => {
|
|
||||||
return {
|
|
||||||
display: 'flex',
|
|
||||||
flexDirection: 'row',
|
|
||||||
justifyContent: 'center',
|
|
||||||
margin: '40px 0 24px 0',
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
export const StyledButtonContent = styled('div')(() => {
|
|
||||||
return {
|
|
||||||
display: 'flex',
|
|
||||||
flexDirection: 'row',
|
|
||||||
justifyContent: 'center',
|
|
||||||
margin: '0px 0 32px 0',
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
export const StyledButton = styled(Button)(() => {
|
|
||||||
return {
|
|
||||||
width: '260px',
|
|
||||||
justifyContent: 'center',
|
|
||||||
};
|
|
||||||
});
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
// import { styled } from '@/styles';
|
|
||||||
// import { useAppState } from '@/providers/app-state-provider';
|
|
||||||
// import {
|
|
||||||
// WorkspaceItemAvatar,
|
|
||||||
// PrivateWorkspaceWrapper,
|
|
||||||
// WorkspaceItemContent,
|
|
||||||
// } from './styles';
|
|
||||||
// import { useRouter } from 'next/router';
|
|
||||||
|
|
||||||
// type PrivateWorkspaceItemProps = {
|
|
||||||
// privateWorkspaceId?: string;
|
|
||||||
// };
|
|
||||||
|
|
||||||
// export const PrivateWorkspaceItem = ({
|
|
||||||
// privateWorkspaceId,
|
|
||||||
// }: PrivateWorkspaceItemProps) => {
|
|
||||||
// const { user } = useAppState();
|
|
||||||
// const router = useRouter();
|
|
||||||
// const handleClick = () => {
|
|
||||||
// if (privateWorkspaceId) {
|
|
||||||
// router.push(`/workspace/${privateWorkspaceId}`);
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
// if (user) {
|
|
||||||
// const Username = user.name;
|
|
||||||
// return (
|
|
||||||
// <PrivateWorkspaceWrapper onClick={handleClick}>
|
|
||||||
// <WorkspaceItemAvatar alt={Username} src={user.avatar_url}>
|
|
||||||
// {Username}
|
|
||||||
// </WorkspaceItemAvatar>
|
|
||||||
// <WorkspaceItemContent>
|
|
||||||
// <Name title={Username}>{Username}</Name>
|
|
||||||
// <Email title={user.email}>{user.email}</Email>
|
|
||||||
// </WorkspaceItemContent>
|
|
||||||
// </PrivateWorkspaceWrapper>
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// return null;
|
|
||||||
// };
|
|
||||||
|
|
||||||
// const Name = styled('div')(({ theme }) => {
|
|
||||||
// return {
|
|
||||||
// color: theme.colors.quoteColor,
|
|
||||||
// fontSize: theme.font.base,
|
|
||||||
// fontWeight: 500,
|
|
||||||
// overflow: 'hidden',
|
|
||||||
// textOverflow: 'ellipsis',
|
|
||||||
// whiteSpace: 'nowrap',
|
|
||||||
// };
|
|
||||||
// });
|
|
||||||
|
|
||||||
// const Email = styled('div')(({ theme }) => {
|
|
||||||
// return {
|
|
||||||
// color: theme.colors.iconColor,
|
|
||||||
// fontSize: theme.font.sm,
|
|
||||||
// overflow: 'hidden',
|
|
||||||
// textOverflow: 'ellipsis',
|
|
||||||
// whiteSpace: 'nowrap',
|
|
||||||
// };
|
|
||||||
// });
|
|
||||||
export const test = () => {
|
|
||||||
return <></>;
|
|
||||||
};
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
import { SettingsIcon } from '@blocksuite/icons';
|
|
||||||
import { styled } from '@/styles';
|
|
||||||
import { IconButton } from '@/ui/button';
|
|
||||||
import { MouseEventHandler } from 'react';
|
|
||||||
|
|
||||||
type SettingProps = {
|
|
||||||
onClick?: () => void;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const FooterSetting = ({ onClick }: SettingProps) => {
|
|
||||||
const handleClick: MouseEventHandler<HTMLButtonElement> = e => {
|
|
||||||
e.stopPropagation();
|
|
||||||
onClick && onClick();
|
|
||||||
};
|
|
||||||
return (
|
|
||||||
<Wrapper
|
|
||||||
className="footer-setting"
|
|
||||||
onClick={e => {
|
|
||||||
e.stopPropagation();
|
|
||||||
handleClick(e);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<SettingsIcon />
|
|
||||||
</Wrapper>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const Wrapper = styled(IconButton)(() => {
|
|
||||||
return {
|
|
||||||
fontSize: '20px',
|
|
||||||
};
|
|
||||||
});
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
import { UsersIcon } from '@blocksuite/icons';
|
|
||||||
import { styled } from '@/styles';
|
|
||||||
import { IconButton } from '@/ui/button';
|
|
||||||
|
|
||||||
type FooterUsersProps = {
|
|
||||||
memberCount: number;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const FooterUsers = ({ memberCount = 1 }: FooterUsersProps) => {
|
|
||||||
return (
|
|
||||||
<Wrapper className="footer-users">
|
|
||||||
<>
|
|
||||||
<UsersIcon />
|
|
||||||
<Tip>{memberCount > 99 ? '99+' : memberCount}</Tip>
|
|
||||||
</>
|
|
||||||
</Wrapper>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const Wrapper = styled(IconButton)({
|
|
||||||
display: 'flex',
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'center',
|
|
||||||
fontSize: '16px',
|
|
||||||
});
|
|
||||||
|
|
||||||
const Tip = styled('span')({
|
|
||||||
fontSize: '12px',
|
|
||||||
});
|
|
||||||
@@ -1,100 +0,0 @@
|
|||||||
// import { useRouter } from 'next/router';
|
|
||||||
// import { styled } from '@/styles';
|
|
||||||
// import {
|
|
||||||
// WorkspaceItemAvatar,
|
|
||||||
// WorkspaceItemWrapper,
|
|
||||||
// WorkspaceItemContent,
|
|
||||||
// } from '../styles';
|
|
||||||
// import { FooterSetting } from './FooterSetting';
|
|
||||||
// import { FooterUsers } from './FooterUsers';
|
|
||||||
// import { WorkspaceType } from '@affine/datacenter';
|
|
||||||
// import { useAppState } from '@/providers/app-state-provider';
|
|
||||||
|
|
||||||
// interface WorkspaceItemProps {
|
|
||||||
// id: string;
|
|
||||||
// name: string;
|
|
||||||
// icon: string;
|
|
||||||
// type: WorkspaceType;
|
|
||||||
// memberCount: number;
|
|
||||||
// onClickSetting?: (workspaceId: string) => void;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// export const WorkspaceItem = ({
|
|
||||||
// id,
|
|
||||||
// name,
|
|
||||||
// icon,
|
|
||||||
// type,
|
|
||||||
// onClickSetting,
|
|
||||||
// memberCount,
|
|
||||||
// }: WorkspaceItemProps) => {
|
|
||||||
// const router = useRouter();
|
|
||||||
|
|
||||||
// const { currentWorkspaceId } = useAppState();
|
|
||||||
|
|
||||||
// const handleClickSetting = async () => {
|
|
||||||
// onClickSetting && onClickSetting(id);
|
|
||||||
// };
|
|
||||||
|
|
||||||
// return (
|
|
||||||
// <StyledWrapper
|
|
||||||
// onClick={() => {
|
|
||||||
// router.push(`/workspace/${id}`);
|
|
||||||
// }}
|
|
||||||
// canSet={
|
|
||||||
// type !== WorkspaceType.Private && currentWorkspaceId === String(id)
|
|
||||||
// }
|
|
||||||
// >
|
|
||||||
// <WorkspaceItemAvatar alt={name} src={icon}>
|
|
||||||
// {name.charAt(0)}
|
|
||||||
// </WorkspaceItemAvatar>
|
|
||||||
// <WorkspaceItemContent>
|
|
||||||
// <Name title={name}>{name}</Name>
|
|
||||||
// </WorkspaceItemContent>
|
|
||||||
// <Footer>
|
|
||||||
// <FooterUsers memberCount={memberCount} />
|
|
||||||
// <FooterSetting onClick={handleClickSetting} />
|
|
||||||
// </Footer>
|
|
||||||
// </StyledWrapper>
|
|
||||||
// );
|
|
||||||
// };
|
|
||||||
|
|
||||||
// const Name = styled('div')(({ theme }) => {
|
|
||||||
// return {
|
|
||||||
// color: theme.colors.quoteColor,
|
|
||||||
// fontSize: theme.font.sm,
|
|
||||||
// fontWeight: 400,
|
|
||||||
// overflow: 'hidden',
|
|
||||||
// textOverflow: 'ellipsis',
|
|
||||||
// whiteSpace: 'nowrap',
|
|
||||||
// };
|
|
||||||
// });
|
|
||||||
|
|
||||||
// const StyledWrapper = styled(WorkspaceItemWrapper)<{ canSet: boolean }>(
|
|
||||||
// ({ canSet }) => {
|
|
||||||
// return {
|
|
||||||
// '& .footer-setting': {
|
|
||||||
// display: 'none',
|
|
||||||
// },
|
|
||||||
// ':hover .footer-users': {
|
|
||||||
// display: canSet ? 'none' : '',
|
|
||||||
// },
|
|
||||||
// ':hover .footer-setting': {
|
|
||||||
// display: canSet ? 'block' : 'none',
|
|
||||||
// },
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
// );
|
|
||||||
|
|
||||||
// const Footer = styled('div')({
|
|
||||||
// width: '42px',
|
|
||||||
// flex: '0 42px',
|
|
||||||
// fontSize: '20px',
|
|
||||||
// display: 'flex',
|
|
||||||
// alignItems: 'center',
|
|
||||||
// justifyContent: 'center',
|
|
||||||
// marginLeft: '12px',
|
|
||||||
// });
|
|
||||||
|
|
||||||
export const test = () => {
|
|
||||||
return <></>;
|
|
||||||
};
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
export * from './WorkspaceItem';
|
|
||||||
@@ -1,5 +1,2 @@
|
|||||||
export * from './PrivateWorkspaceItem';
|
|
||||||
// export * from './WorkspaceItem';
|
|
||||||
export * from './CreateWorkspaceItem';
|
|
||||||
export * from './ListItem';
|
export * from './ListItem';
|
||||||
export * from './LoginItem';
|
export * from './LoginItem';
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export const useMembers = () => {
|
|||||||
const inviteMember = async (email: string) => {
|
const inviteMember = async (email: string) => {
|
||||||
currentWorkspace &&
|
currentWorkspace &&
|
||||||
dataCenter &&
|
dataCenter &&
|
||||||
(await dataCenter.inviteMember(currentWorkspace?.id, email));
|
(await dataCenter.inviteMember(currentWorkspace.id, email));
|
||||||
};
|
};
|
||||||
|
|
||||||
const removeMember = async (permissionId: number) => {
|
const removeMember = async (permissionId: number) => {
|
||||||
|
|||||||
@@ -57,11 +57,10 @@ export const useWorkspaceHelper = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const deleteWorkSpace = async () => {
|
const deleteWorkSpace = async () => {
|
||||||
currentWorkspace &&
|
currentWorkspace && (await dataCenter.deleteWorkspace(currentWorkspace.id));
|
||||||
(await dataCenter.deleteWorkspace(currentWorkspace?.id));
|
|
||||||
};
|
};
|
||||||
const leaveWorkSpace = async () => {
|
const leaveWorkSpace = async () => {
|
||||||
currentWorkspace && (await dataCenter.leaveWorkspace(currentWorkspace?.id));
|
currentWorkspace && (await dataCenter.leaveWorkspace(currentWorkspace.id));
|
||||||
};
|
};
|
||||||
|
|
||||||
const acceptInvite = async (inviteCode: string) => {
|
const acceptInvite = async (inviteCode: string) => {
|
||||||
|
|||||||
@@ -105,10 +105,10 @@ export const AppStateProvider = ({
|
|||||||
// isOwner is useful only in the cloud
|
// isOwner is useful only in the cloud
|
||||||
isOwner = true;
|
isOwner = true;
|
||||||
} else {
|
} else {
|
||||||
isOwner = workspace?.owner && user?.id === workspace?.owner?.id;
|
isOwner = workspace.owner && user?.id === workspace.owner.id;
|
||||||
}
|
}
|
||||||
const pageList =
|
const pageList =
|
||||||
(workspace?.blocksuiteWorkspace?.meta.pageMetas as PageMeta[]) ?? [];
|
(workspace.blocksuiteWorkspace?.meta.pageMetas as PageMeta[]) ?? [];
|
||||||
setAppState({
|
setAppState({
|
||||||
...appState,
|
...appState,
|
||||||
currentWorkspace: workspace,
|
currentWorkspace: workspace,
|
||||||
|
|||||||
@@ -244,9 +244,7 @@ export class AffineProvider extends BaseProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override async getUserInfo(): Promise<User | undefined> {
|
public override async getUserInfo(): Promise<User | undefined> {
|
||||||
await this.init();
|
|
||||||
const user = this._apis.token.user;
|
const user = this._apis.token.user;
|
||||||
await this.init;
|
|
||||||
return user
|
return user
|
||||||
? {
|
? {
|
||||||
id: user.id,
|
id: user.id,
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ export class WorkspaceUnit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setBlocksuiteWorkspace(blocksuiteWorkspace: BlocksuiteWorkspace | null) {
|
setBlocksuiteWorkspace(blocksuiteWorkspace: BlocksuiteWorkspace | null) {
|
||||||
if (blocksuiteWorkspace && blocksuiteWorkspace?.room !== this.id) {
|
if (blocksuiteWorkspace && blocksuiteWorkspace.room !== this.id) {
|
||||||
throw new Error('Workspace id inconsistent.');
|
throw new Error('Workspace id inconsistent.');
|
||||||
}
|
}
|
||||||
this._blocksuiteWorkspace = blocksuiteWorkspace;
|
this._blocksuiteWorkspace = blocksuiteWorkspace;
|
||||||
|
|||||||
Reference in New Issue
Block a user