fix(core): quotaCheck dialog should not appear in team workspace (#9223)

![CleanShot 2024-12-20 at 16 37 17@2x](https://github.com/user-attachments/assets/3bd1107f-cbc8-4415-85ba-e30cf6712f5e)
This commit is contained in:
JimmFly
2024-12-23 08:52:03 +00:00
parent 02aeb89398
commit c793f2307b
3 changed files with 37 additions and 11 deletions

View File

@@ -1,6 +1,7 @@
import { useConfirmModal } from '@affine/component';
import { GlobalDialogService } from '@affine/core/modules/dialogs';
import { type I18nString, useI18n } from '@affine/i18n';
import { InformationFillDuotoneIcon } from '@blocksuite/icons/rc';
import { useLiveData, useService } from '@toeverything/infra';
import { useCallback, useEffect } from 'react';
@@ -32,7 +33,9 @@ export const QuotaCheck = ({
const workspaceProfile = workspacesService.getProfile(workspaceMeta);
const quota = useLiveData(workspaceQuota.quota$);
const usedPercent = useLiveData(workspaceQuota.percent$);
const isOwner = useLiveData(workspaceProfile.profile$)?.isOwner;
const profile = useLiveData(workspaceProfile.profile$);
const isOwner = profile?.isOwner;
const isTeam = profile?.isTeam;
const globalDialogService = useService(GlobalDialogService);
const t = useI18n();
@@ -51,7 +54,7 @@ export const QuotaCheck = ({
}, [workspaceQuota]);
useEffect(() => {
if (workspaceMeta.flavour === 'local' || !quota) {
if (workspaceMeta.flavour === 'local' || !quota || isTeam) {
return;
}
const memberOverflow = quota.memberCount > quota.memberLimit;
@@ -65,7 +68,7 @@ export const QuotaCheck = ({
if (memberOverflow || storageOverflow) {
openConfirmModal({
title: t.t(message.title),
title: <Title title={t.t(message.title)} />,
description: t.t(message.description),
confirmText: t.t(message.confirmText),
cancelText: message.cancelText ? t.t(message.cancelText) : undefined,
@@ -87,6 +90,7 @@ export const QuotaCheck = ({
}
}, [
isOwner,
isTeam,
onConfirm,
openConfirmModal,
quota,
@@ -103,7 +107,7 @@ const messages: Record<
> = {
owner: {
both: {
title: 'com.affine.payment.sync-paused.owner.title',
title: 'com.affine.payment.sync-paused.title',
description: 'com.affine.payment.sync-paused.owner.both.description',
tips: [
'com.affine.payment.sync-paused.owner.both.tips-1',
@@ -113,7 +117,7 @@ const messages: Record<
confirmText: 'com.affine.payment.upgrade',
},
storage: {
title: 'com.affine.payment.sync-paused.owner.title',
title: 'com.affine.payment.sync-paused.title',
description: 'com.affine.payment.sync-paused.owner.storage.description',
tips: [
'com.affine.payment.sync-paused.owner.storage.tips-1',
@@ -123,7 +127,7 @@ const messages: Record<
confirmText: 'com.affine.payment.upgrade',
},
member: {
title: 'com.affine.payment.sync-paused.owner.title',
title: 'com.affine.payment.sync-paused.title',
description: 'com.affine.payment.sync-paused.owner.member.description',
tips: [
'com.affine.payment.sync-paused.owner.member.tips-1',
@@ -135,17 +139,17 @@ const messages: Record<
},
member: {
both: {
title: 'com.affine.payment.sync-paused.member.title',
title: 'com.affine.payment.sync-paused.title',
description: 'com.affine.payment.sync-paused.member.both.description',
confirmText: 'com.affine.payment.sync-paused.member.member.confirm',
},
storage: {
title: 'com.affine.payment.sync-paused.member.title',
title: 'com.affine.payment.sync-paused.title',
description: 'com.affine.payment.sync-paused.member.storage.description',
confirmText: 'com.affine.payment.sync-paused.member.member.confirm',
},
member: {
title: 'com.affine.payment.sync-paused.member.title',
title: 'com.affine.payment.sync-paused.title',
description: 'com.affine.payment.sync-paused.member.member.description',
confirmText: 'com.affine.payment.sync-paused.member.member.confirm',
},
@@ -186,3 +190,12 @@ const Tips = ({ tips }: { tips?: I18nString[] }) => {
</div>
);
};
const Title = ({ title }: { title: string }) => {
return (
<div className={styles.modalTitle}>
<InformationFillDuotoneIcon className={styles.errorIcon} />
{title}
</div>
);
};

View File

@@ -25,3 +25,17 @@ export const bullet = style({
export const modalChildren = style({
paddingLeft: '0',
});
export const modalTitle = style({
display: 'flex',
alignItems: 'center',
gap: '8px',
flexWrap: 'nowrap',
overflow: 'hidden',
textOverflow: 'ellipsis',
});
export const errorIcon = style({
color: cssVarV2('status/error'),
fontSize: '24px',
});

View File

@@ -1601,7 +1601,7 @@
"com.affine.workspace.storage": "Workspace storage",
"com.affine.cmdk.affine.category.affine.journal": "Journal",
"com.affine.cmdk.affine.category.affine.date-picker": "Select a specific date",
"com.affine.payment.sync-paused.owner.title": "[Action Required] Workspace sync paused",
"com.affine.payment.sync-paused.title": "Workspace sync paused",
"com.affine.payment.sync-paused.owner.both.description": "Your workspace has exceeded both storage and member limits, causing synchronization to pause. To resume syncing, please either:",
"com.affine.payment.sync-paused.owner.both.tips-1": "Reduce storage usage and remove some team members",
"com.affine.payment.sync-paused.owner.both.tips-2": "Upgrade your plan for increased capacity",
@@ -1611,7 +1611,6 @@
"com.affine.payment.sync-paused.owner.member.description": "Your workspace has reached its maximum member capacity and synchronization has been paused. To resume syncing, you can either",
"com.affine.payment.sync-paused.owner.member.tips-1": "Remove some team members from the workspace",
"com.affine.payment.sync-paused.owner.member.tips-2": "Upgrade your plan to accommodate more members",
"com.affine.payment.sync-paused.member.title": "Workspace sync paused",
"com.affine.payment.sync-paused.member.both.description": "This workspace has exceeded both storage and member limits, causing synchronization to pause. Please contact your workspace owner to address these limits and resume syncing.",
"com.affine.payment.sync-paused.member.storage.description": "This workspace has exceeded its storage limit and synchronization has been paused. Please contact your workspace owner to either reduce storage usage or upgrade the plan to resume syncing.",
"com.affine.payment.sync-paused.member.member.description": "This workspace has reached its maximum member capacity and synchronization has been paused. Please contact your workspace owner to either adjust team membership or upgrade the plan to resume syncing.",