mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-25 22:38:56 +08:00
feat: mock login
This commit is contained in:
@@ -16,7 +16,7 @@ import { Workspace as StoreWorkspace } from '@blocksuite/store';
|
||||
import { debounce } from '@/utils';
|
||||
import { WorkspaceLeave } from './leave';
|
||||
import { Upload } from '@/components/file-upload';
|
||||
import { Workspace } from '@/hooks/mock-data/mock';
|
||||
import { getUserInfo, Workspace } from '@/hooks/mock-data/mock';
|
||||
|
||||
export const GeneralPage = ({
|
||||
workspace,
|
||||
@@ -30,6 +30,7 @@ export const GeneralPage = ({
|
||||
workspaces,
|
||||
refreshWorkspacesMeta,
|
||||
} = useAppState();
|
||||
// const user = getUserInfo();
|
||||
const [showDelete, setShowDelete] = useState<boolean>(false);
|
||||
const [showLeave, setShowLeave] = useState<boolean>(false);
|
||||
const [uploading, setUploading] = useState<boolean>(false);
|
||||
@@ -38,11 +39,9 @@ export const GeneralPage = ({
|
||||
refreshWorkspacesMeta();
|
||||
}, 100);
|
||||
const isOwner = true;
|
||||
|
||||
const handleChangeWorkSpaceName = (newName: string) => {
|
||||
setWorkspaceName(newName);
|
||||
currentWorkspace?.meta.setName(newName);
|
||||
workspaces[workspace.id]?.meta.setName(newName);
|
||||
debouncedRefreshWorkspacesMeta();
|
||||
};
|
||||
const currentWorkspaceIndex = workspacesMeta.findIndex(
|
||||
meta => meta.id === workspace.id
|
||||
|
||||
@@ -43,7 +43,11 @@ import { toast } from '@/ui/toast';
|
||||
import { Empty } from '@/ui/empty';
|
||||
import { useAppState } from '@/providers/app-state-provider';
|
||||
import { GeneralPage } from './general';
|
||||
import { getActiveWorkspace, Workspace } from '@/hooks/mock-data/mock';
|
||||
import {
|
||||
getActiveWorkspace,
|
||||
setWorkspacePublish,
|
||||
Workspace,
|
||||
} from '@/hooks/mock-data/mock';
|
||||
|
||||
enum ActiveTab {
|
||||
'general' = 'general',
|
||||
@@ -112,6 +116,7 @@ export const WorkspaceSetting = ({
|
||||
};
|
||||
|
||||
const workspace = getActiveWorkspace();
|
||||
console.log('workspace: ', workspace);
|
||||
const handleClickClose = () => {
|
||||
onClose && onClose();
|
||||
};
|
||||
@@ -123,7 +128,7 @@ export const WorkspaceSetting = ({
|
||||
}
|
||||
}, [isShow]);
|
||||
return (
|
||||
<Modal open={false}>
|
||||
<Modal open={isShow}>
|
||||
<StyledSettingContainer>
|
||||
<ModalCloseButton onClick={handleClickClose} />
|
||||
{isOwner ? (
|
||||
@@ -287,23 +292,16 @@ const MembersPage = ({ workspace }: { workspace: Workspace }) => {
|
||||
};
|
||||
|
||||
const PublishPage = ({ workspace }: { workspace: Workspace }) => {
|
||||
const shareUrl = window.location.host + '/workspace/' + workspace.id;
|
||||
const shareUrl =
|
||||
window.location.host + '/workspace/' + workspace.id + '?share=true';
|
||||
const [publicStatus, setPublicStatus] = useState<boolean | null>(
|
||||
workspace.isPublish ?? false
|
||||
);
|
||||
const togglePublic = (flag: boolean) => {
|
||||
getDataCenter()
|
||||
.then(dc =>
|
||||
dc.apis.updateWorkspace({
|
||||
id: workspace.id,
|
||||
public: flag,
|
||||
})
|
||||
)
|
||||
.then(data => {
|
||||
setPublicStatus(data?.public);
|
||||
toast('Updated Public Status Success');
|
||||
});
|
||||
const isPublic = setWorkspacePublish(workspace.id, flag);
|
||||
setPublicStatus(isPublic);
|
||||
};
|
||||
|
||||
const copyUrl = () => {
|
||||
navigator.clipboard.writeText(shareUrl);
|
||||
toast('Copied url to clipboard');
|
||||
|
||||
Reference in New Issue
Block a user