chore: clean up runtime flags and envs (#7454)

This commit is contained in:
forehalo
2024-07-11 02:05:30 +00:00
parent 0739e10683
commit 2f441d9335
30 changed files with 126 additions and 436 deletions

View File

@@ -1,14 +1,8 @@
ENABLE_PLUGIN=
ENABLE_TEST_PROPERTIES=
ENABLE_BC_PROVIDER=
CHANGELOG_URL=
ENABLE_PRELOADING=
ENABLE_NEW_SETTING_MODAL=
ENABLE_SQLITE_PROVIDER=
ENABLE_NEW_SETTING_UNSTABLE_API=
ENABLE_NOTIFICATION_CENTER=
ENABLE_CLOUD=
ENABLE_MOVE_DATABASE=
SHOULD_REPORT_TRACE=
TRACE_REPORT_ENDPOINT=
CAPTCHA_SITE_KEY=
ENABLE_CAPTCHA=
CAPTCHA_SITE_KEY=
ENABLE_ENHANCE_SHARE_MODE=
ALLOW_LOCAL_WORKSPACE=
DEBUG_JOTAI=

View File

@@ -58,7 +58,6 @@ jobs:
run: yarn nx build @affine/web --skip-nx-cache
env:
BUILD_TYPE: ${{ github.event.inputs.flavor }}
SHOULD_REPORT_TRACE: false
PUBLIC_PATH: '/'
SELF_HOSTED: true
MIXPANEL_TOKEN: ${{ secrets.MIXPANEL_TOKEN }}
@@ -86,7 +85,6 @@ jobs:
run: yarn nx build @affine/admin --skip-nx-cache
env:
BUILD_TYPE: ${{ github.event.inputs.flavor }}
SHOULD_REPORT_TRACE: false
PUBLIC_PATH: '/admin/'
SELF_HOSTED: true
MIXPANEL_TOKEN: ${{ secrets.MIXPANEL_TOKEN }}

View File

@@ -45,8 +45,6 @@ jobs:
R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
BUILD_TYPE: ${{ github.event.inputs.flavor }}
SHOULD_REPORT_TRACE: true
TRACE_REPORT_ENDPOINT: ${{ secrets.TRACE_REPORT_ENDPOINT }}
CAPTCHA_SITE_KEY: ${{ secrets.CAPTCHA_SITE_KEY }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: 'affine-web'
@@ -79,8 +77,6 @@ jobs:
R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
BUILD_TYPE: ${{ github.event.inputs.flavor }}
SHOULD_REPORT_TRACE: true
TRACE_REPORT_ENDPOINT: ${{ secrets.TRACE_REPORT_ENDPOINT }}
CAPTCHA_SITE_KEY: ${{ secrets.CAPTCHA_SITE_KEY }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: 'affine-admin'

View File

@@ -6,26 +6,6 @@ import { isDesktop, isServer } from './constant.js';
import { UaHelper } from './ua-helper.js';
export const runtimeFlagsSchema = z.object({
enableTestProperties: z.boolean(),
enableBroadcastChannelProvider: z.boolean(),
enableDebugPage: z.boolean(),
githubUrl: z.string(),
changelogUrl: z.string(),
downloadUrl: z.string(),
// see: tools/workers
imageProxyUrl: z.string(),
linkPreviewUrl: z.string(),
enablePreloading: z.boolean(),
enableNewSettingModal: z.boolean(),
enableNewSettingUnstableApi: z.boolean(),
enableCloud: z.boolean(),
enableCaptcha: z.boolean(),
enableEnhanceShareMode: z.boolean(),
enablePayment: z.boolean(),
enablePageHistory: z.boolean(),
enableExperimentalFeature: z.boolean(),
enableInfoModal: z.boolean(),
allowLocalWorkspace: z.boolean(),
// this is for the electron app
serverUrlPrefix: z.string(),
appVersion: z.string(),
@@ -37,6 +17,19 @@ export const runtimeFlagsSchema = z.object({
z.literal('canary'),
]),
isSelfHosted: z.boolean().optional(),
githubUrl: z.string(),
changelogUrl: z.string(),
downloadUrl: z.string(),
// see: tools/workers
imageProxyUrl: z.string(),
linkPreviewUrl: z.string(),
allowLocalWorkspace: z.boolean(),
enablePreloading: z.boolean(),
enableNewSettingUnstableApi: z.boolean(),
enableCaptcha: z.boolean(),
enableEnhanceShareMode: z.boolean(),
enableExperimentalFeature: z.boolean(),
enableInfoModal: z.boolean(),
});
export type RuntimeConfig = z.infer<typeof runtimeFlagsSchema>;

View File

@@ -29,12 +29,6 @@ export default {
target: 'ES2022',
},
define: {
'process.env': {},
'process.env.COVERAGE': JSON.stringify(!!process.env.COVERAGE),
'process.env.SHOULD_REPORT_TRACE': `${Boolean(
process.env.SHOULD_REPORT_TRACE === 'true'
)}`,
'process.env.TRACE_REPORT_ENDPOINT': `"${process.env.TRACE_REPORT_ENDPOINT}"`,
'process.env.CAPTCHA_SITE_KEY': `"${process.env.CAPTCHA_SITE_KEY}"`,
runtimeConfig: getRuntimeConfig({
distribution: 'browser',

View File

@@ -8,7 +8,6 @@ import type { ActiveTab } from '../components/affine/setting-modal/types';
export const openWorkspacesModalAtom = atom(false);
export const openCreateWorkspaceModalAtom = atom<CreateWorkspaceMode>(false);
export const openSignOutModalAtom = atom(false);
export const openPaymentDisableAtom = atom(false);
export const openQuotaModalAtom = atom(false);
export const openStarAFFiNEModalAtom = atom(false);
export const openIssueFeedbackModalAtom = atom(false);
@@ -51,8 +50,6 @@ export const authAtom = atom<AuthAtom>({
emailType: 'changeEmail',
});
export const openDisableCloudAlertModalAtom = atom(false);
export type AllPageFilterOption = 'docs' | 'collections' | 'tags';
export const allPageFilterSelectAtom = atom<AllPageFilterOption>('docs');

View File

@@ -1,7 +1,7 @@
import { Avatar, Input, Switch, toast } from '@affine/component';
import type { ConfirmModalProps } from '@affine/component/ui/modal';
import { ConfirmModal, Modal } from '@affine/component/ui/modal';
import { authAtom, openDisableCloudAlertModalAtom } from '@affine/core/atoms';
import { authAtom } from '@affine/core/atoms';
import { useAsyncCallback } from '@affine/core/hooks/affine-async-hooks';
import { DebugLogger } from '@affine/debug';
import { apis } from '@affine/electron-api';
@@ -61,20 +61,14 @@ const NameWorkspaceContent = ({
const session = useService(AuthService).session;
const loginStatus = useLiveData(session.status$);
const setDisableCloudOpen = useSetAtom(openDisableCloudAlertModalAtom);
const setOpenSignIn = useSetAtom(authAtom);
const openSignInModal = useCallback(() => {
if (!runtimeConfig.enableCloud) {
setDisableCloudOpen(true);
} else {
setOpenSignIn(state => ({
...state,
openModal: true,
}));
}
}, [setDisableCloudOpen, setOpenSignIn]);
setOpenSignIn(state => ({
...state,
openModal: true,
}));
}, [setOpenSignIn]);
const onSwitchChange = useCallback(
(checked: boolean) => {

View File

@@ -1,12 +1,9 @@
import { OverlayModal } from '@affine/component';
import {
openDisableCloudAlertModalAtom,
openHistoryTipsModalAtom,
} from '@affine/core/atoms';
import { openHistoryTipsModalAtom } from '@affine/core/atoms';
import { useEnableCloud } from '@affine/core/hooks/affine/use-enable-cloud';
import { useI18n } from '@affine/i18n';
import { useService, WorkspaceService } from '@toeverything/infra';
import { useAtom, useSetAtom } from 'jotai';
import { useAtom } from 'jotai';
import { useCallback } from 'react';
import TopSvg from './top-svg';
@@ -15,17 +12,12 @@ export const HistoryTipsModal = () => {
const t = useI18n();
const currentWorkspace = useService(WorkspaceService).workspace;
const [open, setOpen] = useAtom(openHistoryTipsModalAtom);
const setTempDisableCloudOpen = useSetAtom(openDisableCloudAlertModalAtom);
const confirmEnableCloud = useEnableCloud();
const handleConfirm = useCallback(() => {
setOpen(false);
if (runtimeConfig.enableCloud) {
confirmEnableCloud(currentWorkspace);
return;
}
return setTempDisableCloudOpen(true);
}, [confirmEnableCloud, currentWorkspace, setOpen, setTempDisableCloudOpen]);
confirmEnableCloud(currentWorkspace);
}, [confirmEnableCloud, currentWorkspace, setOpen]);
return (
<OverlayModal

View File

@@ -1,35 +0,0 @@
import { ConfirmModal } from '@affine/component/ui/modal';
import { useI18n } from '@affine/i18n';
import { useAtom } from 'jotai';
import { useCallback } from 'react';
import { openPaymentDisableAtom } from '../../../atoms';
import * as styles from './style.css';
export const PaymentDisableModal = () => {
const [open, setOpen] = useAtom(openPaymentDisableAtom);
const t = useI18n();
const onClickCancel = useCallback(() => {
setOpen(false);
}, [setOpen]);
return (
<ConfirmModal
title={t['com.affine.payment.disable-payment.title']()}
cancelText=""
cancelButtonOptions={{ style: { display: 'none' } }}
confirmButtonOptions={{
type: 'primary',
children: t['Got it'](),
}}
onConfirm={onClickCancel}
open={open}
onOpenChange={setOpen}
>
<p className={styles.paymentDisableModalContent}>
{t['com.affine.payment.disable-payment.description']()}
</p>
</ConfirmModal>
);
};

View File

@@ -1,5 +0,0 @@
import { cssVar } from '@toeverything/theme';
import { style } from '@vanilla-extract/css';
export const paymentDisableModalContent = style({
color: cssVar('textPrimaryColor'),
});

View File

@@ -9,12 +9,11 @@ import { Trans, useI18n } from '@affine/i18n';
import { DoneIcon } from '@blocksuite/icons/rc';
import { useLiveData, useService } from '@toeverything/infra';
import clsx from 'clsx';
import { useAtom, useSetAtom } from 'jotai';
import { useSetAtom } from 'jotai';
import { nanoid } from 'nanoid';
import type { HTMLAttributes, PropsWithChildren } from 'react';
import { useCallback, useEffect, useMemo, useState } from 'react';
import { openPaymentDisableAtom } from '../../../../../atoms';
import { authAtom } from '../../../../../atoms/index';
import { mixpanel } from '../../../../../utils';
import { CancelAction, ResumeAction } from './actions';
@@ -280,13 +279,7 @@ export const Upgrade = ({
return;
}, [isOpenedExternalWindow, subscriptionService]);
const [, openPaymentDisableModal] = useAtom(openPaymentDisableAtom);
const upgrade = useAsyncCallback(async () => {
if (!runtimeConfig.enablePayment) {
openPaymentDisableModal(true);
return;
}
setMutating(true);
mixpanel.track('PlanUpgradeStarted', {
segment: 'settings panel',
@@ -306,7 +299,7 @@ export const Upgrade = ({
setIdempotencyKey(nanoid());
popupWindow(link);
setOpenedExternalWindow(true);
}, [openPaymentDisableModal, subscriptionService, recurring, idempotencyKey]);
}, [subscriptionService, recurring, idempotencyKey]);
return (
<Button

View File

@@ -196,11 +196,8 @@ export const SettingSidebar = ({
</div>
<div className={style.sidebarFooter}>
{runtimeConfig.enableCloud && loginStatus === 'unauthenticated' ? (
<SignInButton />
) : null}
{runtimeConfig.enableCloud && loginStatus === 'authenticated' ? (
{loginStatus === 'unauthenticated' ? <SignInButton /> : null}
{loginStatus === 'authenticated' ? (
<Suspense>
<UserInfo
onAccountSettingClick={onAccountSettingClick}

View File

@@ -11,10 +11,9 @@ import {
WorkspaceService,
} from '@toeverything/infra';
import { useSetAtom } from 'jotai';
import { useCallback, useState } from 'react';
import { useCallback } from 'react';
import { openSettingModalAtom } from '../../../../../atoms';
import { TmpDisableAffineCloudModal } from '../../../tmp-disable-affine-cloud-modal';
export interface PublishPanelProps {
workspace: Workspace | null;
@@ -30,8 +29,6 @@ export const EnableCloudPanel = () => {
const setSettingModal = useSetAtom(openSettingModalAtom);
const [open, setOpen] = useState(false);
const confirmEnableCloudAndClose = useCallback(() => {
if (!workspace) return;
confirmEnableCloud(workspace, {
@@ -46,30 +43,25 @@ export const EnableCloudPanel = () => {
}
return (
<>
<SettingRow
name={t['Workspace saved locally']({
name: name ?? UNTITLED_WORKSPACE_NAME,
})}
desc={t['Enable cloud hint']()}
spreadCol={false}
style={{
padding: '10px',
background: 'var(--affine-background-secondary-color)',
}}
<SettingRow
name={t['Workspace saved locally']({
name: name ?? UNTITLED_WORKSPACE_NAME,
})}
desc={t['Enable cloud hint']()}
spreadCol={false}
style={{
padding: '10px',
background: 'var(--affine-background-secondary-color)',
}}
>
<Button
data-testid="publish-enable-affine-cloud-button"
type="primary"
onClick={confirmEnableCloudAndClose}
style={{ marginTop: '12px' }}
>
<Button
data-testid="publish-enable-affine-cloud-button"
type="primary"
onClick={confirmEnableCloudAndClose}
style={{ marginTop: '12px' }}
>
{t['Enable AFFiNE Cloud']()}
</Button>
</SettingRow>
{runtimeConfig.enableCloud ? null : (
<TmpDisableAffineCloudModal open={open} onOpenChange={setOpen} />
)}
</>
{t['Enable AFFiNE Cloud']()}
</Button>
</SettingRow>
);
};

View File

@@ -1,61 +0,0 @@
import { Empty } from '@affine/component';
import type { ModalProps } from '@affine/component/ui/modal';
import { Modal } from '@affine/component/ui/modal';
import { Trans, useI18n } from '@affine/i18n';
import { useCallback } from 'react';
import {
StyleButton,
StyleButtonContainer,
StyleImage,
StyleTips,
} from './style';
export const TmpDisableAffineCloudModal = (props: ModalProps) => {
const t = useI18n();
const onClose = useCallback(() => {
props.onOpenChange?.(false);
}, [props]);
return (
<Modal
title={t['com.affine.cloudTempDisable.title']()}
contentOptions={{
['data-testid' as string]: 'disable-affine-cloud-modal',
}}
width={480}
{...props}
>
<StyleTips>
<Trans i18nKey="com.affine.cloudTempDisable.description">
We are upgrading the AFFiNE Cloud service and it is temporarily
unavailable on the client side. If you wish to stay updated on the
progress and be notified on availability, you can fill out the
<a
href="https://6dxre9ihosp.typeform.com/to/B8IHwuyy"
rel="noreferrer"
target="_blank"
style={{
color: 'var(--affine-link-color)',
}}
>
AFFiNE Cloud Signup
</a>
.
</Trans>
</StyleTips>
<StyleImage>
<Empty
containerStyle={{
width: '200px',
height: '112px',
}}
/>
</StyleImage>
<StyleButtonContainer>
<StyleButton type="primary" onClick={onClose}>
{t['Got it']()}
</StyleButton>
</StyleButtonContainer>
</Modal>
);
};

View File

@@ -1,54 +0,0 @@
import { displayFlex, styled } from '@affine/component';
import { Button } from '@affine/component/ui/button';
export const Header = styled('div')({
height: '44px',
display: 'flex',
flexDirection: 'row-reverse',
paddingRight: '10px',
paddingTop: '10px',
flexShrink: 0,
});
export const Content = styled('div')({
padding: '0 40px',
});
export const ContentTitle = styled('h1')(() => {
return {
marginTop: 44,
fontSize: 'var(--affine-font-h6)',
lineHeight: '28px',
fontWeight: 600,
};
});
export const StyleTips = styled('div')(() => {
return {
margin: '0 0 20px 0',
a: {
color: 'var(--affine-primary-color)',
},
};
});
export const StyleButton = styled(Button)({
textAlign: 'center',
borderRadius: '8px',
backgroundColor: 'var(--affine-primary-color)',
span: {
margin: '0',
},
});
export const StyleButtonContainer = styled('div')(() => {
return {
width: '100%',
marginTop: 20,
...displayFlex('flex-end', 'center'),
};
});
export const StyleImage = styled('div')(() => {
return {
...displayFlex('center', 'center'),
};
});

View File

@@ -245,7 +245,7 @@ export const PageHeaderMenuButton = ({
{t['com.affine.header.option.add-tag']()}
</MenuItem> */}
<MenuSeparator />
{runtimeConfig.enableInfoModal ? (
{runtimeConfig.enableInfoModal && (
<MenuItem
preFix={
<MenuIcon>
@@ -258,21 +258,19 @@ export const PageHeaderMenuButton = ({
>
{t['com.affine.page-properties.page-info.view']()}
</MenuItem>
) : null}
{runtimeConfig.enablePageHistory ? (
<MenuItem
preFix={
<MenuIcon>
<HistoryIcon />
</MenuIcon>
}
data-testid="editor-option-menu-history"
onSelect={openHistoryModal}
style={menuItemStyle}
>
{t['com.affine.history.view-history-version']()}
</MenuItem>
) : null}
)}
<MenuItem
preFix={
<MenuIcon>
<HistoryIcon />
</MenuIcon>
}
data-testid="editor-option-menu-history"
onSelect={openHistoryModal}
style={menuItemStyle}
>
{t['com.affine.history.view-history-version']()}
</MenuItem>
<MenuSeparator />
{!isJournal && (
<MenuItem
@@ -301,7 +299,6 @@ export const PageHeaderMenuButton = ({
{t['Import']()}
</MenuItem>
<Export exportHandler={exportHandler} pageMode={currentMode} />
<MenuSeparator />
<MoveToTrash
data-testid="editor-option-menu-delete"

View File

@@ -12,11 +12,7 @@ import {
import { useSetAtom } from 'jotai';
import { Suspense, useCallback } from 'react';
import {
authAtom,
openCreateWorkspaceModalAtom,
openDisableCloudAlertModalAtom,
} from '../../../../atoms';
import { authAtom, openCreateWorkspaceModalAtom } from '../../../../atoms';
import { mixpanel } from '../../../../utils';
import { AddWorkspace } from './add-workspace';
import * as styles from './index.css';
@@ -24,8 +20,6 @@ import { UserAccountItem } from './user-account';
import { AFFiNEWorkspaceList } from './workspace-list';
export const SignInItem = () => {
const setDisableCloudOpen = useSetAtom(openDisableCloudAlertModalAtom);
const setOpen = useSetAtom(authAtom);
const t = useI18n();
@@ -34,15 +28,11 @@ export const SignInItem = () => {
mixpanel.track('Button', {
resolve: 'SignIn',
});
if (!runtimeConfig.enableCloud) {
setDisableCloudOpen(true);
} else {
setOpen(state => ({
...state,
openModal: true,
}));
}
}, [setOpen, setDisableCloudOpen]);
setOpen(state => ({
...state,
openModal: true,
}));
}, [setOpen]);
return (
<MenuItem
@@ -88,20 +78,15 @@ const UserWithWorkspaceListInner = ({
const isAuthenticated = session.status === 'authenticated';
const setOpenCreateWorkspaceModal = useSetAtom(openCreateWorkspaceModalAtom);
const setDisableCloudOpen = useSetAtom(openDisableCloudAlertModalAtom);
const setOpenSignIn = useSetAtom(authAtom);
const openSignInModal = useCallback(() => {
if (!runtimeConfig.enableCloud) {
setDisableCloudOpen(true);
} else {
setOpenSignIn(state => ({
...state,
openModal: true,
}));
}
}, [setDisableCloudOpen, setOpenSignIn]);
setOpenSignIn(state => ({
...state,
openModal: true,
}));
}, [setOpenSignIn]);
const onNewWorkspace = useCallback(() => {
if (!isAuthenticated && !runtimeConfig.allowLocalWorkspace) {

View File

@@ -192,17 +192,15 @@ export const RootAppSidebar = memo(
<AppSidebarJournalButton
docCollection={currentWorkspace.docCollection}
/>
{runtimeConfig.enableNewSettingModal ? (
<MenuItem
data-testid="slider-bar-workspace-setting-button"
icon={<SettingsIcon />}
onClick={onOpenSettingModal}
>
<span data-testid="settings-modal-trigger">
{t['com.affine.settingSidebar.title']()}
</span>
</MenuItem>
) : null}
<MenuItem
data-testid="slider-bar-workspace-setting-button"
icon={<SettingsIcon />}
onClick={onOpenSettingModal}
>
<span data-testid="settings-modal-trigger">
{t['com.affine.settingSidebar.title']()}
</span>
</MenuItem>
</SidebarContainer>
<SidebarScrollableContainer>
<FavoriteList docCollection={docCollection} />

View File

@@ -11,7 +11,6 @@ import {
} from '@affine/component';
import {
authAtom,
openDisableCloudAlertModalAtom,
openSettingModalAtom,
openSignOutModalAtom,
} from '@affine/core/atoms';
@@ -65,13 +64,11 @@ const AuthorizedUserInfo = ({ account }: { account: AuthAccountInfo }) => {
};
const UnauthorizedUserInfo = () => {
const setDisableCloudOpen = useSetAtom(openDisableCloudAlertModalAtom);
const setOpen = useSetAtom(authAtom);
const openSignInModal = useCallback(() => {
if (!runtimeConfig.enableCloud) setDisableCloudOpen(true);
else setOpen(state => ({ ...state, openModal: true }));
}, [setDisableCloudOpen, setOpen]);
setOpen(state => ({ ...state, openModal: true }));
}, [setOpen]);
return (
<Button

View File

@@ -73,7 +73,6 @@ export const useEnableCloud = () => {
const confirmEnableCloud = useCallback(
(ws: Workspace, options?: ConfirmEnableCloudOptions) => {
const { onSuccess, onFinished } = options ?? {};
if (!runtimeConfig.enableCloud) return;
const closeOnSuccess = () => {
closeConfirmModal();

View File

@@ -253,7 +253,7 @@ export function useRegisterBlocksuiteEditorCommands() {
})
);
if (runtimeConfig.enablePageHistory && isCloudWorkspace) {
if (isCloudWorkspace) {
unsubs.push(
registerAffineCommand({
id: `editor:${mode}-page-history`,

View File

@@ -16,7 +16,6 @@ import type { SettingAtom } from '../atoms';
import {
authAtom,
openCreateWorkspaceModalAtom,
openDisableCloudAlertModalAtom,
openSettingModalAtom,
openSignOutModalAtom,
} from '../atoms';
@@ -25,7 +24,6 @@ import { AiLoginRequiredModal } from '../components/affine/auth/ai-login-require
import { CreateWorkspaceModal } from '../components/affine/create-workspace-modal';
import { HistoryTipsModal } from '../components/affine/history-tips-modal';
import { IssueFeedbackModal } from '../components/affine/issue-feedback-modal';
import { PaymentDisableModal } from '../components/affine/payment-disable';
import {
CloudQuotaModal,
LocalQuotaModal,
@@ -33,7 +31,6 @@ import {
import { SettingModal } from '../components/affine/setting-modal';
import { SignOutModal } from '../components/affine/sign-out-modal';
import { StarAFFiNEModal } from '../components/affine/star-affine-modal';
import { TmpDisableAffineCloudModal } from '../components/affine/tmp-disable-affine-cloud-modal';
import { MoveToTrash } from '../components/page-list';
import { useTrashModalHelper } from '../hooks/affine/use-trash-modal-helper';
import { useAsyncCallback } from '../hooks/affine-async-hooks';
@@ -137,9 +134,6 @@ export const AuthModal = (): ReactElement => {
export function CurrentWorkspaceModals() {
const currentWorkspace = useService(WorkspaceService).workspace;
const [openDisableCloudAlertModal, setOpenDisableCloudAlertModal] = useAtom(
openDisableCloudAlertModalAtom
);
const { trashModal, setTrashModal, handleOnConfirm } = useTrashModalHelper(
currentWorkspace.docCollection
@@ -158,10 +152,6 @@ export function CurrentWorkspaceModals() {
return (
<>
<TmpDisableAffineCloudModal
open={openDisableCloudAlertModal}
onOpenChange={setOpenDisableCloudAlertModal}
/>
<StarAFFiNEModal />
<IssueFeedbackModal />
{currentWorkspace ? <Setting /> : null}
@@ -256,7 +246,6 @@ export const AllWorkspaceModals = (): ReactElement => {
/>
<AuthModal />
<SignOutConfirmModal />
<PaymentDisableModal />
</>
);
};

View File

@@ -1031,8 +1031,6 @@
"com.affine.payment.lifetime.benefit-4": "Dedicated Discord support with AFFiNE makers",
"com.affine.payment.contact-sales": "Contact Sales",
"com.affine.payment.current-plan": "Current Plan",
"com.affine.payment.disable-payment.description": "This is a special testing(Canary) version of AFFiNE. Account upgrades are not supported in this version. If you want to experience the full service, please download the stable version from our website.",
"com.affine.payment.disable-payment.title": "Account Upgrade Unavailable",
"com.affine.payment.discount-amount": "{{amount}}% off",
"com.affine.payment.downgrade": "Downgrade",
"com.affine.payment.downgraded-tooltip": "You have successfully downgraded. After the current billing period ends, your account will automatically switch to the Free plan.",

View File

@@ -986,8 +986,6 @@
"com.affine.payment.cloud.team.title": "Contacter le service commercial\n\n\n\n\n\n",
"com.affine.payment.contact-sales": "Contacter le service commercial\n\n\n\n\n\n",
"com.affine.payment.current-plan": "Abonnement actuel",
"com.affine.payment.disable-payment.description": "Il s'agit d'une version prévue pour le test (Canary) d'AFFiNE. Les comptes payants ne sont pas pris en charge dans cette version. Si vous souhaitez bénéficier de tous les services, veuillez télécharger la version stable sur notre site web.",
"com.affine.payment.disable-payment.title": "Compte payant non disponible",
"com.affine.payment.discount-amount": "{{amount}}% de réduction\n",
"com.affine.payment.downgrade": "Rétrograder",
"com.affine.payment.downgraded-tooltip": "Vous avez rétrogradé avec succès. Une fois la période de facturation actuelle terminée, votre compte basculera automatiquement vers l'abonnement gratuit.",

View File

@@ -813,8 +813,6 @@
"com.affine.payment.change-to": "{{to}}로 결제를 변경",
"com.affine.payment.contact-sales": "Contact Sales",
"com.affine.payment.current-plan": "현재 플랜",
"com.affine.payment.disable-payment.description": "AFFiNE의 특별 테스트(Canary) 버전입니다. 이 버전에서는 계정 업그레이드가 지원되지 않습니다. 정식 서비스를 경험하고 싶으시면 웹사이트에서 안정 버전을 다운로드하세요.",
"com.affine.payment.disable-payment.title": "계정 업그레이드 불가",
"com.affine.payment.discount-amount": "{{amount}}% 할인",
"com.affine.payment.downgrade": "다운그레이드",
"com.affine.payment.downgraded-tooltip": "성공적으로 다운그레이드했습니다. 현재 청구 기간이 종료되면 계정이 자동으로 무료 요금제로 전환됩니다.",

View File

@@ -1005,8 +1005,6 @@
"com.affine.payment.cloud.team.title": "Связаться с отделом продаж",
"com.affine.payment.contact-sales": "Связаться с отделом продаж",
"com.affine.payment.current-plan": "Текущий план",
"com.affine.payment.disable-payment.description": "Это специальная тестовая (Canary) версия AFFiNE. Обновления аккаунта не поддерживаются в этой версии. Если вы хотите воспользоваться всеми возможностями сервиса, пожалуйста, загрузите стабильную версию с нашего сайта.",
"com.affine.payment.disable-payment.title": "Обновление аккаунта недоступно",
"com.affine.payment.discount-amount": "{{amount}}% скидка",
"com.affine.payment.downgrade": "Понизить",
"com.affine.payment.downgraded-tooltip": "Вы успешно понизили тариф. После окончания текущего периода оплаты ваш аккаунт автоматически перейдет на Free план.",

View File

@@ -1011,8 +1011,6 @@
"com.affine.payment.cloud.team.title": "联系销售",
"com.affine.payment.contact-sales": "联系销售",
"com.affine.payment.current-plan": "当前计划",
"com.affine.payment.disable-payment.description": "这是 AFFiNE 的特别测试(Canary)版本。此版本不支持账户升级。如果您想体验完整服务,请从我们的官网下载稳定版本。",
"com.affine.payment.disable-payment.title": "账户升级不可用",
"com.affine.payment.discount-amount": "{{amount}}% 折扣",
"com.affine.payment.downgrade": "降级",
"com.affine.payment.downgraded-tooltip": "您已成功降级。当前计费周期结束后,您的账户将自动切换到免费计划。",

View File

@@ -50,12 +50,6 @@
{
"env": "CAPTCHA_SITE_KEY"
},
{
"env": "SHOULD_REPORT_TRACE"
},
{
"env": "TRACE_REPORT_ENDPOINT"
},
{
"env": "R2_ACCOUNT_ID"
},

View File

@@ -333,15 +333,7 @@ export const createConfiguration: (
}),
new VanillaExtractPlugin(),
new webpack.DefinePlugin({
'process.env': JSON.stringify({}),
'process.env.COVERAGE': JSON.stringify(!!buildFlags.coverage),
'process.env.NODE_ENV': JSON.stringify(buildFlags.mode),
'process.env.SHOULD_REPORT_TRACE': JSON.stringify(
Boolean(process.env.SHOULD_REPORT_TRACE === 'true')
),
'process.env.TRACE_REPORT_ENDPOINT': JSON.stringify(
process.env.TRACE_REPORT_ENDPOINT
),
'process.env.CAPTCHA_SITE_KEY': JSON.stringify(
process.env.CAPTCHA_SITE_KEY
),
@@ -350,6 +342,7 @@ export const createConfiguration: (
'process.env.MIXPANEL_TOKEN': JSON.stringify(
process.env.MIXPANEL_TOKEN
),
'process.env.DEBUG_JOTAI': JSON.stringify(process.env.DEBUG_JOTAI),
runtimeConfig: JSON.stringify(runtimeConfig),
}),
buildFlags.distribution === 'admin'

View File

@@ -5,71 +5,56 @@ import type { BuildFlags } from '../config';
export function getRuntimeConfig(buildFlags: BuildFlags): RuntimeConfig {
const buildPreset: Record<BuildFlags['channel'], RuntimeConfig> = {
stable: {
enableTestProperties: false,
enableBroadcastChannelProvider: true,
enableDebugPage: true,
githubUrl: 'https://github.com/toeverything/AFFiNE',
changelogUrl: 'https://affine.pro/what-is-new',
downloadUrl: 'https://affine.pro/download',
imageProxyUrl: '/api/worker/image-proxy',
linkPreviewUrl: '/api/worker/link-preview',
enablePreloading: true,
enableNewSettingModal: true,
enableNewSettingUnstableApi: false,
enableCloud: true,
enableCaptcha: true,
enableEnhanceShareMode: false,
enablePayment: true,
enablePageHistory: true,
enableExperimentalFeature: false,
enableInfoModal: false,
allowLocalWorkspace: buildFlags.distribution === 'desktop' ? true : false,
serverUrlPrefix: 'https://app.affine.pro',
appVersion: packageJson.version,
editorVersion: packageJson.devDependencies['@blocksuite/presets'],
appBuildType: 'stable',
get stable() {
return {
appBuildType: 'stable' as const,
serverUrlPrefix: 'https://app.affine.pro',
appVersion: packageJson.version,
editorVersion: packageJson.devDependencies['@blocksuite/presets'],
githubUrl: 'https://github.com/toeverything/AFFiNE',
changelogUrl: 'https://affine.pro/what-is-new',
downloadUrl: 'https://affine.pro/download',
imageProxyUrl: '/api/worker/image-proxy',
linkPreviewUrl: '/api/worker/link-preview',
enablePreloading: true,
enableCaptcha: true,
enableExperimentalFeature: true,
allowLocalWorkspace:
buildFlags.distribution === 'desktop' ? true : false,
// TODO(@forehalo): enable in next release and canary
enableInfoModal: false,
// CAUTION(@forehalo): product not ready, do not enable it
enableNewSettingUnstableApi: false,
enableEnhanceShareMode: false,
};
},
get beta() {
return {
...this.stable,
enablePageHistory: true,
serverUrlPrefix: 'https://insider.affine.pro',
appBuildType: 'beta' as const,
serverUrlPrefix: 'https://insider.affine.pro',
changelogUrl: 'https://github.com/toeverything/AFFiNE/releases',
};
},
get internal() {
return {
...this.stable,
serverUrlPrefix: 'https://insider.affine.pro',
appBuildType: 'internal' as const,
serverUrlPrefix: 'https://insider.affine.pro',
changelogUrl: 'https://github.com/toeverything/AFFiNE/releases',
};
},
// canary will be aggressive and enable all features
canary: {
enableTestProperties: true,
enableBroadcastChannelProvider: true,
enableDebugPage: true,
githubUrl: 'https://github.com/toeverything/AFFiNE',
changelogUrl: 'https://github.com/toeverything/AFFiNE/releases',
downloadUrl: 'https://affine.pro/download',
imageProxyUrl: '/api/worker/image-proxy',
linkPreviewUrl: '/api/worker/link-preview',
enablePreloading: true,
enableNewSettingModal: true,
enableNewSettingUnstableApi: false,
enableCloud: true,
enableCaptcha: true,
enableEnhanceShareMode: false,
enablePayment: true,
enablePageHistory: true,
enableExperimentalFeature: true,
enableInfoModal: true,
allowLocalWorkspace: buildFlags.distribution === 'desktop' ? true : false,
serverUrlPrefix: 'https://affine.fail',
appVersion: packageJson.version,
editorVersion: packageJson.devDependencies['@blocksuite/presets'],
appBuildType: 'canary',
get canary() {
return {
...this.stable,
appBuildType: 'canary' as const,
serverUrlPrefix: 'https://affine.fail',
changelogUrl: 'https://github.com/toeverything/AFFiNE/releases',
enableInfoModal: true,
};
},
};
@@ -82,25 +67,13 @@ export function getRuntimeConfig(buildFlags: BuildFlags): RuntimeConfig {
const currentBuildPreset = buildPreset[currentBuild];
const environmentPreset = {
enableTestProperties: process.env.ENABLE_TEST_PROPERTIES
? process.env.ENABLE_TEST_PROPERTIES === 'true'
: currentBuildPreset.enableTestProperties,
enableBroadcastChannelProvider: process.env.ENABLE_BC_PROVIDER
? process.env.ENABLE_BC_PROVIDER !== 'false'
: currentBuildPreset.enableBroadcastChannelProvider,
changelogUrl: process.env.CHANGELOG_URL ?? currentBuildPreset.changelogUrl,
enablePreloading: process.env.ENABLE_PRELOADING
? process.env.ENABLE_PRELOADING === 'true'
: currentBuildPreset.enablePreloading,
enableNewSettingModal: process.env.ENABLE_NEW_SETTING_MODAL
? process.env.ENABLE_NEW_SETTING_MODAL === 'true'
: currentBuildPreset.enableNewSettingModal,
enableNewSettingUnstableApi: process.env.ENABLE_NEW_SETTING_UNSTABLE_API
? process.env.ENABLE_NEW_SETTING_UNSTABLE_API === 'true'
: currentBuildPreset.enableNewSettingUnstableApi,
enableCloud: process.env.ENABLE_CLOUD
? process.env.ENABLE_CLOUD === 'true'
: currentBuildPreset.enableCloud,
enableCaptcha: process.env.ENABLE_CAPTCHA
? process.env.ENABLE_CAPTCHA === 'true'
: buildFlags.mode === 'development'
@@ -109,16 +82,6 @@ export function getRuntimeConfig(buildFlags: BuildFlags): RuntimeConfig {
enableEnhanceShareMode: process.env.ENABLE_ENHANCE_SHARE_MODE
? process.env.ENABLE_ENHANCE_SHARE_MODE === 'true'
: currentBuildPreset.enableEnhanceShareMode,
enablePayment: process.env.ENABLE_PAYMENT
? process.env.ENABLE_PAYMENT !== 'false'
: buildFlags.mode === 'development'
? true
: currentBuildPreset.enablePayment,
enablePageHistory: process.env.ENABLE_PAGE_HISTORY
? process.env.ENABLE_PAGE_HISTORY === 'true'
: buildFlags.mode === 'development'
? true
: currentBuildPreset.enablePageHistory,
allowLocalWorkspace: process.env.ALLOW_LOCAL_WORKSPACE
? process.env.ALLOW_LOCAL_WORKSPACE === 'true'
: buildFlags.mode === 'development'