mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-22 12:36:24 +08:00
feat(core): add enable url preview to workspace settings (#8089)
This commit is contained in:
+2
@@ -17,6 +17,7 @@ import { ExportPanel } from './export';
|
||||
import { LabelsPanel } from './labels';
|
||||
import { MembersPanel } from './members';
|
||||
import { ProfilePanel } from './profile';
|
||||
import { SharingPanel } from './sharing';
|
||||
import type { WorkspaceSettingDetailProps } from './types';
|
||||
|
||||
export const WorkspaceSettingDetail = ({
|
||||
@@ -67,6 +68,7 @@ export const WorkspaceSettingDetail = ({
|
||||
<EnableCloudPanel />
|
||||
<MembersPanel />
|
||||
</SettingWrapper>
|
||||
<SharingPanel />
|
||||
{environment.isElectron && (
|
||||
<SettingWrapper title={t['Storage and Export']()}>
|
||||
<ExportPanel
|
||||
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
import { Switch } from '@affine/component';
|
||||
import {
|
||||
SettingRow,
|
||||
SettingWrapper,
|
||||
} from '@affine/component/setting-components';
|
||||
import { useAsyncCallback } from '@affine/core/hooks/affine-async-hooks';
|
||||
import { WorkspaceShareSettingService } from '@affine/core/modules/share-setting';
|
||||
import { WorkspaceFlavour } from '@affine/env/workspace';
|
||||
import { useI18n } from '@affine/i18n';
|
||||
import { useLiveData, useService, WorkspaceService } from '@toeverything/infra';
|
||||
|
||||
export const SharingPanel = () => {
|
||||
const workspace = useService(WorkspaceService).workspace;
|
||||
if (workspace.flavour === WorkspaceFlavour.LOCAL) {
|
||||
return null;
|
||||
}
|
||||
return <Sharing />;
|
||||
};
|
||||
|
||||
export const Sharing = () => {
|
||||
const t = useI18n();
|
||||
const shareSetting = useService(WorkspaceShareSettingService).sharePreview;
|
||||
const enableUrlPreview = useLiveData(shareSetting.enableUrlPreview$);
|
||||
const loading = useLiveData(shareSetting.isLoading$);
|
||||
|
||||
const handleCheck = useAsyncCallback(
|
||||
async (checked: boolean) => {
|
||||
await shareSetting.setEnableUrlPreview(checked);
|
||||
},
|
||||
[shareSetting]
|
||||
);
|
||||
|
||||
return (
|
||||
<SettingWrapper title={t['com.affine.settings.workspace.sharing.title']()}>
|
||||
<SettingRow
|
||||
name={t['com.affine.settings.workspace.sharing.url-preview.title']()}
|
||||
desc={t[
|
||||
'com.affine.settings.workspace.sharing.url-preview.description'
|
||||
]()}
|
||||
>
|
||||
<Switch
|
||||
checked={enableUrlPreview || false}
|
||||
onChange={handleCheck}
|
||||
disabled={loading}
|
||||
/>
|
||||
</SettingRow>
|
||||
</SettingWrapper>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user