mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-17 01:56:27 +08:00
Merge branch 'feat/filesystem_and_search' of github.com:toeverything/AFFiNE into feat/filesystem_and_search
This commit is contained in:
@@ -13,6 +13,7 @@ import { ModalCloseButton } from '@/ui/modal';
|
||||
import { Button } from '@/ui/button';
|
||||
import { deleteWorkspace } from '@pathfinder/data-services';
|
||||
import { useRouter } from 'next/router';
|
||||
import { useAppState } from '@/providers/app-state-provider';
|
||||
|
||||
interface WorkspaceDeleteProps {
|
||||
open: boolean;
|
||||
@@ -31,6 +32,7 @@ export const WorkspaceDelete = ({
|
||||
}: WorkspaceDeleteProps) => {
|
||||
const [deleteStr, setDeleteStr] = useState<string>('');
|
||||
const router = useRouter();
|
||||
const { refreshWorkspacesMeta } = useAppState();
|
||||
|
||||
const handlerInputChange = (workspaceName: string) => {
|
||||
setDeleteStr(workspaceName);
|
||||
@@ -39,6 +41,7 @@ export const WorkspaceDelete = ({
|
||||
const handleDelete = async () => {
|
||||
await deleteWorkspace({ id: workspaceId });
|
||||
router.push(`/workspace/${nextWorkSpaceId}`);
|
||||
refreshWorkspacesMeta();
|
||||
onClose();
|
||||
};
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ import {
|
||||
Workspace,
|
||||
Member,
|
||||
removeMember,
|
||||
updateWorkspace,
|
||||
} from '@pathfinder/data-services';
|
||||
import { Avatar } from '@mui/material';
|
||||
import { Menu, MenuItem } from '@/ui/menu';
|
||||
@@ -158,7 +159,9 @@ export const WorkspaceSetting = ({
|
||||
{activeTab === ActiveTab.members && workspace && (
|
||||
<MembersPage workspace={workspace} />
|
||||
)}
|
||||
{activeTab === ActiveTab.publish && <PublishPage />}
|
||||
{activeTab === ActiveTab.publish && (
|
||||
<PublishPage workspace={workspace} />
|
||||
)}
|
||||
</StyledSettingContent>
|
||||
</StyledSettingContainer>
|
||||
</Modal>
|
||||
@@ -286,31 +289,69 @@ const MembersPage = ({ workspace }: { workspace: Workspace }) => {
|
||||
);
|
||||
};
|
||||
|
||||
const PublishPage = () => {
|
||||
const PublishPage = ({ workspace }: { workspace: Workspace }) => {
|
||||
const { refreshWorkspacesMeta } = useAppState();
|
||||
const shareUrl = window.location.host + '/workspace/' + workspace.id;
|
||||
const togglePublic = (flag: boolean) => {
|
||||
updateWorkspace({
|
||||
id: workspace.id,
|
||||
public: flag,
|
||||
}).then(data => {
|
||||
refreshWorkspacesMeta();
|
||||
toast('Updated');
|
||||
});
|
||||
};
|
||||
const copyUrl = () => {
|
||||
navigator.clipboard.writeText(shareUrl);
|
||||
toast('Copied');
|
||||
};
|
||||
return (
|
||||
<div>
|
||||
<StyledPublishContent>
|
||||
<StyledPublishExplanation>
|
||||
After publishing to the web, everyone can view the content of this
|
||||
workspace through the link.
|
||||
</StyledPublishExplanation>
|
||||
<StyledSettingH2 marginTop={48}>Share with link</StyledSettingH2>
|
||||
<StyledPublishCopyContainer>
|
||||
<Input
|
||||
width={500}
|
||||
value={'www.baidu.com/asdsadas/asdsadasd'}
|
||||
disabled
|
||||
></Input>
|
||||
<StyledCopyButtonContainer>
|
||||
<Button type="primary" shape="circle">
|
||||
Copy Link
|
||||
</Button>
|
||||
</StyledCopyButtonContainer>
|
||||
</StyledPublishCopyContainer>
|
||||
{workspace.public ? (
|
||||
<StyledPublishExplanation>
|
||||
After publishing to the web, everyone can view the content of this
|
||||
workspace through the link.
|
||||
</StyledPublishExplanation>
|
||||
) : (
|
||||
<>
|
||||
<StyledPublishExplanation>
|
||||
The current workspace has been published to the web, everyone can
|
||||
view the contents of this workspace through the link.
|
||||
</StyledPublishExplanation>
|
||||
<StyledSettingH2 marginTop={48}>Share with link</StyledSettingH2>
|
||||
<StyledPublishCopyContainer>
|
||||
<Input width={500} value={shareUrl} disabled={true}></Input>
|
||||
<StyledCopyButtonContainer>
|
||||
<Button onClick={copyUrl} type="primary" shape="circle">
|
||||
Copy Link
|
||||
</Button>
|
||||
</StyledCopyButtonContainer>
|
||||
</StyledPublishCopyContainer>
|
||||
</>
|
||||
)}
|
||||
</StyledPublishContent>
|
||||
<Button type="primary" shape="circle">
|
||||
Publish to web
|
||||
</Button>
|
||||
{!workspace.public ? (
|
||||
<Button
|
||||
onClick={() => {
|
||||
togglePublic(true);
|
||||
}}
|
||||
type="primary"
|
||||
shape="circle"
|
||||
>
|
||||
Publish to web
|
||||
</Button>
|
||||
) : (
|
||||
<Button
|
||||
onClick={() => {
|
||||
togglePublic(false);
|
||||
}}
|
||||
type="primary"
|
||||
shape="circle"
|
||||
>
|
||||
Stop publishing
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
+2
-4
@@ -103,10 +103,8 @@ export const SelectorPopperContent = ({
|
||||
workspaces[id] = workspace;
|
||||
});
|
||||
|
||||
console.log('workspaces', workspaces);
|
||||
|
||||
setWorkspaces(workspaces);
|
||||
}, []);
|
||||
}, [workspacesMeta]);
|
||||
|
||||
useEffect(() => {
|
||||
if (isShow) {
|
||||
@@ -144,7 +142,7 @@ export const SelectorPopperContent = ({
|
||||
workspaces[workspace.id]?.meta.name ||
|
||||
(workspace.type === WorkspaceType.Private
|
||||
? user.name
|
||||
: `workspace-${workspace.id}`)
|
||||
: `loading...`) // workspace-${workspace.id}
|
||||
}
|
||||
memberCount={workSpaceDetails[workspace.id]?.memberCount || 1}
|
||||
/>
|
||||
|
||||
+3
@@ -17,6 +17,7 @@ import {
|
||||
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;
|
||||
@@ -34,6 +35,7 @@ const DefaultHeadImgColors = [
|
||||
export const WorkspaceCreate = ({ open, onClose }: WorkspaceCreateProps) => {
|
||||
const [workspaceName, setWorkspaceId] = useState<string>('');
|
||||
const [canCreate, setCanCreate] = useState<boolean>(false);
|
||||
const { refreshWorkspacesMeta } = useAppState();
|
||||
const handlerInputChange = (workspaceName: string) => {
|
||||
setWorkspaceId(workspaceName);
|
||||
};
|
||||
@@ -74,6 +76,7 @@ export const WorkspaceCreate = ({ open, onClose }: WorkspaceCreateProps) => {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
router.push(`/workspace/${data.created_at}`);
|
||||
refreshWorkspacesMeta();
|
||||
onClose();
|
||||
})
|
||||
.catch(err => {
|
||||
|
||||
Reference in New Issue
Block a user