mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-15 05:37:32 +00:00
fix(editor): improve error message in mention (#11309)
Close [BS-2972](https://linear.app/affine-design/issue/BS-2972/邀请了无权限阅读的用户时,报错信息展示不正确) Close [BS-2973](https://linear.app/affine-design/issue/BS-2973/也没有区分邀请人是否有邀请权限,并如设计稿给出邀请提示)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { notify } from '@affine/component';
|
||||
import { UserFriendlyError } from '@affine/error';
|
||||
import { type DocMode as GraphqlDocMode } from '@affine/graphql';
|
||||
import { type DocMode as GraphqlDocMode, ErrorNames } from '@affine/graphql';
|
||||
import { I18n, i18nTime } from '@affine/i18n';
|
||||
import track from '@affine/track';
|
||||
import {
|
||||
@@ -432,6 +432,45 @@ export class AtMenuConfigService extends Service {
|
||||
})
|
||||
.catch(error => {
|
||||
const err = UserFriendlyError.fromAny(error);
|
||||
|
||||
const canUserManage = this.guardService.can$(
|
||||
'Workspace_Users_Manage'
|
||||
).signal.value;
|
||||
|
||||
if (err.is(ErrorNames.MENTION_USER_DOC_ACCESS_DENIED)) {
|
||||
if (canUserManage) {
|
||||
const username = name ?? 'Unknown';
|
||||
notify.error({
|
||||
title: I18n.t('com.affine.editor.at-menu.access-needed'),
|
||||
message: I18n[
|
||||
'com.affine.editor.at-menu.access-needed-message'
|
||||
]({
|
||||
username,
|
||||
}),
|
||||
action: {
|
||||
label: 'Invite',
|
||||
onClick: () => {
|
||||
this.dialogService.open('setting', {
|
||||
activeTab: 'workspace:members',
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
} else {
|
||||
notify.error({
|
||||
title: I18n.t(
|
||||
'com.affine.editor.at-menu.member-not-notified'
|
||||
),
|
||||
message:
|
||||
I18n[
|
||||
'com.affine.editor.at-menu.member-not-notified-message'
|
||||
](),
|
||||
});
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
notify.error({
|
||||
title: I18n[`error.${err.name}`](err.data),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user