feat(core): adjust member tips (#4737)
This commit is contained in:
@@ -10,9 +10,9 @@ import { pushNotificationAtom } from '@affine/component/notification-center';
|
|||||||
import { SettingRow } from '@affine/component/setting-components';
|
import { SettingRow } from '@affine/component/setting-components';
|
||||||
import type { AffineOfficialWorkspace } from '@affine/env/workspace';
|
import type { AffineOfficialWorkspace } from '@affine/env/workspace';
|
||||||
import { WorkspaceFlavour } from '@affine/env/workspace';
|
import { WorkspaceFlavour } from '@affine/env/workspace';
|
||||||
import { Permission } from '@affine/graphql';
|
import { Permission, SubscriptionPlan } from '@affine/graphql';
|
||||||
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
||||||
import { MoreVerticalIcon } from '@blocksuite/icons';
|
import { ArrowRightBigIcon, MoreVerticalIcon } from '@blocksuite/icons';
|
||||||
import { Avatar } from '@toeverything/components/avatar';
|
import { Avatar } from '@toeverything/components/avatar';
|
||||||
import { Button, IconButton } from '@toeverything/components/button';
|
import { Button, IconButton } from '@toeverything/components/button';
|
||||||
import { Loading } from '@toeverything/components/loading';
|
import { Loading } from '@toeverything/components/loading';
|
||||||
@@ -31,16 +31,24 @@ import {
|
|||||||
} from 'react';
|
} from 'react';
|
||||||
import { ErrorBoundary } from 'react-error-boundary';
|
import { ErrorBoundary } from 'react-error-boundary';
|
||||||
|
|
||||||
|
import { openSettingModalAtom } from '../../../atoms';
|
||||||
import type { CheckedUser } from '../../../hooks/affine/use-current-user';
|
import type { CheckedUser } from '../../../hooks/affine/use-current-user';
|
||||||
import { useCurrentUser } from '../../../hooks/affine/use-current-user';
|
import { useCurrentUser } from '../../../hooks/affine/use-current-user';
|
||||||
import { useInviteMember } from '../../../hooks/affine/use-invite-member';
|
import { useInviteMember } from '../../../hooks/affine/use-invite-member';
|
||||||
import { useMemberCount } from '../../../hooks/affine/use-member-count';
|
import { useMemberCount } from '../../../hooks/affine/use-member-count';
|
||||||
import { type Member, useMembers } from '../../../hooks/affine/use-members';
|
import { type Member, useMembers } from '../../../hooks/affine/use-members';
|
||||||
import { useRevokeMemberPermission } from '../../../hooks/affine/use-revoke-member-permission';
|
import { useRevokeMemberPermission } from '../../../hooks/affine/use-revoke-member-permission';
|
||||||
|
import { useUserSubscription } from '../../../hooks/use-subscription';
|
||||||
import { AnyErrorBoundary } from '../any-error-boundary';
|
import { AnyErrorBoundary } from '../any-error-boundary';
|
||||||
import * as style from './style.css';
|
import * as style from './style.css';
|
||||||
import type { WorkspaceSettingDetailProps } from './types';
|
import type { WorkspaceSettingDetailProps } from './types';
|
||||||
|
|
||||||
|
enum MemberLimitCount {
|
||||||
|
Free = '3',
|
||||||
|
Pro = '10',
|
||||||
|
Other = '?',
|
||||||
|
}
|
||||||
|
|
||||||
const COUNT_PER_PAGE = 8;
|
const COUNT_PER_PAGE = 8;
|
||||||
export interface MembersPanelProps extends WorkspaceSettingDetailProps {
|
export interface MembersPanelProps extends WorkspaceSettingDetailProps {
|
||||||
workspace: AffineOfficialWorkspace;
|
workspace: AffineOfficialWorkspace;
|
||||||
@@ -130,11 +138,47 @@ export const CloudWorkspaceMembersPanel = ({
|
|||||||
[pushNotification, revokeMemberPermission, t]
|
[pushNotification, revokeMemberPermission, t]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const setSettingModalAtom = useSetAtom(openSettingModalAtom);
|
||||||
|
const handleUpgrade = useCallback(() => {
|
||||||
|
setSettingModalAtom({
|
||||||
|
open: true,
|
||||||
|
activeTab: 'plans',
|
||||||
|
workspaceId: null,
|
||||||
|
});
|
||||||
|
}, [setSettingModalAtom]);
|
||||||
|
|
||||||
|
const [subscription] = useUserSubscription();
|
||||||
|
const plan = subscription?.plan ?? SubscriptionPlan.Free;
|
||||||
|
const memberLimit = useMemo(() => {
|
||||||
|
if (plan === SubscriptionPlan.Free) {
|
||||||
|
return MemberLimitCount.Free;
|
||||||
|
}
|
||||||
|
if (plan === SubscriptionPlan.Pro) {
|
||||||
|
return MemberLimitCount.Pro;
|
||||||
|
}
|
||||||
|
return MemberLimitCount.Other;
|
||||||
|
}, [plan]);
|
||||||
|
const desc = useMemo(() => {
|
||||||
|
return (
|
||||||
|
<span>
|
||||||
|
{t['com.affine.payment.member.description']({
|
||||||
|
planName: plan,
|
||||||
|
memberLimit,
|
||||||
|
})}
|
||||||
|
,
|
||||||
|
<div className={style.goUpgradeWrapper} onClick={handleUpgrade}>
|
||||||
|
<span className={style.goUpgrade}>go upgrade</span>
|
||||||
|
<ArrowRightBigIcon className={style.arrowRight} />
|
||||||
|
</div>
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}, [handleUpgrade, memberLimit, plan, t]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SettingRow
|
<SettingRow
|
||||||
name={`${t['Members']()} (${memberCount})`}
|
name={`${t['Members']()} (${memberCount})`}
|
||||||
desc={t['Members hint']()}
|
desc={desc}
|
||||||
spreadCol={isOwner}
|
spreadCol={isOwner}
|
||||||
>
|
>
|
||||||
{isOwner ? (
|
{isOwner ? (
|
||||||
|
|||||||
@@ -182,3 +182,22 @@ export const workspaceLabel = style({
|
|||||||
lineHeight: '20px',
|
lineHeight: '20px',
|
||||||
whiteSpace: 'nowrap',
|
whiteSpace: 'nowrap',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const goUpgrade = style({
|
||||||
|
fontSize: 'var(--affine-font-xs)',
|
||||||
|
color: 'var(--affine-text-emphasis-color)',
|
||||||
|
cursor: 'pointer',
|
||||||
|
marginLeft: '4px',
|
||||||
|
display: 'inline',
|
||||||
|
});
|
||||||
|
|
||||||
|
export const goUpgradeWrapper = style({
|
||||||
|
display: 'inline-flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
});
|
||||||
|
|
||||||
|
export const arrowRight = style({
|
||||||
|
fontSize: '16px',
|
||||||
|
color: 'var(--affine-text-emphasis-color)',
|
||||||
|
cursor: 'pointer',
|
||||||
|
});
|
||||||
|
|||||||
@@ -711,5 +711,6 @@
|
|||||||
"com.affine.payment.billing-setting.resume-subscription": "Resume",
|
"com.affine.payment.billing-setting.resume-subscription": "Resume",
|
||||||
"com.affine.payment.billing-setting.no-invoice": "There are no invoices to display.",
|
"com.affine.payment.billing-setting.no-invoice": "There are no invoices to display.",
|
||||||
"com.affine.payment.billing-setting.paid": "Paid",
|
"com.affine.payment.billing-setting.paid": "Paid",
|
||||||
"com.affine.payment.billing-setting.view-invoice": "View Invoice"
|
"com.affine.payment.billing-setting.view-invoice": "View Invoice",
|
||||||
|
"com.affine.payment.member.description": "Manage members here. {{planName}} Users can invite up to {{memberLimit}}"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user