feat: rewrite enable affile cloud
This commit is contained in:
24
packages/app/src/components/enable-workspace/index.tsx
Normal file
24
packages/app/src/components/enable-workspace/index.tsx
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
import { useWorkspaceHelper } from '@/hooks/use-workspace-helper';
|
||||||
|
import { Button } from '@/ui/button';
|
||||||
|
import { useTranslation } from '@affine/i18n';
|
||||||
|
import { useState } from 'react';
|
||||||
|
|
||||||
|
export const EnableWorkspaceButton = () => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const { enableWorkspace } = useWorkspaceHelper();
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
return (
|
||||||
|
<Button
|
||||||
|
type="primary"
|
||||||
|
shape="circle"
|
||||||
|
loading={loading}
|
||||||
|
onClick={async () => {
|
||||||
|
setLoading(true);
|
||||||
|
await enableWorkspace();
|
||||||
|
setLoading(false);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{t('Enable AFFiNE Cloud')}
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -16,9 +16,10 @@ import { useWorkspaceHelper } from '@/hooks/use-workspace-helper';
|
|||||||
import { useTranslation } from '@affine/i18n';
|
import { useTranslation } from '@affine/i18n';
|
||||||
import Loading from '@/components/loading';
|
import Loading from '@/components/loading';
|
||||||
import { Wrapper } from '@/ui/layout';
|
import { Wrapper } from '@/ui/layout';
|
||||||
|
import { EnableWorkspaceButton } from '../enable-workspace';
|
||||||
export const PublishPage = ({ workspace }: { workspace: WorkspaceUnit }) => {
|
export const PublishPage = ({ workspace }: { workspace: WorkspaceUnit }) => {
|
||||||
const shareUrl = window.location.host + '/public-workspace/' + workspace.id;
|
const shareUrl = window.location.host + '/public-workspace/' + workspace.id;
|
||||||
const { publishWorkspace, enableWorkspace } = useWorkspaceHelper();
|
const { publishWorkspace } = useWorkspaceHelper();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [loaded, setLoaded] = useState(true);
|
const [loaded, setLoaded] = useState(true);
|
||||||
const togglePublic = async (flag: boolean) => {
|
const togglePublic = async (flag: boolean) => {
|
||||||
@@ -30,9 +31,6 @@ export const PublishPage = ({ workspace }: { workspace: WorkspaceUnit }) => {
|
|||||||
toast('Copied url to clipboard');
|
toast('Copied url to clipboard');
|
||||||
};
|
};
|
||||||
|
|
||||||
const enableAffineCloud = async () => {
|
|
||||||
await enableWorkspace();
|
|
||||||
};
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{workspace.provider === 'affine' ? (
|
{workspace.provider === 'affine' ? (
|
||||||
@@ -100,17 +98,7 @@ export const PublishPage = ({ workspace }: { workspace: WorkspaceUnit }) => {
|
|||||||
</StyledPublishExplanation>
|
</StyledPublishExplanation>
|
||||||
|
|
||||||
<StyledPublishCopyContainer>
|
<StyledPublishCopyContainer>
|
||||||
<Button
|
<EnableWorkspaceButton></EnableWorkspaceButton>
|
||||||
onClick={async () => {
|
|
||||||
setLoaded(false);
|
|
||||||
await enableAffineCloud();
|
|
||||||
setLoaded(true);
|
|
||||||
}}
|
|
||||||
type="primary"
|
|
||||||
shape="circle"
|
|
||||||
>
|
|
||||||
{t('Enable AFFiNE Cloud')}
|
|
||||||
</Button>
|
|
||||||
</StyledPublishCopyContainer>
|
</StyledPublishCopyContainer>
|
||||||
</>
|
</>
|
||||||
</StyledPublishContent>
|
</StyledPublishContent>
|
||||||
|
|||||||
@@ -9,11 +9,10 @@ import { DownloadIcon } from '@blocksuite/icons';
|
|||||||
import { Button } from '@/ui/button';
|
import { Button } from '@/ui/button';
|
||||||
import { Menu, MenuItem } from '@/ui/menu';
|
import { Menu, MenuItem } from '@/ui/menu';
|
||||||
import { WorkspaceUnit } from '@affine/datacenter';
|
import { WorkspaceUnit } from '@affine/datacenter';
|
||||||
import { useWorkspaceHelper } from '@/hooks/use-workspace-helper';
|
|
||||||
import { Trans, useTranslation } from '@affine/i18n';
|
import { Trans, useTranslation } from '@affine/i18n';
|
||||||
import { WorkspaceUnitAvatar } from '@/components/workspace-avatar';
|
import { WorkspaceUnitAvatar } from '@/components/workspace-avatar';
|
||||||
|
import { EnableWorkspaceButton } from '../enable-workspace';
|
||||||
export const SyncPage = ({ workspace }: { workspace: WorkspaceUnit }) => {
|
export const SyncPage = ({ workspace }: { workspace: WorkspaceUnit }) => {
|
||||||
const { enableWorkspace } = useWorkspaceHelper();
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
@@ -36,16 +35,7 @@ export const SyncPage = ({ workspace }: { workspace: WorkspaceUnit }) => {
|
|||||||
Cloud for this workspace to keep data in sync with the cloud.
|
Cloud for this workspace to keep data in sync with the cloud.
|
||||||
</StyledWorkspaceType>
|
</StyledWorkspaceType>
|
||||||
<StyledPublishCopyContainer>
|
<StyledPublishCopyContainer>
|
||||||
<Button
|
<EnableWorkspaceButton></EnableWorkspaceButton>
|
||||||
onClick={async () => {
|
|
||||||
await enableWorkspace();
|
|
||||||
}}
|
|
||||||
type="primary"
|
|
||||||
shape="circle"
|
|
||||||
style={{ fontWeight: '500' }}
|
|
||||||
>
|
|
||||||
{t('Enable AFFiNE Cloud')}
|
|
||||||
</Button>
|
|
||||||
</StyledPublishCopyContainer>
|
</StyledPublishCopyContainer>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@@ -27,14 +27,13 @@ import useMembers from '@/hooks/use-members';
|
|||||||
import Loading from '@/components/loading';
|
import Loading from '@/components/loading';
|
||||||
import { Wrapper } from '@/ui/layout';
|
import { Wrapper } from '@/ui/layout';
|
||||||
import { useTranslation } from '@affine/i18n';
|
import { useTranslation } from '@affine/i18n';
|
||||||
import { useWorkspaceHelper } from '@/hooks/use-workspace-helper';
|
import { EnableWorkspaceButton } from '@/components/enable-workspace';
|
||||||
|
|
||||||
export const MembersPage = ({ workspace }: { workspace: WorkspaceUnit }) => {
|
export const MembersPage = ({ workspace }: { workspace: WorkspaceUnit }) => {
|
||||||
const [isInviteModalShow, setIsInviteModalShow] = useState(false);
|
const [isInviteModalShow, setIsInviteModalShow] = useState(false);
|
||||||
const { members, removeMember, loaded } = useMembers();
|
const { members, removeMember, loaded } = useMembers();
|
||||||
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { enableWorkspace } = useWorkspaceHelper();
|
|
||||||
const { confirm } = useConfirm();
|
const { confirm } = useConfirm();
|
||||||
|
|
||||||
if (workspace.provider === 'affine') {
|
if (workspace.provider === 'affine') {
|
||||||
@@ -163,15 +162,7 @@ export const MembersPage = ({ workspace }: { workspace: WorkspaceUnit }) => {
|
|||||||
<StyledMemberWarp>
|
<StyledMemberWarp>
|
||||||
{t('Collaboration Description')}
|
{t('Collaboration Description')}
|
||||||
<StyledPublishExplanation>
|
<StyledPublishExplanation>
|
||||||
<Button
|
<EnableWorkspaceButton></EnableWorkspaceButton>
|
||||||
type="primary"
|
|
||||||
shape="circle"
|
|
||||||
onClick={async () => {
|
|
||||||
await enableWorkspace();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{t('Enable AFFiNE Cloud')}
|
|
||||||
</Button>
|
|
||||||
</StyledPublishExplanation>
|
</StyledPublishExplanation>
|
||||||
</StyledMemberWarp>
|
</StyledMemberWarp>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user