fix(core): workspace sharing settings should not be displayed when there is no permission (#8285)

close AF-1222
This commit is contained in:
JimmFly 2024-09-18 07:36:05 +00:00
parent fab23d226d
commit af5b9a3a23
No known key found for this signature in database
GPG Key ID: 126E0320FEB0D05C
2 changed files with 8 additions and 4 deletions

View File

@ -4,6 +4,7 @@ import {
SettingWrapper,
} from '@affine/component/setting-components';
import { useAsyncCallback } from '@affine/core/components/hooks/affine-async-hooks';
import { WorkspacePermissionService } from '@affine/core/modules/permissions';
import { WorkspaceShareSettingService } from '@affine/core/modules/share-setting';
import { WorkspaceFlavour } from '@affine/env/workspace';
import { useI18n } from '@affine/i18n';
@ -22,6 +23,8 @@ export const Sharing = () => {
const shareSetting = useService(WorkspaceShareSettingService).sharePreview;
const enableUrlPreview = useLiveData(shareSetting.enableUrlPreview$);
const loading = useLiveData(shareSetting.isLoading$);
const permissionService = useService(WorkspacePermissionService);
const isOwner = useLiveData(permissionService.permission.isOwner$);
const handleCheck = useAsyncCallback(
async (checked: boolean) => {
@ -30,6 +33,10 @@ export const Sharing = () => {
[shareSetting]
);
if (!isOwner) {
return null;
}
return (
<SettingWrapper title={t['com.affine.settings.workspace.sharing.title']()}>
<SettingRow

View File

@ -1420,11 +1420,8 @@
"com.affine.settings.workspace.publish-tooltip": "Enable AFFiNE Cloud to publish this workspace",
"com.affine.settings.workspace.sharing.title": "Sharing",
"com.affine.settings.workspace.sharing.url-preview.description": "Allow URL unfurling by Slack & other social apps, even if a doc is only accessible by workspace members.",
"com.affine.settings.workspace.sharing.url-preview.title": "Always Enable URL Preview",
"com.affine.settings.workspace.sharing.url-preview.title": "Always enable url preview",
"com.affine.settings.workspace.storage.tip": "Click to move storage location.",
"com.affine.settings.workspace.sharing.title": "Sharing",
"com.affine.settings.workspace.sharing.url-preview.title": "Always Enable URL Preview",
"com.affine.settings.workspace.sharing.url-preview.description": "Allow URL unfurling by Slack & other social apps, even if a doc is only accessible by workspace members.",
"com.affine.share-menu.EnableCloudDescription": "Sharing doc requires AFFiNE Cloud.",
"com.affine.share-menu.ShareMode": "Share mode",
"com.affine.share-menu.SharePage": "Share doc",