Merge branch 'feat/poc' into feat/datacenter

This commit is contained in:
JimmFly
2023-01-12 16:38:54 +08:00
31 changed files with 170 additions and 173 deletions
@@ -1,6 +1,6 @@
import { styled } from '@/styles';
import { WorkspaceUnit } from '@affine/datacenter';
import { Trans } from '@affine/i18n';
export const ExportPageTitleContainer = styled('div')(() => {
return {
display: 'flex',
@@ -12,8 +12,13 @@ export const ExportPageTitleContainer = styled('div')(() => {
export const ExportPage = ({ workspace }: { workspace: WorkspaceUnit }) => {
return (
<ExportPageTitleContainer>
Export Workspace{' '}
<code style={{ margin: '0 10px' }}>{workspace.name}</code> Is Comming
<Trans i18nKey="Export Workspace">
Export Workspace
<code style={{ margin: '0 10px' }}>
{{ workspace: workspace.name }}
</code>
Is Comming
</Trans>
</ExportPageTitleContainer>
);
};
@@ -12,11 +12,11 @@ import { toast } from '@/ui/toast';
// import { useAppState } from '@/providers/app-state-provider3';
import { WorkspaceUnit } from '@affine/datacenter';
import { useWorkspaceHelper } from '@/hooks/use-workspace-helper';
import { useTranslation } from '@affine/i18n';
export const PublishPage = ({ workspace }: { workspace: WorkspaceUnit }) => {
const shareUrl = window.location.host + '/public-workspace/' + workspace.id;
const { publishWorkspace, enableWorkspace } = useWorkspaceHelper();
const { t } = useTranslation();
const togglePublic = async (flag: boolean) => {
await publishWorkspace(workspace.id.toString(), flag);
};
@@ -37,22 +37,21 @@ export const PublishPage = ({ workspace }: { workspace: WorkspaceUnit }) => {
{workspace?.published ? (
<>
<StyledPublishExplanation>
Publishing to web requires AFFiNE Cloud service .
{t('Publishing')}
</StyledPublishExplanation>
<StyledSettingH2>Share with link</StyledSettingH2>
<StyledSettingH2>{t('Share with link')}</StyledSettingH2>
<StyledPublishCopyContainer>
<Input width={500} value={shareUrl} disabled={true}></Input>
<StyledCopyButtonContainer>
<Button onClick={copyUrl} type="primary" shape="circle">
Copy Link
{t('Copy Link')}
</Button>
</StyledCopyButtonContainer>
</StyledPublishCopyContainer>
</>
) : (
<StyledPublishExplanation>
After publishing to the web, everyone can view the content of
this workspace through the link.
{'Publishing Description'}
</StyledPublishExplanation>
)}
</StyledPublishContent>
@@ -64,7 +63,7 @@ export const PublishPage = ({ workspace }: { workspace: WorkspaceUnit }) => {
type="primary"
shape="circle"
>
Stop publishing
{t('Stop publishing')}
</Button>
) : (
<Button
@@ -74,7 +73,7 @@ export const PublishPage = ({ workspace }: { workspace: WorkspaceUnit }) => {
type="primary"
shape="circle"
>
Publish to web
{t('Publish to web')}
</Button>
)}
</div>
@@ -82,7 +81,7 @@ export const PublishPage = ({ workspace }: { workspace: WorkspaceUnit }) => {
<StyledPublishContent>
<>
<StyledPublishExplanation>
Publishing to web requires AFFiNE Cloud service.
{t('Publishing')}
</StyledPublishExplanation>
<StyledPublishCopyContainer>
@@ -93,7 +92,7 @@ export const PublishPage = ({ workspace }: { workspace: WorkspaceUnit }) => {
type="primary"
shape="circle"
>
Enable AFFiNE Cloud
{t('Enable AFFiNE Cloud')}
</Button>
</StyledPublishCopyContainer>
</>
@@ -8,17 +8,19 @@ import { Button } from '@/ui/button';
import { Menu, MenuItem } from '@/ui/menu';
import { WorkspaceUnit } from '@affine/datacenter';
import { useWorkspaceHelper } from '@/hooks/use-workspace-helper';
import { Trans, useTranslation } from '@affine/i18n';
export const SyncPage = ({ workspace }: { workspace: WorkspaceUnit }) => {
const { enableWorkspace } = useWorkspaceHelper();
const { t } = useTranslation();
return (
<div>
<StyledPublishContent>
{workspace?.provider === 'local' ? (
<>
<StyledPublishExplanation>
{workspace.name ?? 'Affine'} is Local Workspace. All data is
stored on the current device. You can enable AFFiNE Cloud for this
workspace to keep data in sync with the cloud.
{t('Sync Description', {
workspaceName: workspace.name ?? 'Affine',
})}
</StyledPublishExplanation>
<StyledPublishCopyContainer>
@@ -29,15 +31,18 @@ export const SyncPage = ({ workspace }: { workspace: WorkspaceUnit }) => {
type="primary"
shape="circle"
>
Enable AFFiNE Cloud
{t('Enable AFFiNE Cloud')}
</Button>
</StyledPublishCopyContainer>
</>
) : (
<>
<StyledPublishExplanation>
<code>{workspace.name ?? 'Affine'}</code> is Cloud Workspace. All
data will be synchronized and saved to the AFFiNE
<Trans i18nKey="Sync Description2">
<code>{{ workspaceName: workspace.name ?? 'Affine' }}</code>
is Cloud Workspace. All data will be synchronised and saved to
the AFFiNE
</Trans>
</StyledPublishExplanation>
<StyledPublishCopyContainer>
<Menu
@@ -49,7 +54,7 @@ export const SyncPage = ({ workspace }: { workspace: WorkspaceUnit }) => {
}}
icon={<DownloadIcon />}
>
Download core data to device
{t('Download data to device', { CoreOrAll: 'core' })}
</MenuItem>
<MenuItem
onClick={() => {
@@ -57,14 +62,16 @@ export const SyncPage = ({ workspace }: { workspace: WorkspaceUnit }) => {
}}
icon={<DownloadIcon />}
>
Download all data to device
{t('Download data to device', { CoreOrAll: 'all' })}
</MenuItem>
</>
}
placement="bottom-end"
disablePortal={true}
>
<Button>Download all data to device</Button>
<Button>
{t('Download data to device', { CoreOrAll: 'all' })}
</Button>
</Menu>
</StyledPublishCopyContainer>
</>
@@ -16,6 +16,7 @@ import { Upload } from '@/components/file-upload';
import { WorkspaceAvatar } from '@/components/workspace-avatar';
import { WorkspaceUnit } from '@affine/datacenter';
import { useWorkspaceHelper } from '@/hooks/use-workspace-helper';
import { useTranslation } from '@affine/i18n';
export const GeneralPage = ({ workspace }: { workspace: WorkspaceUnit }) => {
const [showDelete, setShowDelete] = useState<boolean>(false);
const [showLeave, setShowLeave] = useState<boolean>(false);
@@ -23,6 +24,8 @@ export const GeneralPage = ({ workspace }: { workspace: WorkspaceUnit }) => {
const [workspaceName, setWorkspaceName] = useState<string>(workspace.name);
const { currentWorkspace } = useAppState();
const { updateWorkspace } = useWorkspaceHelper();
const { t } = useTranslation();
const isOwner = true;
const handleChangeWorkSpaceName = (newName: string) => {
setWorkspaceName(newName);
@@ -56,7 +59,7 @@ export const GeneralPage = ({ workspace }: { workspace: WorkspaceUnit }) => {
return workspace ? (
<div>
<StyledSettingH2 marginTop={56}>Workspace Icon</StyledSettingH2>
<StyledSettingH2 marginTop={56}>{t('Workspace Icon')}</StyledSettingH2>
<StyledSettingAvatarContent>
<div
style={{
@@ -74,16 +77,16 @@ export const GeneralPage = ({ workspace }: { workspace: WorkspaceUnit }) => {
accept="image/gif,image/jpeg,image/jpg,image/png,image/svg"
fileChange={fileChange}
>
<Button loading={uploading}>Upload</Button>
<Button loading={uploading}>{t('Upload')}</Button>
</Upload>
{/* TODO: add upload logic */}
</StyledSettingAvatarContent>
<StyledSettingH2 marginTop={20}>Workspace Name</StyledSettingH2>
<StyledSettingH2 marginTop={20}>{t('Workspace Name')}</StyledSettingH2>
<StyledSettingInputContainer>
<Input
width={327}
value={workspaceName}
placeholder="Workspace Name"
placeholder={t('Workspace Name')}
maxLength={14}
minLength={1}
onChange={handleChangeWorkSpaceName}
@@ -97,7 +100,7 @@ export const GeneralPage = ({ workspace }: { workspace: WorkspaceUnit }) => {
</TextButton>
</StyledSettingInputContainer>
<StyledSettingH2 marginTop={20}>Workspace Type</StyledSettingH2>
<StyledSettingH2 marginTop={20}>{t('Workspace Type')}</StyledSettingH2>
<StyledSettingInputContainer>
<code>{workspace.provider} </code>
</StyledSettingInputContainer>
@@ -105,7 +108,7 @@ export const GeneralPage = ({ workspace }: { workspace: WorkspaceUnit }) => {
{isOwner ? (
<>
<Button type="danger" shape="circle" onClick={handleClickDelete}>
Delete Workspace
{t('Delete Workspace')}
</Button>
<WorkspaceDelete
open={showDelete}
@@ -116,7 +119,7 @@ export const GeneralPage = ({ workspace }: { workspace: WorkspaceUnit }) => {
) : (
<>
<Button type="danger" shape="circle" onClick={handleClickLeave}>
Leave Workspace
{t('Leave Workspace')}
</Button>
<WorkspaceLeave
open={showLeave}
@@ -18,7 +18,7 @@ import {
// Workspace,
} from '@/hooks/mock-data/mock';
import { WorkspaceUnit } from '@affine/datacenter';
import { Trans, useTranslation } from '@affine/i18n';
interface WorkspaceDeleteProps {
open: boolean;
onClose: () => void;
@@ -31,6 +31,7 @@ export const WorkspaceDelete = ({
workspace,
}: WorkspaceDeleteProps) => {
const [deleteStr, setDeleteStr] = useState<string>('');
const { t } = useTranslation();
const router = useRouter();
const handlerInputChange = (workspaceName: string) => {
@@ -55,31 +56,40 @@ export const WorkspaceDelete = ({
<Modal open={open} onClose={onClose}>
<StyledModalWrapper>
<ModalCloseButton onClick={onClose} />
<StyledModalHeader>Delete Workspace</StyledModalHeader>
<StyledModalHeader>{t('Delete Workspace')}</StyledModalHeader>
{workspace.provider === 'local' ? (
<StyledTextContent>
Deleting (
<StyledWorkspaceName>{workspace.name}</StyledWorkspaceName>) cannot
be undone, please proceed with caution. along with all its content.
<Trans i18nKey="Delete Workspace Description">
Deleting (
<StyledWorkspaceName>
{{ workspace: workspace.name }}
</StyledWorkspaceName>
) cannot be undone, please proceed with caution. along with all
its content.
</Trans>
</StyledTextContent>
) : (
<StyledTextContent>
Deleting (
<StyledWorkspaceName>{workspace.name}</StyledWorkspaceName>) will
delete both local and cloud data, this operation cannot be undone,
please proceed with caution.
<Trans i18nKey="Delete Workspace Description2">
Deleting (
<StyledWorkspaceName>
{{ workspace: workspace.name }}
</StyledWorkspaceName>
) will delete both local and cloud data, this operation cannot be
undone, please proceed with caution.
</Trans>
</StyledTextContent>
)}
<StyledInputContent>
<Input
onChange={handlerInputChange}
placeholder="Please type “Delete” to confirm"
placeholder={t('Delete Workspace placeholder')}
value={deleteStr}
></Input>
</StyledInputContent>
<StyledButtonContent>
<Button shape="circle" onClick={onClose}>
Cancel
{t('Cancel')}
</Button>
<Button
disabled={deleteStr.toLowerCase() !== 'delete'}
@@ -88,7 +98,7 @@ export const WorkspaceDelete = ({
shape="circle"
style={{ marginLeft: '24px' }}
>
Delete
{t('Delete')}
</Button>
</StyledButtonContent>
</StyledModalWrapper>
@@ -7,6 +7,7 @@ import {
} from './style';
import { ModalCloseButton } from '@/ui/modal';
import { Button } from '@/ui/button';
import { useTranslation } from '@affine/i18n';
// import { getDataCenter } from '@affine/datacenter';
// import { useAppState } from '@/providers/app-state-provider';
@@ -22,6 +23,7 @@ export const WorkspaceLeave = ({
onClose,
workspaceId,
}: WorkspaceDeleteProps) => {
const { t } = useTranslation();
console.log('workspaceId: ', workspaceId);
// const router = useRouter();
// const { refreshWorkspacesMeta } = useAppState();
@@ -37,14 +39,13 @@ export const WorkspaceLeave = ({
<Modal open={open} onClose={onClose}>
<StyledModalWrapper>
<ModalCloseButton onClick={onClose} />
<StyledModalHeader>Leave Workspace</StyledModalHeader>
<StyledModalHeader>{t('Leave Workspace')}</StyledModalHeader>
<StyledTextContent>
After you leave, you will not be able to access all the contents of
this workspace.
{t('Leave Workspace Description')}
</StyledTextContent>
<StyledButtonContent>
<Button shape="circle" onClick={onClose}>
Cancel
{t('Cancel')}
</Button>
<Button
onClick={handleLeave}
@@ -52,7 +53,7 @@ export const WorkspaceLeave = ({
shape="circle"
style={{ marginLeft: '24px' }}
>
Leave
{t('Leave')}
</Button>
</StyledButtonContent>
</StyledModalWrapper>
@@ -7,6 +7,7 @@ import { useState } from 'react';
import { Avatar } from '@mui/material';
import useMembers from '@/hooks/use-members';
import { User } from '@affine/datacenter';
import { useTranslation } from '@affine/i18n';
interface LoginModalProps {
open: boolean;
onClose: () => void;
@@ -53,6 +54,7 @@ export const InviteMemberModal = ({
const [showTip, setShowTip] = useState<boolean>(false);
const [userData, setUserData] = useState<User | null>(null);
const { inviteMember, getUserByEmail } = useMembers();
const { t } = useTranslation();
const inputChange = (value: string) => {
setShowMember(true);
if (gmailReg.test(value)) {
@@ -82,7 +84,7 @@ export const InviteMemberModal = ({
/>
</Header>
<Content>
<ContentTitle>Invite members</ContentTitle>
<ContentTitle>{t('Invite Members')}</ContentTitle>
<InviteBox>
<Input
width={360}
@@ -91,12 +93,12 @@ export const InviteMemberModal = ({
onBlur={() => {
setShowMember(false);
}}
placeholder="Search mail (Gmail support only)"
placeholder={t('Invite placeholder')}
></Input>
{showMember ? (
<Members>
{showTip ? (
<NoFind>Non-Gmail is not supported</NoFind>
<NoFind>{t('Non-Gmail')}</NoFind>
) : (
<Member>
{userData?.avatar ? (
@@ -125,7 +127,7 @@ export const InviteMemberModal = ({
onInviteSuccess();
}}
>
Invite
{t('Invite')}
</Button>
</Footer>
</ModalWrapper>