mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00:00
feat(electron): enable disable cloud alert (#2184)
This commit is contained in:
@@ -21,3 +21,21 @@ test('new page', async () => {
|
|||||||
expect(flavour).toBe('local');
|
expect(flavour).toBe('local');
|
||||||
await electronApp.close();
|
await electronApp.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('affine cloud disabled', async () => {
|
||||||
|
const electronApp = await electron.launch({
|
||||||
|
args: [resolve(__dirname, '..')],
|
||||||
|
executablePath: resolve(__dirname, '../node_modules/.bin/electron'),
|
||||||
|
});
|
||||||
|
const page = await electronApp.firstWindow();
|
||||||
|
await page.getByTestId('new-page-button').click({
|
||||||
|
delay: 100,
|
||||||
|
});
|
||||||
|
await page.waitForSelector('v-line');
|
||||||
|
await page.getByTestId('current-workspace').click();
|
||||||
|
await page.getByTestId('sign-in-button').click();
|
||||||
|
await page.getByTestId('disable-affine-cloud-modal').waitFor({
|
||||||
|
state: 'visible',
|
||||||
|
});
|
||||||
|
await electronApp.close();
|
||||||
|
});
|
||||||
|
|||||||
@@ -78,6 +78,8 @@ export const openWorkspacesModalAtom = atom(false);
|
|||||||
export const openCreateWorkspaceModalAtom = atom(false);
|
export const openCreateWorkspaceModalAtom = atom(false);
|
||||||
export const openQuickSearchModalAtom = atom(false);
|
export const openQuickSearchModalAtom = atom(false);
|
||||||
|
|
||||||
|
export const openDisableCloudAlertModalAtom = atom(false);
|
||||||
|
|
||||||
export { workspacesAtom } from './root';
|
export { workspacesAtom } from './root';
|
||||||
|
|
||||||
type View = { id: string; mode: 'page' | 'edgeless' };
|
type View = { id: string; mode: 'page' | 'edgeless' };
|
||||||
|
|||||||
@@ -21,7 +21,11 @@ export const TmpDisableAffineCloudModal: React.FC<
|
|||||||
TmpDisableAffineCloudModalProps
|
TmpDisableAffineCloudModalProps
|
||||||
> = ({ open, onClose }) => {
|
> = ({ open, onClose }) => {
|
||||||
return (
|
return (
|
||||||
<Modal open={open} onClose={onClose}>
|
<Modal
|
||||||
|
data-testid="disable-affine-cloud-modal"
|
||||||
|
open={open}
|
||||||
|
onClose={onClose}
|
||||||
|
>
|
||||||
<ModalWrapper width={480}>
|
<ModalWrapper width={480}>
|
||||||
<Header>
|
<Header>
|
||||||
<IconButton
|
<IconButton
|
||||||
@@ -41,6 +45,9 @@ export const TmpDisableAffineCloudModal: React.FC<
|
|||||||
<a
|
<a
|
||||||
href="https://github.com/toeverything/AFFiNE/releases"
|
href="https://github.com/toeverything/AFFiNE/releases"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
|
style={{
|
||||||
|
color: 'var(--affine-link-color)',
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
click here
|
click here
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@@ -5,10 +5,12 @@ import { config } from '@affine/env';
|
|||||||
import { useTranslation } from '@affine/i18n';
|
import { useTranslation } from '@affine/i18n';
|
||||||
import type { AccessTokenMessage } from '@affine/workspace/affine/login';
|
import type { AccessTokenMessage } from '@affine/workspace/affine/login';
|
||||||
import { CloudWorkspaceIcon, SignOutIcon } from '@blocksuite/icons';
|
import { CloudWorkspaceIcon, SignOutIcon } from '@blocksuite/icons';
|
||||||
|
import { useSetAtom } from 'jotai';
|
||||||
import type { CSSProperties } from 'react';
|
import type { CSSProperties } from 'react';
|
||||||
import type React from 'react';
|
import type React from 'react';
|
||||||
import { forwardRef } from 'react';
|
import { forwardRef } from 'react';
|
||||||
|
|
||||||
|
import { openDisableCloudAlertModalAtom } from '../../../atoms';
|
||||||
import { stringToColour } from '../../../utils';
|
import { stringToColour } from '../../../utils';
|
||||||
import { StyledFooter, StyledSignInButton, StyleUserInfo } from './styles';
|
import { StyledFooter, StyledSignInButton, StyleUserInfo } from './styles';
|
||||||
|
|
||||||
@@ -20,11 +22,7 @@ export type FooterProps = {
|
|||||||
|
|
||||||
export const Footer: React.FC<FooterProps> = ({ user, onLogin, onLogout }) => {
|
export const Footer: React.FC<FooterProps> = ({ user, onLogin, onLogout }) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const setOpen = useSetAtom(openDisableCloudAlertModalAtom);
|
||||||
if (!config.enableLegacyCloud) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledFooter data-testid="workspace-list-modal-footer">
|
<StyledFooter data-testid="workspace-list-modal-footer">
|
||||||
{user && (
|
{user && (
|
||||||
@@ -55,6 +53,7 @@ export const Footer: React.FC<FooterProps> = ({ user, onLogin, onLogout }) => {
|
|||||||
|
|
||||||
{!user && (
|
{!user && (
|
||||||
<StyledSignInButton
|
<StyledSignInButton
|
||||||
|
data-testid="sign-in-button"
|
||||||
noBorder
|
noBorder
|
||||||
bold
|
bold
|
||||||
icon={
|
icon={
|
||||||
@@ -63,7 +62,11 @@ export const Footer: React.FC<FooterProps> = ({ user, onLogin, onLogout }) => {
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
onLogin();
|
if (!config.enableLegacyCloud) {
|
||||||
|
setOpen(true);
|
||||||
|
} else {
|
||||||
|
onLogin();
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{t('Sign in')}
|
{t('Sign in')}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { lazy, Suspense, useCallback, useTransition } from 'react';
|
|||||||
import {
|
import {
|
||||||
currentWorkspaceIdAtom,
|
currentWorkspaceIdAtom,
|
||||||
openCreateWorkspaceModalAtom,
|
openCreateWorkspaceModalAtom,
|
||||||
|
openDisableCloudAlertModalAtom,
|
||||||
openWorkspacesModalAtom,
|
openWorkspacesModalAtom,
|
||||||
} from '../atoms';
|
} from '../atoms';
|
||||||
import { useAffineLogIn } from '../hooks/affine/use-affine-log-in';
|
import { useAffineLogIn } from '../hooks/affine/use-affine-log-in';
|
||||||
@@ -29,6 +30,14 @@ const CreateWorkspaceModal = lazy(() =>
|
|||||||
}))
|
}))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const TmpDisableAffineCloudModal = lazy(() =>
|
||||||
|
import('../components/affine/tmp-disable-affine-cloud-modal').then(
|
||||||
|
module => ({
|
||||||
|
default: module.TmpDisableAffineCloudModal,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
export function Modals() {
|
export function Modals() {
|
||||||
const [openWorkspacesModal, setOpenWorkspacesModal] = useAtom(
|
const [openWorkspacesModal, setOpenWorkspacesModal] = useAtom(
|
||||||
openWorkspacesModalAtom
|
openWorkspacesModalAtom
|
||||||
@@ -37,6 +46,10 @@ export function Modals() {
|
|||||||
openCreateWorkspaceModalAtom
|
openCreateWorkspaceModalAtom
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const [openDisableCloudAlertModal, setOpenDisableCloudAlertModal] = useAtom(
|
||||||
|
openDisableCloudAlertModalAtom
|
||||||
|
);
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { jumpToSubPath } = useRouterHelper(router);
|
const { jumpToSubPath } = useRouterHelper(router);
|
||||||
const user = useCurrentUser();
|
const user = useCurrentUser();
|
||||||
@@ -49,6 +62,14 @@ export function Modals() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
<Suspense>
|
||||||
|
<TmpDisableAffineCloudModal
|
||||||
|
open={openDisableCloudAlertModal}
|
||||||
|
onClose={useCallback(() => {
|
||||||
|
setOpenDisableCloudAlertModal(false);
|
||||||
|
}, [setOpenDisableCloudAlertModal])}
|
||||||
|
/>
|
||||||
|
</Suspense>
|
||||||
<Suspense>
|
<Suspense>
|
||||||
<WorkspaceListModal
|
<WorkspaceListModal
|
||||||
disabled={transitioning}
|
disabled={transitioning}
|
||||||
|
|||||||
Reference in New Issue
Block a user