Fix: invite (#1064)
This commit is contained in:
@@ -19,22 +19,22 @@ const WorkspaceType = ({ workspaceData }: { workspaceData: WorkspaceUnit }) => {
|
|||||||
|
|
||||||
if (workspaceData.provider === 'local') {
|
if (workspaceData.provider === 'local') {
|
||||||
return (
|
return (
|
||||||
<p>
|
<p title={t('Local Workspace')}>
|
||||||
<LocalWorkspaceIcon />
|
<LocalWorkspaceIcon />
|
||||||
{t('Local Workspace')}
|
<span>{t('Local Workspace')}</span>
|
||||||
</p>
|
</p>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return isOwner ? (
|
return isOwner ? (
|
||||||
<p>
|
<p title={t('Cloud Workspace')}>
|
||||||
<CloudWorkspaceIcon />
|
<CloudWorkspaceIcon />
|
||||||
{t('Cloud Workspace')}
|
<span>{t('Cloud Workspace')}</span>
|
||||||
</p>
|
</p>
|
||||||
) : (
|
) : (
|
||||||
<p>
|
<p title={t('Joined Workspace')}>
|
||||||
<JoinedWorkspaceIcon />
|
<JoinedWorkspaceIcon />
|
||||||
{t('Joined Workspace')}
|
<span>{t('Joined Workspace')}</span>
|
||||||
</p>
|
</p>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -66,15 +66,15 @@ export const WorkspaceCard = ({
|
|||||||
</StyleWorkspaceTitle>
|
</StyleWorkspaceTitle>
|
||||||
<WorkspaceType workspaceData={workspaceData} />
|
<WorkspaceType workspaceData={workspaceData} />
|
||||||
{workspaceData.provider === 'local' && (
|
{workspaceData.provider === 'local' && (
|
||||||
<p>
|
<p title={t('Available Offline')}>
|
||||||
<LocalDataIcon />
|
<LocalDataIcon />
|
||||||
{t('Available Offline')}
|
<span>{t('Available Offline')}</span>
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
{workspaceData.published && (
|
{workspaceData.published && (
|
||||||
<p>
|
<p title={t('Published to Web')}>
|
||||||
<PublishIcon />
|
<PublishIcon />
|
||||||
{t('Published to Web')}
|
<span>{t('Published to Web')}</span>
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
</StyleWorkspaceInfo>
|
</StyleWorkspaceInfo>
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ export const StyledSplitLine = styled.div(({ theme }) => {
|
|||||||
export const StyleWorkspaceInfo = styled.div(({ theme }) => {
|
export const StyleWorkspaceInfo = styled.div(({ theme }) => {
|
||||||
return {
|
return {
|
||||||
marginLeft: '15px',
|
marginLeft: '15px',
|
||||||
|
width: '202px',
|
||||||
p: {
|
p: {
|
||||||
color: theme.colors.popoverColor,
|
color: theme.colors.popoverColor,
|
||||||
height: '20px',
|
height: '20px',
|
||||||
@@ -27,6 +28,11 @@ export const StyleWorkspaceInfo = styled.div(({ theme }) => {
|
|||||||
svg: {
|
svg: {
|
||||||
marginRight: '10px',
|
marginRight: '10px',
|
||||||
fontSize: '16px',
|
fontSize: '16px',
|
||||||
|
flexShrink: 0,
|
||||||
|
},
|
||||||
|
span: {
|
||||||
|
flexGrow: 1,
|
||||||
|
...textEllipsis(1),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import {
|
|||||||
StyledEditButton,
|
StyledEditButton,
|
||||||
} from './style';
|
} from './style';
|
||||||
import { StyledSettingKey, StyledRow } from '../style';
|
import { StyledSettingKey, StyledRow } from '../style';
|
||||||
import { FlexWrapper } from '@affine/component';
|
import { FlexWrapper, MuiAvatar } from '@affine/component';
|
||||||
|
|
||||||
import { useCallback, useState } from 'react';
|
import { useCallback, useState } from 'react';
|
||||||
import { Button } from '@affine/component';
|
import { Button } from '@affine/component';
|
||||||
@@ -24,6 +24,7 @@ import { CameraIcon } from './icons';
|
|||||||
import { Upload } from '@/components/file-upload';
|
import { Upload } from '@/components/file-upload';
|
||||||
import { MuiFade } from '@affine/component';
|
import { MuiFade } from '@affine/component';
|
||||||
import { useGlobalState } from '@/store/app';
|
import { useGlobalState } from '@/store/app';
|
||||||
|
import { EmailIcon } from '@blocksuite/icons';
|
||||||
export const GeneralPage = ({ workspace }: { workspace: WorkspaceUnit }) => {
|
export const GeneralPage = ({ workspace }: { workspace: WorkspaceUnit }) => {
|
||||||
const [showDelete, setShowDelete] = useState<boolean>(false);
|
const [showDelete, setShowDelete] = useState<boolean>(false);
|
||||||
const [showLeave, setShowLeave] = useState<boolean>(false);
|
const [showLeave, setShowLeave] = useState<boolean>(false);
|
||||||
@@ -143,6 +144,30 @@ export const GeneralPage = ({ workspace }: { workspace: WorkspaceUnit }) => {
|
|||||||
</div>
|
</div>
|
||||||
</StyledRow>
|
</StyledRow>
|
||||||
|
|
||||||
|
{!isOwner && (
|
||||||
|
<StyledRow>
|
||||||
|
<StyledSettingKey>{t('Workspace Owner')}</StyledSettingKey>
|
||||||
|
<FlexWrapper alignItems="center">
|
||||||
|
<MuiAvatar
|
||||||
|
sx={{ width: 72, height: 72, marginRight: '12px' }}
|
||||||
|
alt="owner avatar"
|
||||||
|
src={currentWorkspace?.owner?.avatar}
|
||||||
|
>
|
||||||
|
<EmailIcon />
|
||||||
|
</MuiAvatar>
|
||||||
|
<span>{currentWorkspace?.owner?.name}</span>
|
||||||
|
</FlexWrapper>
|
||||||
|
</StyledRow>
|
||||||
|
)}
|
||||||
|
{!isOwner && (
|
||||||
|
<StyledRow>
|
||||||
|
<StyledSettingKey>{t('Members')}</StyledSettingKey>
|
||||||
|
<FlexWrapper alignItems="center">
|
||||||
|
<span>{currentWorkspace?.memberCount}</span>
|
||||||
|
</FlexWrapper>
|
||||||
|
</StyledRow>
|
||||||
|
)}
|
||||||
|
|
||||||
<StyledRow>
|
<StyledRow>
|
||||||
<StyledSettingKey>{t('Workspace Type')}</StyledSettingKey>
|
<StyledSettingKey>{t('Workspace Type')}</StyledSettingKey>
|
||||||
{isOwner ? (
|
{isOwner ? (
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ export const WorkspaceSettingTagItem = styled('li')<{ isActive?: boolean }>(
|
|||||||
export const StyledSettingKey = styled.div(({ theme }) => {
|
export const StyledSettingKey = styled.div(({ theme }) => {
|
||||||
return {
|
return {
|
||||||
width: '140px',
|
width: '140px',
|
||||||
textAlign: 'right',
|
|
||||||
fontSize: theme.font.base,
|
fontSize: theme.font.base,
|
||||||
fontWeight: 500,
|
fontWeight: 500,
|
||||||
marginRight: '56px',
|
marginRight: '56px',
|
||||||
|
|||||||
@@ -1,12 +1,18 @@
|
|||||||
import { MuiAvatar, textEllipsis } from '@affine/component';
|
import { MuiAvatar, textEllipsis } from '@affine/component';
|
||||||
import { styled } from '@affine/component';
|
import { styled } from '@affine/component';
|
||||||
export const SelectorWrapper = styled('div')({
|
export const SelectorWrapper = styled('div')(({ theme }) => {
|
||||||
height: '100%',
|
return {
|
||||||
display: 'flex',
|
height: '42px',
|
||||||
alignItems: 'center',
|
display: 'flex',
|
||||||
':hover': {
|
alignItems: 'center',
|
||||||
cursor: 'pointer',
|
padding: '0 12px',
|
||||||
},
|
borderRadius: '5px',
|
||||||
|
color: theme.colors.textColor,
|
||||||
|
':hover': {
|
||||||
|
cursor: 'pointer',
|
||||||
|
background: theme.colors.hoverBackground,
|
||||||
|
},
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
export const Avatar = styled(MuiAvatar)({
|
export const Avatar = styled(MuiAvatar)({
|
||||||
@@ -19,7 +25,6 @@ export const WorkspaceName = styled('span')(({ theme }) => {
|
|||||||
marginLeft: '12px',
|
marginLeft: '12px',
|
||||||
fontSize: theme.font.h6,
|
fontSize: theme.font.h6,
|
||||||
fontWeight: 500,
|
fontWeight: 500,
|
||||||
color: theme.colors.iconColor,
|
|
||||||
marginTop: '4px',
|
marginTop: '4px',
|
||||||
flexGrow: 1,
|
flexGrow: 1,
|
||||||
...textEllipsis(1),
|
...textEllipsis(1),
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import {
|
|||||||
StyledArrowButton,
|
StyledArrowButton,
|
||||||
StyledLink,
|
StyledLink,
|
||||||
StyledListItem,
|
StyledListItem,
|
||||||
StyledListItemForWorkspace,
|
|
||||||
StyledNewPageButton,
|
StyledNewPageButton,
|
||||||
StyledSliderBar,
|
StyledSliderBar,
|
||||||
StyledSliderBarWrapper,
|
StyledSliderBarWrapper,
|
||||||
@@ -112,9 +111,8 @@ export const WorkSpaceSliderBar = () => {
|
|||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
|
||||||
<StyledSliderBarWrapper data-testid="sliderBar">
|
<StyledSliderBarWrapper data-testid="sliderBar">
|
||||||
<StyledListItemForWorkspace>
|
<WorkspaceSelector />
|
||||||
<WorkspaceSelector />
|
|
||||||
</StyledListItemForWorkspace>
|
|
||||||
<StyledListItem
|
<StyledListItem
|
||||||
data-testid="sliderBar-quickSearchButton"
|
data-testid="sliderBar-quickSearchButton"
|
||||||
style={{ cursor: 'pointer' }}
|
style={{ cursor: 'pointer' }}
|
||||||
|
|||||||
@@ -82,11 +82,6 @@ export const StyledListItem = styled.div<{
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
export const StyledListItemForWorkspace = styled.div({
|
|
||||||
height: '42px',
|
|
||||||
padding: '0 12px',
|
|
||||||
});
|
|
||||||
|
|
||||||
export const StyledLink = styled(Link)(() => {
|
export const StyledLink = styled(Link)(() => {
|
||||||
return {
|
return {
|
||||||
flexGrow: 1,
|
flexGrow: 1,
|
||||||
|
|||||||
@@ -31,10 +31,12 @@ const useTabMap = () => {
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const isOwner = useGlobalState(store => store.isOwner);
|
const isOwner = useGlobalState(store => store.isOwner);
|
||||||
const tabMap: {
|
const tabMap: {
|
||||||
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
panelRender: (workspace: WorkspaceUnit) => ReactNode;
|
panelRender: (workspace: WorkspaceUnit) => ReactNode;
|
||||||
}[] = [
|
}[] = [
|
||||||
{
|
{
|
||||||
|
id: 'General',
|
||||||
name: t('General'),
|
name: t('General'),
|
||||||
panelRender: workspace => <GeneralPage workspace={workspace} />,
|
panelRender: workspace => <GeneralPage workspace={workspace} />,
|
||||||
},
|
},
|
||||||
@@ -44,40 +46,37 @@ const useTabMap = () => {
|
|||||||
// panelRender: workspace => <SyncPage workspace={workspace} />,
|
// panelRender: workspace => <SyncPage workspace={workspace} />,
|
||||||
// },
|
// },
|
||||||
{
|
{
|
||||||
|
id: 'Collaboration',
|
||||||
name: t('Collaboration'),
|
name: t('Collaboration'),
|
||||||
panelRender: workspace => <MembersPage workspace={workspace} />,
|
panelRender: workspace => <MembersPage workspace={workspace} />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
id: 'Publish',
|
||||||
name: t('Publish'),
|
name: t('Publish'),
|
||||||
panelRender: workspace => <PublishPage workspace={workspace} />,
|
panelRender: workspace => <PublishPage workspace={workspace} />,
|
||||||
},
|
},
|
||||||
// TODO: next version will finish this feature
|
// TODO: next version will finish this feature
|
||||||
{
|
{
|
||||||
|
id: 'Export',
|
||||||
name: t('Export'),
|
name: t('Export'),
|
||||||
panelRender: workspace => <ExportPage workspace={workspace} />,
|
panelRender: workspace => <ExportPage workspace={workspace} />,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
const [activeTab, setActiveTab] = useState<string>(tabMap[0].name);
|
const [activeTab, setActiveTab] = useState<string>(tabMap[0].id);
|
||||||
const handleTabChange = (tab: string) => {
|
const handleTabChange = (tabId: string) => {
|
||||||
setActiveTab(tab);
|
setActiveTab(tabId);
|
||||||
};
|
};
|
||||||
|
|
||||||
const activeTabPanelRender = tabMap.find(
|
const activeTabPanelRender = tabMap.find(
|
||||||
tab => tab.name === activeTab
|
tab => tab.id === activeTab
|
||||||
)?.panelRender;
|
)?.panelRender;
|
||||||
let tableArr: {
|
|
||||||
name: string;
|
return {
|
||||||
panelRender: (workspace: WorkspaceUnit) => ReactNode;
|
activeTabPanelRender,
|
||||||
}[] = tabMap;
|
tabMap: isOwner ? tabMap : tabMap.slice(0, 1),
|
||||||
if (!isOwner) {
|
handleTabChange,
|
||||||
tableArr = [
|
activeTab,
|
||||||
{
|
};
|
||||||
name: 'General',
|
|
||||||
panelRender: workspace => <GeneralPage workspace={workspace} />,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
|
||||||
return { activeTabPanelRender, tableArr, handleTabChange, activeTab };
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const StyledIndicator = styled.div(({ theme }) => {
|
const StyledIndicator = styled.div(({ theme }) => {
|
||||||
@@ -101,8 +100,9 @@ const WorkspaceSetting = () => {
|
|||||||
const currentWorkspace = useGlobalState(
|
const currentWorkspace = useGlobalState(
|
||||||
useCallback(store => store.currentDataCenterWorkspace, [])
|
useCallback(store => store.currentDataCenterWorkspace, [])
|
||||||
);
|
);
|
||||||
const { activeTabPanelRender, tableArr, handleTabChange, activeTab } =
|
const { activeTabPanelRender, tabMap, handleTabChange, activeTab } =
|
||||||
useTabMap();
|
useTabMap();
|
||||||
|
|
||||||
const [indicatorState, setIndicatorState] = useState<
|
const [indicatorState, setIndicatorState] = useState<
|
||||||
Pick<CSSProperties, 'left' | 'width'>
|
Pick<CSSProperties, 'left' | 'width'>
|
||||||
>({
|
>({
|
||||||
@@ -133,14 +133,14 @@ const WorkspaceSetting = () => {
|
|||||||
|
|
||||||
<StyledSettingContainer>
|
<StyledSettingContainer>
|
||||||
<StyledTabButtonWrapper>
|
<StyledTabButtonWrapper>
|
||||||
{tableArr.map(({ name }) => {
|
{tabMap.map(({ id, name }) => {
|
||||||
return (
|
return (
|
||||||
<WorkspaceSettingTagItem
|
<WorkspaceSettingTagItem
|
||||||
key={name}
|
key={id}
|
||||||
isActive={activeTab === name}
|
isActive={activeTab === id}
|
||||||
data-setting-tab-button={name}
|
data-setting-tab-button={id}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
handleTabChange(name);
|
handleTabChange(id);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{name}
|
{name}
|
||||||
|
|||||||
@@ -55,9 +55,8 @@ export const createDataCenterActions: GlobalActionsCreator<
|
|||||||
// isOwner is useful only in the cloud
|
// isOwner is useful only in the cloud
|
||||||
isOwner = true;
|
isOwner = true;
|
||||||
} else {
|
} else {
|
||||||
const userInfo = get().user;
|
const userInfo = get().user; // We must ensure workspace.owner exists, then ensure id same.
|
||||||
// We must ensure workspace.owner exists, then ensure id same.
|
isOwner = isOwner = userInfo?.id === workspace?.owner?.id;
|
||||||
isOwner = workspace?.owner && userInfo?.id === workspace.owner.id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const pageList =
|
const pageList =
|
||||||
|
|||||||
@@ -23,15 +23,25 @@ export const createUserActions: GlobalActionsCreator<UserActions> = (
|
|||||||
) => {
|
) => {
|
||||||
return {
|
return {
|
||||||
login: async () => {
|
login: async () => {
|
||||||
const { dataCenter } = get();
|
const { dataCenter, currentDataCenterWorkspace: workspace } = get();
|
||||||
try {
|
try {
|
||||||
await dataCenter.login();
|
await dataCenter.login();
|
||||||
const user = (await dataCenter.getUserInfo()) as User;
|
const user = (await dataCenter.getUserInfo()) as User;
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
// Add ErrorBoundary
|
// Add ErrorBoundary
|
||||||
throw new Error('User info not found');
|
throw new Error('User info not found');
|
||||||
}
|
}
|
||||||
set({ user });
|
|
||||||
|
let isOwner;
|
||||||
|
if (workspace?.provider === 'local') {
|
||||||
|
// isOwner is useful only in the cloud
|
||||||
|
isOwner = true;
|
||||||
|
} else {
|
||||||
|
isOwner = user?.id === workspace?.owner?.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
set({ user, isOwner });
|
||||||
return user;
|
return user;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return null; // login failed
|
return null; // login failed
|
||||||
|
|||||||
@@ -190,5 +190,7 @@
|
|||||||
"Edit": "Edit",
|
"Edit": "Edit",
|
||||||
"Sign out description": "Signing out will cause the unsynchronised content to be lost.",
|
"Sign out description": "Signing out will cause the unsynchronised content to be lost.",
|
||||||
"Help and Feedback": "Help and Feedback",
|
"Help and Feedback": "Help and Feedback",
|
||||||
"Please make sure you are online": "Please make sure you are online"
|
"Please make sure you are online": "Please make sure you are online",
|
||||||
|
"Workspace Owner": "Workspace Owner",
|
||||||
|
"Members": "Members"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user