feat: backend module awareness & optional request (#5909)

This commit is contained in:
DarkSky
2024-02-28 08:29:37 +00:00
parent 35454c3bfc
commit 3432f355b0
7 changed files with 34 additions and 31 deletions
@@ -34,7 +34,7 @@ import {
openSignOutModalAtom,
} from '../../../../atoms';
import { useCurrentUser } from '../../../../hooks/affine/use-current-user';
import { useSelfHosted } from '../../../../hooks/affine/use-server-config';
import { useServerFeatures } from '../../../../hooks/affine/use-server-config';
import { useMutation } from '../../../../hooks/use-mutation';
import { useQuery } from '../../../../hooks/use-query';
import { useUserSubscription } from '../../../../hooks/use-subscription';
@@ -169,7 +169,7 @@ export const AvatarAndName = () => {
const StoragePanel = () => {
const t = useAFFiNEI18N();
const isSelfHosted = useSelfHosted();
const { payment: hasPaymentFeature } = useServerFeatures();
const { data } = useQuery({
query: allBlobSizesQuery,
@@ -205,7 +205,7 @@ const StoragePanel = () => {
plan={plan}
value={data.collectAllBlobSizes.size}
onUpgrade={onUpgrade}
upgradable={!isSelfHosted}
upgradable={hasPaymentFeature}
/>
</SettingRow>
);
@@ -7,7 +7,7 @@ import {
import type { ReactElement, SVGProps } from 'react';
import { useCurrentLoginStatus } from '../../../../hooks/affine/use-current-login-status';
import { useSelfHosted } from '../../../../hooks/affine/use-server-config';
import { useServerFeatures } from '../../../../hooks/affine/use-server-config';
import type { GeneralSettingKey } from '../types';
import { AboutAffine } from './about';
import { AppearanceSettings } from './appearance';
@@ -28,7 +28,7 @@ export type GeneralSettingList = GeneralSettingListItem[];
export const useGeneralSettingList = (): GeneralSettingList => {
const t = useAFFiNEI18N();
const status = useCurrentLoginStatus();
const isSelfHosted = useSelfHosted();
const { payment: hasPaymentFeature } = useServerFeatures();
const settings: GeneralSettingListItem[] = [
{
@@ -51,7 +51,7 @@ export const useGeneralSettingList = (): GeneralSettingList => {
},
];
if (!isSelfHosted) {
if (hasPaymentFeature) {
settings.splice(3, 0, {
key: 'plans',
title: t['com.affine.payment.title'](),
@@ -3,7 +3,7 @@ import {
SettingRow,
SettingWrapper,
} from '@affine/component/setting-components';
import { useSelfHosted } from '@affine/core/hooks/affine/use-server-config';
import { useServerFeatures } from '@affine/core/hooks/affine/use-server-config';
import { useWorkspace } from '@affine/core/hooks/use-workspace';
import { useWorkspaceInfo } from '@affine/core/hooks/use-workspace-info';
import { UNTITLED_WORKSPACE_NAME } from '@affine/env/constant';
@@ -20,7 +20,7 @@ import type { WorkspaceSettingDetailProps } from './types';
export const WorkspaceSettingDetail = (props: WorkspaceSettingDetailProps) => {
const t = useAFFiNEI18N();
const isSelfHosted = useSelfHosted();
const { payment: hasPaymentFeature } = useServerFeatures();
const workspaceMetadata = props.workspaceMetadata;
// useWorkspace hook is a vary heavy operation here, but we need syncing name and avatar changes here,
@@ -49,7 +49,7 @@ export const WorkspaceSettingDetail = (props: WorkspaceSettingDetailProps) => {
</SettingWrapper>
<SettingWrapper title={t['com.affine.brand.affineCloud']()}>
<EnableCloudPanel workspace={workspace} {...props} />
<MembersPanel upgradable={!isSelfHosted} {...props} />
<MembersPanel upgradable={hasPaymentFeature} {...props} />
</SettingWrapper>
{environment.isDesktop && (
<SettingWrapper title={t['Storage and Export']()}>