mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-11-24 03:26:31 +03:00
feat(electron): enable disable cloud alert (#2184)
This commit is contained in:
parent
70fbbb39c1
commit
73d5b2081a
@ -21,3 +21,21 @@ test('new page', async () => {
|
||||
expect(flavour).toBe('local');
|
||||
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 openQuickSearchModalAtom = atom(false);
|
||||
|
||||
export const openDisableCloudAlertModalAtom = atom(false);
|
||||
|
||||
export { workspacesAtom } from './root';
|
||||
|
||||
type View = { id: string; mode: 'page' | 'edgeless' };
|
||||
|
@ -21,7 +21,11 @@ export const TmpDisableAffineCloudModal: React.FC<
|
||||
TmpDisableAffineCloudModalProps
|
||||
> = ({ open, onClose }) => {
|
||||
return (
|
||||
<Modal open={open} onClose={onClose}>
|
||||
<Modal
|
||||
data-testid="disable-affine-cloud-modal"
|
||||
open={open}
|
||||
onClose={onClose}
|
||||
>
|
||||
<ModalWrapper width={480}>
|
||||
<Header>
|
||||
<IconButton
|
||||
@ -41,6 +45,9 @@ export const TmpDisableAffineCloudModal: React.FC<
|
||||
<a
|
||||
href="https://github.com/toeverything/AFFiNE/releases"
|
||||
target="_blank"
|
||||
style={{
|
||||
color: 'var(--affine-link-color)',
|
||||
}}
|
||||
>
|
||||
click here
|
||||
</a>
|
||||
|
@ -5,10 +5,12 @@ import { config } from '@affine/env';
|
||||
import { useTranslation } from '@affine/i18n';
|
||||
import type { AccessTokenMessage } from '@affine/workspace/affine/login';
|
||||
import { CloudWorkspaceIcon, SignOutIcon } from '@blocksuite/icons';
|
||||
import { useSetAtom } from 'jotai';
|
||||
import type { CSSProperties } from 'react';
|
||||
import type React from 'react';
|
||||
import { forwardRef } from 'react';
|
||||
|
||||
import { openDisableCloudAlertModalAtom } from '../../../atoms';
|
||||
import { stringToColour } from '../../../utils';
|
||||
import { StyledFooter, StyledSignInButton, StyleUserInfo } from './styles';
|
||||
|
||||
@ -20,11 +22,7 @@ export type FooterProps = {
|
||||
|
||||
export const Footer: React.FC<FooterProps> = ({ user, onLogin, onLogout }) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
if (!config.enableLegacyCloud) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const setOpen = useSetAtom(openDisableCloudAlertModalAtom);
|
||||
return (
|
||||
<StyledFooter data-testid="workspace-list-modal-footer">
|
||||
{user && (
|
||||
@ -55,6 +53,7 @@ export const Footer: React.FC<FooterProps> = ({ user, onLogin, onLogout }) => {
|
||||
|
||||
{!user && (
|
||||
<StyledSignInButton
|
||||
data-testid="sign-in-button"
|
||||
noBorder
|
||||
bold
|
||||
icon={
|
||||
@ -63,7 +62,11 @@ export const Footer: React.FC<FooterProps> = ({ user, onLogin, onLogout }) => {
|
||||
</div>
|
||||
}
|
||||
onClick={async () => {
|
||||
onLogin();
|
||||
if (!config.enableLegacyCloud) {
|
||||
setOpen(true);
|
||||
} else {
|
||||
onLogin();
|
||||
}
|
||||
}}
|
||||
>
|
||||
{t('Sign in')}
|
||||
|
@ -8,6 +8,7 @@ import { lazy, Suspense, useCallback, useTransition } from 'react';
|
||||
import {
|
||||
currentWorkspaceIdAtom,
|
||||
openCreateWorkspaceModalAtom,
|
||||
openDisableCloudAlertModalAtom,
|
||||
openWorkspacesModalAtom,
|
||||
} from '../atoms';
|
||||
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() {
|
||||
const [openWorkspacesModal, setOpenWorkspacesModal] = useAtom(
|
||||
openWorkspacesModalAtom
|
||||
@ -37,6 +46,10 @@ export function Modals() {
|
||||
openCreateWorkspaceModalAtom
|
||||
);
|
||||
|
||||
const [openDisableCloudAlertModal, setOpenDisableCloudAlertModal] = useAtom(
|
||||
openDisableCloudAlertModalAtom
|
||||
);
|
||||
|
||||
const router = useRouter();
|
||||
const { jumpToSubPath } = useRouterHelper(router);
|
||||
const user = useCurrentUser();
|
||||
@ -49,6 +62,14 @@ export function Modals() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<Suspense>
|
||||
<TmpDisableAffineCloudModal
|
||||
open={openDisableCloudAlertModal}
|
||||
onClose={useCallback(() => {
|
||||
setOpenDisableCloudAlertModal(false);
|
||||
}, [setOpenDisableCloudAlertModal])}
|
||||
/>
|
||||
</Suspense>
|
||||
<Suspense>
|
||||
<WorkspaceListModal
|
||||
disabled={transitioning}
|
||||
|
Loading…
Reference in New Issue
Block a user