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
2 changed files with 8 additions and 4 deletions
@@ -4,6 +4,7 @@ import {
SettingWrapper, SettingWrapper,
} from '@affine/component/setting-components'; } from '@affine/component/setting-components';
import { useAsyncCallback } from '@affine/core/components/hooks/affine-async-hooks'; 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 { WorkspaceShareSettingService } from '@affine/core/modules/share-setting';
import { WorkspaceFlavour } from '@affine/env/workspace'; import { WorkspaceFlavour } from '@affine/env/workspace';
import { useI18n } from '@affine/i18n'; import { useI18n } from '@affine/i18n';
@@ -22,6 +23,8 @@ export const Sharing = () => {
const shareSetting = useService(WorkspaceShareSettingService).sharePreview; const shareSetting = useService(WorkspaceShareSettingService).sharePreview;
const enableUrlPreview = useLiveData(shareSetting.enableUrlPreview$); const enableUrlPreview = useLiveData(shareSetting.enableUrlPreview$);
const loading = useLiveData(shareSetting.isLoading$); const loading = useLiveData(shareSetting.isLoading$);
const permissionService = useService(WorkspacePermissionService);
const isOwner = useLiveData(permissionService.permission.isOwner$);
const handleCheck = useAsyncCallback( const handleCheck = useAsyncCallback(
async (checked: boolean) => { async (checked: boolean) => {
@@ -30,6 +33,10 @@ export const Sharing = () => {
[shareSetting] [shareSetting]
); );
if (!isOwner) {
return null;
}
return ( return (
<SettingWrapper title={t['com.affine.settings.workspace.sharing.title']()}> <SettingWrapper title={t['com.affine.settings.workspace.sharing.title']()}>
<SettingRow <SettingRow
+1 -4
View File
@@ -1420,11 +1420,8 @@
"com.affine.settings.workspace.publish-tooltip": "Enable AFFiNE Cloud to publish this workspace", "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.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.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.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.EnableCloudDescription": "Sharing doc requires AFFiNE Cloud.",
"com.affine.share-menu.ShareMode": "Share mode", "com.affine.share-menu.ShareMode": "Share mode",
"com.affine.share-menu.SharePage": "Share doc", "com.affine.share-menu.SharePage": "Share doc",