chore(desktop): simplify code (#1146)

This commit is contained in:
Himself65
2023-02-20 23:15:40 -06:00
committed by GitHub
parent ed4d1e8bcd
commit edd8f347bc
13 changed files with 30 additions and 191 deletions

View File

@@ -1,80 +0,0 @@
import { Modal, ModalWrapper } from '@affine/component';
import { IconButton } from '@affine/component';
import { toast } from '@affine/component';
import { useTranslation } from '@affine/i18n';
import { useDataCenter } from '@affine/store';
import { useGlobalState } from '@affine/store';
import { CloseIcon } from '@blocksuite/icons';
import router from 'next/router';
import { useCallback, useState } from 'react';
import { Content, ContentTitle, Header, StyleButton, StyleTips } from './style';
interface EnableWorkspaceModalProps {
open: boolean;
onClose: () => void;
}
export const EnableWorkspaceModal = ({
open,
onClose,
}: EnableWorkspaceModalProps) => {
const { t } = useTranslation();
const login = useGlobalState(store => store.login);
const user = useGlobalState(store => store.user);
const dataCenter = useDataCenter();
const currentWorkspace = useGlobalState(
useCallback(store => store.currentDataCenterWorkspace, [])
);
const [loading, setLoading] = useState(false);
return (
<Modal open={open} onClose={onClose} data-testid="logout-modal">
<ModalWrapper width={560} height={292}>
<Header>
<IconButton
onClick={() => {
onClose();
}}
>
<CloseIcon />
</IconButton>
</Header>
<Content>
<ContentTitle>{t('Enable AFFiNE Cloud')}?</ContentTitle>
<StyleTips>{t('Enable AFFiNE Cloud Description')}</StyleTips>
{/* <StyleTips>{t('Retain local cached data')}</StyleTips> */}
<div>
<StyleButton
shape="round"
type="primary"
loading={loading}
onClick={async () => {
setLoading(true);
if (!user) {
await login();
}
if (currentWorkspace) {
const workspace = await dataCenter.enableWorkspaceCloud(
currentWorkspace
);
workspace &&
router.push(`/workspace/${workspace.id}/setting`);
toast(t('Enabled success'));
}
}}
>
{user ? t('Enable') : t('Sign in and Enable')}
</StyleButton>
<StyleButton
shape="round"
onClick={() => {
onClose();
}}
>
{t('Not now')}
</StyleButton>
</div>
</Content>
</ModalWrapper>
</Modal>
);
};

View File

@@ -1,39 +0,0 @@
import { Button, styled } from '@affine/component';
export const Header = styled('div')({
height: '44px',
display: 'flex',
flexDirection: 'row-reverse',
paddingRight: '10px',
paddingTop: '10px',
});
export const Content = styled('div')({
textAlign: 'center',
});
export const ContentTitle = styled('h1')({
fontSize: '20px',
lineHeight: '28px',
fontWeight: 600,
textAlign: 'center',
});
export const StyleTips = styled('div')(() => {
return {
userSelect: 'none',
width: '400px',
margin: 'auto',
marginBottom: '32px',
marginTop: '12px',
};
});
export const StyleButton = styled(Button)(() => {
return {
width: '284px',
display: 'block',
margin: 'auto',
marginTop: '16px',
};
});

View File

@@ -1,27 +0,0 @@
import {
CloudWorkspaceIcon as DefaultCloudWorkspaceIcon,
JoinedWorkspaceIcon as DefaultJoinedWorkspaceIcon,
LocalDataIcon as DefaultLocalDataIcon,
LocalWorkspaceIcon as DefaultLocalWorkspaceIcon,
PublishIcon as DefaultPublishIcon,
} from '@blocksuite/icons';
// Here are some icons with special color or size
export const JoinedWorkspaceIcon = () => {
return <DefaultJoinedWorkspaceIcon style={{ color: '#FF646B' }} />;
};
export const LocalWorkspaceIcon = () => {
return <DefaultLocalWorkspaceIcon style={{ color: '#FDBD32' }} />;
};
export const CloudWorkspaceIcon = () => {
return <DefaultCloudWorkspaceIcon style={{ color: '##60A5FA' }} />;
};
export const LocalDataIcon = () => {
return <DefaultLocalDataIcon style={{ color: '#62CD80' }} />;
};
export const PublishIcon = () => {
return <DefaultPublishIcon style={{ color: '##8699FF' }} />;
};

View File

@@ -1,4 +1,8 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
declare global {
interface Window {
__TAURI_ISOLATION_HOOK_: (payload: any) => any;
}
}
// tauri preload script can't have `export {}`
// @ts-ignore 'index.ts' cannot be compiled under '--isolatedModules' because it is considered a global script file. Add an import, export, or an empty 'export {}' statement to make it a module.ts(1208)
@@ -16,3 +20,5 @@ function setEnvironmentVariables() {
}
setEnvironmentVariables();
export {};

View File

@@ -1,7 +1,9 @@
declare global {
// eslint-disable-next-line no-var
var __editoVersion: unknown;
interface Window {
CLIENT_APP?: boolean;
__editoVersion?: string;
}
}