mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-03 18:40:00 +08:00
feat: add setting entry of setting workspace
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import Modal from '@/ui/modal';
|
import Modal, { ModalCloseButton } from '@/ui/modal';
|
||||||
import {
|
import {
|
||||||
StyledAvatarUploadBtn,
|
StyledAvatarUploadBtn,
|
||||||
StyledCopyButtonContainer,
|
StyledCopyButtonContainer,
|
||||||
@@ -35,7 +35,7 @@ import {
|
|||||||
PublishIcon,
|
PublishIcon,
|
||||||
MoreVerticalIcon,
|
MoreVerticalIcon,
|
||||||
} from '@blocksuite/icons';
|
} from '@blocksuite/icons';
|
||||||
import { useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { Button } from '@/ui/button';
|
import { Button } from '@/ui/button';
|
||||||
import Input from '@/ui/input';
|
import Input from '@/ui/input';
|
||||||
|
|
||||||
@@ -50,6 +50,11 @@ type SettingTabProps = {
|
|||||||
onTabChange?: (tab: ActiveTab) => void;
|
onTabChange?: (tab: ActiveTab) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type WorkspaceSettingProps = {
|
||||||
|
isShow: boolean;
|
||||||
|
onClose?: () => void;
|
||||||
|
};
|
||||||
|
|
||||||
const WorkspaceSettingTab = ({ activeTab, onTabChange }: SettingTabProps) => {
|
const WorkspaceSettingTab = ({ activeTab, onTabChange }: SettingTabProps) => {
|
||||||
return (
|
return (
|
||||||
<StyledSettingTabContainer>
|
<StyledSettingTabContainer>
|
||||||
@@ -90,14 +95,27 @@ const WorkspaceSettingTab = ({ activeTab, onTabChange }: SettingTabProps) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const WorkspaceSetting = () => {
|
export const WorkspaceSetting = ({
|
||||||
|
isShow,
|
||||||
|
onClose,
|
||||||
|
}: WorkspaceSettingProps) => {
|
||||||
const [activeTab, setActiveTab] = useState<ActiveTab>(ActiveTab.general);
|
const [activeTab, setActiveTab] = useState<ActiveTab>(ActiveTab.general);
|
||||||
const handleTabChange = (tab: ActiveTab) => {
|
const handleTabChange = (tab: ActiveTab) => {
|
||||||
setActiveTab(tab);
|
setActiveTab(tab);
|
||||||
};
|
};
|
||||||
|
const handleClickClose = () => {
|
||||||
|
onClose && onClose();
|
||||||
|
};
|
||||||
|
useEffect(() => {
|
||||||
|
// reset tab when modal is closed
|
||||||
|
if (!isShow) {
|
||||||
|
setActiveTab(ActiveTab.general);
|
||||||
|
}
|
||||||
|
}, [isShow]);
|
||||||
return (
|
return (
|
||||||
<Modal open={true}>
|
<Modal open={isShow}>
|
||||||
<StyledSettingContainer>
|
<StyledSettingContainer>
|
||||||
|
<ModalCloseButton onClick={handleClickClose} />
|
||||||
<StyledSettingSidebar>
|
<StyledSettingSidebar>
|
||||||
<StyledSettingSidebarHeader>
|
<StyledSettingSidebarHeader>
|
||||||
Workspace Settings
|
Workspace Settings
|
||||||
|
|||||||
+16
-1
@@ -10,9 +10,20 @@ import {
|
|||||||
ListItem,
|
ListItem,
|
||||||
LoginItem,
|
LoginItem,
|
||||||
} from './WorkspaceItem';
|
} from './WorkspaceItem';
|
||||||
|
import { WorkspaceSetting } from '@/components/workspace-setting';
|
||||||
|
import { useState } from 'react';
|
||||||
|
|
||||||
export const SelectorPopperContent = () => {
|
export const SelectorPopperContent = () => {
|
||||||
const { user, workspacesMeta } = useAppState();
|
const { user, workspacesMeta } = useAppState();
|
||||||
|
const [settingWorkspaceId, setSettingWorkspaceId] = useState<string | null>(
|
||||||
|
null
|
||||||
|
);
|
||||||
|
const handleClickSettingWorkspace = (workspaceId: string) => {
|
||||||
|
setSettingWorkspaceId(workspaceId);
|
||||||
|
};
|
||||||
|
const handleCloseWorkSpace = () => {
|
||||||
|
setSettingWorkspaceId(null);
|
||||||
|
};
|
||||||
return !user ? (
|
return !user ? (
|
||||||
<SelectorPopperContainer placement="bottom-start">
|
<SelectorPopperContainer placement="bottom-start">
|
||||||
<LoginItem />
|
<LoginItem />
|
||||||
@@ -36,12 +47,16 @@ export const SelectorPopperContent = () => {
|
|||||||
id={workspace.id}
|
id={workspace.id}
|
||||||
name={`workspace-${workspace.id}`}
|
name={`workspace-${workspace.id}`}
|
||||||
icon={''}
|
icon={''}
|
||||||
|
onClick={handleClickSettingWorkspace}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</WorkspaceWrapper>
|
</WorkspaceWrapper>
|
||||||
|
|
||||||
<CreateWorkspaceItem />
|
<CreateWorkspaceItem />
|
||||||
|
<WorkspaceSetting
|
||||||
|
isShow={Boolean(settingWorkspaceId)}
|
||||||
|
onClose={handleCloseWorkSpace}
|
||||||
|
/>
|
||||||
<StyledDivider />
|
<StyledDivider />
|
||||||
<ListItem
|
<ListItem
|
||||||
icon={<InformationIcon />}
|
icon={<InformationIcon />}
|
||||||
|
|||||||
+9
-2
@@ -2,9 +2,16 @@ import { SettingsIcon } from '@blocksuite/icons';
|
|||||||
import { styled } from '@/styles';
|
import { styled } from '@/styles';
|
||||||
import { IconButton } from '@/ui/button';
|
import { IconButton } from '@/ui/button';
|
||||||
|
|
||||||
export const FooterSetting = () => {
|
type SettingProps = {
|
||||||
|
onClick?: () => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const FooterSetting = ({ onClick }: SettingProps) => {
|
||||||
|
const handleClick = () => {
|
||||||
|
onClick && onClick();
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<Wrapper className="footer-setting">
|
<Wrapper className="footer-setting" onClick={handleClick}>
|
||||||
<SettingsIcon />
|
<SettingsIcon />
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
);
|
);
|
||||||
|
|||||||
+12
-2
@@ -12,11 +12,21 @@ interface WorkspaceItemProps {
|
|||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
icon: string;
|
icon: string;
|
||||||
|
onClick?: (workspaceId: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const WorkspaceItem = ({ id, name, icon }: WorkspaceItemProps) => {
|
export const WorkspaceItem = ({
|
||||||
|
id,
|
||||||
|
name,
|
||||||
|
icon,
|
||||||
|
onClick,
|
||||||
|
}: WorkspaceItemProps) => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
|
const handleClickSetting = async () => {
|
||||||
|
onClick && onClick(id);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledWrapper
|
<StyledWrapper
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@@ -31,7 +41,7 @@ export const WorkspaceItem = ({ id, name, icon }: WorkspaceItemProps) => {
|
|||||||
</WorkspaceItemContent>
|
</WorkspaceItemContent>
|
||||||
<Footer>
|
<Footer>
|
||||||
<FooterUsers />
|
<FooterUsers />
|
||||||
<FooterSetting />
|
<FooterSetting onClick={handleClickSetting} />
|
||||||
</Footer>
|
</Footer>
|
||||||
</StyledWrapper>
|
</StyledWrapper>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user