mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-23 21:06:22 +08:00
fix(core): quotaCheck dialog should not appear in team workspace (#9223)

This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import { useConfirmModal } from '@affine/component';
|
import { useConfirmModal } from '@affine/component';
|
||||||
import { GlobalDialogService } from '@affine/core/modules/dialogs';
|
import { GlobalDialogService } from '@affine/core/modules/dialogs';
|
||||||
import { type I18nString, useI18n } from '@affine/i18n';
|
import { type I18nString, useI18n } from '@affine/i18n';
|
||||||
|
import { InformationFillDuotoneIcon } from '@blocksuite/icons/rc';
|
||||||
import { useLiveData, useService } from '@toeverything/infra';
|
import { useLiveData, useService } from '@toeverything/infra';
|
||||||
import { useCallback, useEffect } from 'react';
|
import { useCallback, useEffect } from 'react';
|
||||||
|
|
||||||
@@ -32,7 +33,9 @@ export const QuotaCheck = ({
|
|||||||
const workspaceProfile = workspacesService.getProfile(workspaceMeta);
|
const workspaceProfile = workspacesService.getProfile(workspaceMeta);
|
||||||
const quota = useLiveData(workspaceQuota.quota$);
|
const quota = useLiveData(workspaceQuota.quota$);
|
||||||
const usedPercent = useLiveData(workspaceQuota.percent$);
|
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 globalDialogService = useService(GlobalDialogService);
|
||||||
const t = useI18n();
|
const t = useI18n();
|
||||||
|
|
||||||
@@ -51,7 +54,7 @@ export const QuotaCheck = ({
|
|||||||
}, [workspaceQuota]);
|
}, [workspaceQuota]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (workspaceMeta.flavour === 'local' || !quota) {
|
if (workspaceMeta.flavour === 'local' || !quota || isTeam) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const memberOverflow = quota.memberCount > quota.memberLimit;
|
const memberOverflow = quota.memberCount > quota.memberLimit;
|
||||||
@@ -65,7 +68,7 @@ export const QuotaCheck = ({
|
|||||||
|
|
||||||
if (memberOverflow || storageOverflow) {
|
if (memberOverflow || storageOverflow) {
|
||||||
openConfirmModal({
|
openConfirmModal({
|
||||||
title: t.t(message.title),
|
title: <Title title={t.t(message.title)} />,
|
||||||
description: t.t(message.description),
|
description: t.t(message.description),
|
||||||
confirmText: t.t(message.confirmText),
|
confirmText: t.t(message.confirmText),
|
||||||
cancelText: message.cancelText ? t.t(message.cancelText) : undefined,
|
cancelText: message.cancelText ? t.t(message.cancelText) : undefined,
|
||||||
@@ -87,6 +90,7 @@ export const QuotaCheck = ({
|
|||||||
}
|
}
|
||||||
}, [
|
}, [
|
||||||
isOwner,
|
isOwner,
|
||||||
|
isTeam,
|
||||||
onConfirm,
|
onConfirm,
|
||||||
openConfirmModal,
|
openConfirmModal,
|
||||||
quota,
|
quota,
|
||||||
@@ -103,7 +107,7 @@ const messages: Record<
|
|||||||
> = {
|
> = {
|
||||||
owner: {
|
owner: {
|
||||||
both: {
|
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',
|
description: 'com.affine.payment.sync-paused.owner.both.description',
|
||||||
tips: [
|
tips: [
|
||||||
'com.affine.payment.sync-paused.owner.both.tips-1',
|
'com.affine.payment.sync-paused.owner.both.tips-1',
|
||||||
@@ -113,7 +117,7 @@ const messages: Record<
|
|||||||
confirmText: 'com.affine.payment.upgrade',
|
confirmText: 'com.affine.payment.upgrade',
|
||||||
},
|
},
|
||||||
storage: {
|
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',
|
description: 'com.affine.payment.sync-paused.owner.storage.description',
|
||||||
tips: [
|
tips: [
|
||||||
'com.affine.payment.sync-paused.owner.storage.tips-1',
|
'com.affine.payment.sync-paused.owner.storage.tips-1',
|
||||||
@@ -123,7 +127,7 @@ const messages: Record<
|
|||||||
confirmText: 'com.affine.payment.upgrade',
|
confirmText: 'com.affine.payment.upgrade',
|
||||||
},
|
},
|
||||||
member: {
|
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',
|
description: 'com.affine.payment.sync-paused.owner.member.description',
|
||||||
tips: [
|
tips: [
|
||||||
'com.affine.payment.sync-paused.owner.member.tips-1',
|
'com.affine.payment.sync-paused.owner.member.tips-1',
|
||||||
@@ -135,17 +139,17 @@ const messages: Record<
|
|||||||
},
|
},
|
||||||
member: {
|
member: {
|
||||||
both: {
|
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',
|
description: 'com.affine.payment.sync-paused.member.both.description',
|
||||||
confirmText: 'com.affine.payment.sync-paused.member.member.confirm',
|
confirmText: 'com.affine.payment.sync-paused.member.member.confirm',
|
||||||
},
|
},
|
||||||
storage: {
|
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',
|
description: 'com.affine.payment.sync-paused.member.storage.description',
|
||||||
confirmText: 'com.affine.payment.sync-paused.member.member.confirm',
|
confirmText: 'com.affine.payment.sync-paused.member.member.confirm',
|
||||||
},
|
},
|
||||||
member: {
|
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',
|
description: 'com.affine.payment.sync-paused.member.member.description',
|
||||||
confirmText: 'com.affine.payment.sync-paused.member.member.confirm',
|
confirmText: 'com.affine.payment.sync-paused.member.member.confirm',
|
||||||
},
|
},
|
||||||
@@ -186,3 +190,12 @@ const Tips = ({ tips }: { tips?: I18nString[] }) => {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const Title = ({ title }: { title: string }) => {
|
||||||
|
return (
|
||||||
|
<div className={styles.modalTitle}>
|
||||||
|
<InformationFillDuotoneIcon className={styles.errorIcon} />
|
||||||
|
{title}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|||||||
@@ -25,3 +25,17 @@ export const bullet = style({
|
|||||||
export const modalChildren = style({
|
export const modalChildren = style({
|
||||||
paddingLeft: '0',
|
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',
|
||||||
|
});
|
||||||
|
|||||||
@@ -1601,7 +1601,7 @@
|
|||||||
"com.affine.workspace.storage": "Workspace storage",
|
"com.affine.workspace.storage": "Workspace storage",
|
||||||
"com.affine.cmdk.affine.category.affine.journal": "Journal",
|
"com.affine.cmdk.affine.category.affine.journal": "Journal",
|
||||||
"com.affine.cmdk.affine.category.affine.date-picker": "Select a specific date",
|
"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.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-1": "Reduce storage usage and remove some team members",
|
||||||
"com.affine.payment.sync-paused.owner.both.tips-2": "Upgrade your plan for increased capacity",
|
"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.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-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.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.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.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.",
|
"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.",
|
||||||
|
|||||||
Reference in New Issue
Block a user