feat: add publish workspace page list and workspace page

This commit is contained in:
DiamondThree
2023-01-11 23:54:25 +08:00
parent d979acbba7
commit 753c59b534
9 changed files with 94 additions and 56 deletions
@@ -31,7 +31,6 @@ export const Editor = ({ page, workspace, setEditor }: Props) => {
const editor = new EditorContainer();
editor.page = page;
editorContainer.current?.appendChild(editor);
if (page.isEmpty) {
const isFirstPage = workspace?.meta.pageMetas.length === 1;
+26 -16
View File
@@ -67,10 +67,12 @@ export const PageList = ({
pageList,
showFavoriteTag = false,
isTrash = false,
isPublic = false,
}: {
pageList: PageMeta[];
showFavoriteTag?: boolean;
isTrash?: boolean;
isPublic?: boolean;
}) => {
const router = useRouter();
const { currentWorkspace } = useAppState();
@@ -98,9 +100,15 @@ export const PageList = ({
<StyledTableRow
key={`${pageMeta.id}-${index}`}
onClick={() => {
router.push(
`/workspace/${currentWorkspace?.id}/${pageMeta.id}`
);
if (isPublic) {
router.push(
`/public-workspace/${router.query.workspaceId}/${pageMeta.id}`
);
} else {
router.push(
`/workspace/${currentWorkspace?.id}/${pageMeta.id}`
);
}
}}
>
<TableCell>
@@ -124,19 +132,21 @@ export const PageList = ({
dateKey={isTrash ? 'trashDate' : 'updatedDate'}
backupKey={isTrash ? 'trashDate' : 'createDate'}
/>
<TableCell
style={{ padding: 0 }}
data-testid={`more-actions-${pageMeta.id}`}
onClick={e => {
e.stopPropagation();
}}
>
{isTrash ? (
<TrashOperationCell pageMeta={pageMeta} />
) : (
<OperationCell pageMeta={pageMeta} />
)}
</TableCell>
{!isPublic ? (
<TableCell
style={{ padding: 0 }}
data-testid={`more-actions-${pageMeta.id}`}
onClick={e => {
e.stopPropagation();
}}
>
{isTrash ? (
<TrashOperationCell pageMeta={pageMeta} />
) : (
<OperationCell pageMeta={pageMeta} />
)}
</TableCell>
) : null}
</StyledTableRow>
);
})}
@@ -14,8 +14,7 @@ import { WorkspaceUnit } from '@affine/datacenter';
import { useWorkspaceHelper } from '@/hooks/use-workspace-helper';
export const PublishPage = ({ workspace }: { workspace: WorkspaceUnit }) => {
const shareUrl =
window.location.host + '/workspace/' + workspace.id + '?share=true';
const shareUrl = window.location.host + '/public-workspace/' + workspace.id;
const { publishWorkspace, enableWorkspace } = useWorkspaceHelper();
const togglePublic = async (flag: boolean) => {
@@ -1,6 +1,5 @@
import { styled } from '@/styles';
import MuiAvatar from '@mui/material/Avatar';
import { Button } from '@/ui/button';
export const StyledMemberTitleContainer = styled('div')(() => {
return {
@@ -1,6 +1,4 @@
import { styled } from '@/styles';
import { Button } from '@/ui/button';
import MuiAvatar from '@mui/material/Avatar';
export const StyledSettingContainer = styled('div')(() => {
return {