From 152093e7d87cacd0f5580e3fd4a28b67d44aae58 Mon Sep 17 00:00:00 2001 From: DiamondThree <857159145@qq.com> Date: Mon, 30 Jan 2023 12:37:28 +0800 Subject: [PATCH 1/5] fix: publish status error and delete export tab --- .../src/components/workspace-modal/index.tsx | 10 ++++++++-- .../workspace-setting/PublishPage.tsx | 4 +--- .../components/workspace-setting/SyncPage.tsx | 19 ++++++++++++++----- .../src/components/workspace-setting/style.ts | 1 + .../pages/workspace/[workspaceId]/setting.tsx | 10 +++++----- 5 files changed, 29 insertions(+), 15 deletions(-) diff --git a/packages/app/src/components/workspace-modal/index.tsx b/packages/app/src/components/workspace-modal/index.tsx index c0dd2a8bd3..2ce3e50995 100644 --- a/packages/app/src/components/workspace-modal/index.tsx +++ b/packages/app/src/components/workspace-modal/index.tsx @@ -20,7 +20,13 @@ import { useRouter } from 'next/router'; import { useTranslation } from '@affine/i18n'; import { LanguageMenu } from './languageMenu'; -import { CloudIcon, LineIcon, LocalIcon, OfflineIcon } from './icons'; +import { + CloudIcon, + LineIcon, + LocalIcon, + OfflineIcon, + PublishedIcon, +} from './icons'; import { LoginModal } from '../login-modal'; import { LogoutModal } from '../logout-modal'; interface WorkspaceModalProps { @@ -120,7 +126,7 @@ export const WorkspaceModal = ({ open, onClose }: WorkspaceModalProps) => { )} {item.published && (

- Published to Web + Published to Web

)} diff --git a/packages/app/src/components/workspace-setting/PublishPage.tsx b/packages/app/src/components/workspace-setting/PublishPage.tsx index a30b72bdf7..a03749fe98 100644 --- a/packages/app/src/components/workspace-setting/PublishPage.tsx +++ b/packages/app/src/components/workspace-setting/PublishPage.tsx @@ -10,7 +10,6 @@ import { useState } from 'react'; import { Button } from '@/ui/button'; import Input from '@/ui/input'; 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'; @@ -23,6 +22,7 @@ export const PublishPage = ({ workspace }: { workspace: WorkspaceUnit }) => { const togglePublic = async (flag: boolean) => { try { await publishWorkspace(workspace.id.toString(), flag); + setLoaded(false); } catch (e) { toast('Failed to publish workspace'); } @@ -67,7 +67,6 @@ export const PublishPage = ({ workspace }: { workspace: WorkspaceUnit }) => { onClick={async () => { setLoaded(true); await togglePublic(true); - setLoaded(false); }} loading={loaded} type="primary" @@ -86,7 +85,6 @@ export const PublishPage = ({ workspace }: { workspace: WorkspaceUnit }) => { onClick={async () => { setLoaded(true); await togglePublic(false); - setLoaded(true); }} loading={false} type="danger" diff --git a/packages/app/src/components/workspace-setting/SyncPage.tsx b/packages/app/src/components/workspace-setting/SyncPage.tsx index 6969461a38..69a3df8a67 100644 --- a/packages/app/src/components/workspace-setting/SyncPage.tsx +++ b/packages/app/src/components/workspace-setting/SyncPage.tsx @@ -12,8 +12,10 @@ import { WorkspaceUnit } from '@affine/datacenter'; import { Trans, useTranslation } from '@affine/i18n'; import { WorkspaceUnitAvatar } from '@/components/workspace-avatar'; import { EnableWorkspaceButton } from '../enable-workspace'; +import { useAppState } from '@/providers/app-state-provider'; export const SyncPage = ({ workspace }: { workspace: WorkspaceUnit }) => { const { t } = useTranslation(); + const { user } = useAppState(); return (
@@ -40,12 +42,19 @@ export const SyncPage = ({ workspace }: { workspace: WorkspaceUnit }) => { ) : ( <> - - {{ workspaceName: workspace.name ?? 'Affine' }} - is Cloud Workspace. All data will be synchronised and saved to - the AFFiNE - + + {workspace.name} is + Cloud Workspace. + + All data will be synchronized and saved to the AFFiNE account{' '} + {user?.email} + { return { display: 'flex', flexDirection: 'column', + flex: 1, }; }); diff --git a/packages/app/src/pages/workspace/[workspaceId]/setting.tsx b/packages/app/src/pages/workspace/[workspaceId]/setting.tsx index 11de4aa598..48451dabfd 100644 --- a/packages/app/src/pages/workspace/[workspaceId]/setting.tsx +++ b/packages/app/src/pages/workspace/[workspaceId]/setting.tsx @@ -42,11 +42,11 @@ const tabMap: { name: 'Publish', panelRender: workspace => , }, - - { - name: 'Export', - panelRender: workspace => , - }, + // TODO: next version will finish this feature + // { + // name: 'Export', + // panelRender: workspace => , + // }, ]; const WorkspaceSetting = () => { From f28a1df624ebfa4b5a81ff6c82c8e926b6da0089 Mon Sep 17 00:00:00 2001 From: DiamondThree <857159145@qq.com> Date: Mon, 30 Jan 2023 12:44:38 +0800 Subject: [PATCH 2/5] fix: lint erroe --- packages/app/src/components/workspace-modal/index.tsx | 1 - packages/app/src/components/workspace-setting/SyncPage.tsx | 2 +- packages/app/src/hooks/use-workspace-helper.ts | 4 ++-- packages/app/src/pages/workspace/[workspaceId]/setting.tsx | 1 - 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/app/src/components/workspace-modal/index.tsx b/packages/app/src/components/workspace-modal/index.tsx index 2ce3e50995..7c7dafc4f7 100644 --- a/packages/app/src/components/workspace-modal/index.tsx +++ b/packages/app/src/components/workspace-modal/index.tsx @@ -8,7 +8,6 @@ import { AddIcon, LogOutIcon, CloudInsyncIcon, - PublishIcon, CloseIcon, } from '@blocksuite/icons'; import { diff --git a/packages/app/src/components/workspace-setting/SyncPage.tsx b/packages/app/src/components/workspace-setting/SyncPage.tsx index 69a3df8a67..7e17d83cf8 100644 --- a/packages/app/src/components/workspace-setting/SyncPage.tsx +++ b/packages/app/src/components/workspace-setting/SyncPage.tsx @@ -9,7 +9,7 @@ import { DownloadIcon } from '@blocksuite/icons'; import { Button } from '@/ui/button'; import { Menu, MenuItem } from '@/ui/menu'; import { WorkspaceUnit } from '@affine/datacenter'; -import { Trans, useTranslation } from '@affine/i18n'; +import { useTranslation } from '@affine/i18n'; import { WorkspaceUnitAvatar } from '@/components/workspace-avatar'; import { EnableWorkspaceButton } from '../enable-workspace'; import { useAppState } from '@/providers/app-state-provider'; diff --git a/packages/app/src/hooks/use-workspace-helper.ts b/packages/app/src/hooks/use-workspace-helper.ts index 2a1977f968..870d954638 100644 --- a/packages/app/src/hooks/use-workspace-helper.ts +++ b/packages/app/src/hooks/use-workspace-helper.ts @@ -31,8 +31,8 @@ export const useWorkspaceHelper = () => { await dataCenter.updateWorkspaceMeta({ name }, workspace); } if (avatarBlob) { - // const blobId = await dataCenter.setBlob(workspace, avatarBlob); - // await dataCenter.updateWorkspaceMeta({ avatar: blobId }, workspace); + const blobId = await dataCenter.setBlob(workspace, avatarBlob); + await dataCenter.updateWorkspaceMeta({ avatar: blobId }, workspace); } }; diff --git a/packages/app/src/pages/workspace/[workspaceId]/setting.tsx b/packages/app/src/pages/workspace/[workspaceId]/setting.tsx index 48451dabfd..975e3d6ff1 100644 --- a/packages/app/src/pages/workspace/[workspaceId]/setting.tsx +++ b/packages/app/src/pages/workspace/[workspaceId]/setting.tsx @@ -10,7 +10,6 @@ import { GeneralPage, MembersPage, PublishPage, - ExportPage, SyncPage, } from '@/components/workspace-setting'; import { SettingsIcon } from '@blocksuite/icons'; From 05aa532d58a535eb08d4faccbcd2427a98944873 Mon Sep 17 00:00:00 2001 From: DiamondThree <857159145@qq.com> Date: Mon, 30 Jan 2023 15:51:27 +0800 Subject: [PATCH 3/5] fix: delete import --- .../app/src/components/workspace-slider-bar/index.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/app/src/components/workspace-slider-bar/index.tsx b/packages/app/src/components/workspace-slider-bar/index.tsx index ce6f8d43d3..7ff7965e78 100644 --- a/packages/app/src/components/workspace-slider-bar/index.tsx +++ b/packages/app/src/components/workspace-slider-bar/index.tsx @@ -65,7 +65,7 @@ const FavoriteList = ({ showList }: { showList: boolean }) => { ); }; export const WorkSpaceSliderBar = () => { - const { triggerQuickSearchModal, triggerImportModal } = useModal(); + const { triggerQuickSearchModal } = useModal(); const [showSubFavorite, setShowSubFavorite] = useState(true); const { currentWorkspace } = useAppState(); const { openPage, createPage } = usePageHelper(); @@ -161,14 +161,14 @@ export const WorkSpaceSliderBar = () => { setShowWorkspaceSetting(false); }} /> */} - - { triggerImportModal(); }} > {t('Import')} - + */} From be35e2beac2e015bf19d6d9066eea916cae12d83 Mon Sep 17 00:00:00 2001 From: DiamondThree <857159145@qq.com> Date: Mon, 30 Jan 2023 16:11:02 +0800 Subject: [PATCH 4/5] fix: delete no-used --- packages/app/src/components/workspace-slider-bar/index.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/app/src/components/workspace-slider-bar/index.tsx b/packages/app/src/components/workspace-slider-bar/index.tsx index 7ff7965e78..a4c91f7a61 100644 --- a/packages/app/src/components/workspace-slider-bar/index.tsx +++ b/packages/app/src/components/workspace-slider-bar/index.tsx @@ -17,7 +17,6 @@ import { SearchIcon, AllPagesIcon, FavouritesIcon, - ImportIcon, TrashIcon, AddIcon, SettingsIcon, From d7e3d524e5a451acc4afc81273cf7f45f6df3a66 Mon Sep 17 00:00:00 2001 From: DiamondThree Date: Tue, 31 Jan 2023 18:07:55 +0800 Subject: [PATCH 5/5] fix: userInfo name conversion encoding format (#755) --- .../src/provider/affine/apis/token.ts | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/packages/data-center/src/provider/affine/apis/token.ts b/packages/data-center/src/provider/affine/apis/token.ts index 88c1997772..f002fedb9e 100644 --- a/packages/data-center/src/provider/affine/apis/token.ts +++ b/packages/data-center/src/provider/affine/apis/token.ts @@ -100,17 +100,13 @@ class Token { static parse(token: string): AccessTokenMessage | null { try { return JSON.parse( - String.fromCharCode.apply( - null, - Array.from( - Uint8Array.from( - window.atob( - // split jwt - token.split('.')[1] - ), - c => c.charCodeAt(0) - ) - ) + decodeURIComponent( + atob(token.split('.')[1]) + .split('') + .map(function (c) { + return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2); + }) + .join('') ) ); } catch (error) {