mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2026-01-27 06:50:48 -08:00
refactor: remove unused feature codeinjection
This commit is contained in:
parent
fd580c6462
commit
6114794732
10 changed files with 2 additions and 299 deletions
|
|
@ -1,123 +0,0 @@
|
|||
import React from 'react';
|
||||
|
||||
import Button from '@material-ui/core/Button';
|
||||
import FormControlLabel from '@material-ui/core/FormControlLabel';
|
||||
import Switch from '@material-ui/core/Switch';
|
||||
|
||||
import AceEditor from 'react-ace';
|
||||
|
||||
import 'ace-builds/src-noconflict/mode-css';
|
||||
import 'ace-builds/src-noconflict/mode-javascript';
|
||||
import 'ace-builds/src-noconflict/theme-github';
|
||||
import 'ace-builds/src-noconflict/theme-monokai';
|
||||
|
||||
import { WindowNames, WindowMeta } from '@services/windows/WindowProperties';
|
||||
|
||||
import connectComponent from '../../helpers/connect-component';
|
||||
|
||||
import { updateForm, save } from '../../state/dialog-code-injection/actions';
|
||||
|
||||
const styles = (theme: any) => ({
|
||||
root: {
|
||||
background: theme.palette.background.paper,
|
||||
height: '100vh',
|
||||
width: '100vw',
|
||||
padding: 0,
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
},
|
||||
|
||||
flexGrow: {
|
||||
flex: 1,
|
||||
},
|
||||
|
||||
actions: {
|
||||
borderTop: `1px solid ${theme.palette.divider}`,
|
||||
padding: theme.spacing(2),
|
||||
display: 'flex',
|
||||
},
|
||||
|
||||
actionsLeft: {
|
||||
flex: 1,
|
||||
},
|
||||
|
||||
button: {
|
||||
float: 'right',
|
||||
marginLeft: theme.spacing(1),
|
||||
},
|
||||
});
|
||||
|
||||
const getMode = (codeInjectionType: any) => {
|
||||
if (codeInjectionType === 'css') return 'css';
|
||||
if (codeInjectionType === 'js') return 'javascript';
|
||||
return '';
|
||||
};
|
||||
|
||||
interface OwnCodeInjectionProps {
|
||||
allowNodeInJsCodeInjection?: boolean;
|
||||
classes: any;
|
||||
code: string;
|
||||
onSave: (...arguments_: any[]) => any;
|
||||
onUpdateForm: (...arguments_: any[]) => any;
|
||||
shouldUseDarkColors: boolean;
|
||||
}
|
||||
|
||||
// @ts-expect-error ts-migrate(2456) FIXME: Type alias 'CodeInjectionProps' circularly referen... Remove this comment to see the full error message
|
||||
type CodeInjectionProps = OwnCodeInjectionProps & typeof CodeInjection.defaultProps;
|
||||
|
||||
// @ts-expect-error ts-migrate(7022) FIXME: 'CodeInjection' implicitly has type 'any' because ... Remove this comment to see the full error message
|
||||
const CodeInjection = ({ allowNodeInJsCodeInjection, classes, code, onSave, onUpdateForm, shouldUseDarkColors }: CodeInjectionProps) => {
|
||||
const { codeInjectionType } = window.meta as WindowMeta[WindowNames.codeInjection];
|
||||
return (
|
||||
<div className={classes.root}>
|
||||
<div className={classes.flexGrow}>
|
||||
<AceEditor
|
||||
mode={getMode(codeInjectionType)}
|
||||
theme={shouldUseDarkColors ? 'monokai' : 'github'}
|
||||
height="100%"
|
||||
width="100%"
|
||||
name="codeEditor"
|
||||
value={code}
|
||||
onChange={(value) => onUpdateForm({ code: value })}
|
||||
/>
|
||||
</div>
|
||||
<div className={classes.actions}>
|
||||
<div className={classes.actionsLeft}>
|
||||
{codeInjectionType === 'js' && (
|
||||
<FormControlLabel
|
||||
control={
|
||||
<Switch checked={allowNodeInJsCodeInjection} onChange={(e) => onUpdateForm({ allowNodeInJsCodeInjection: e.target.checked })} color="primary" />
|
||||
}
|
||||
label="Allow access to Node.JS & Electron APIs"
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
<div className={classes.actionsRight}>
|
||||
<Button color="primary" variant="contained" disableElevation className={classes.button} onClick={onSave}>
|
||||
Save
|
||||
</Button>
|
||||
<Button variant="contained" disableElevation className={classes.button} onClick={() => window.remote.closeCurrentWindow()}>
|
||||
Cancel
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
CodeInjection.defaultProps = {
|
||||
allowNodeInJsCodeInjection: false,
|
||||
};
|
||||
|
||||
const mapStateToProps = (state: any) => ({
|
||||
code: state.dialogCodeInjection.form.code || '',
|
||||
allowNodeInJsCodeInjection: state.dialogCodeInjection.form.allowNodeInJsCodeInjection,
|
||||
shouldUseDarkColors: state.general.shouldUseDarkColors,
|
||||
});
|
||||
|
||||
const actionCreators = {
|
||||
updateForm,
|
||||
save,
|
||||
};
|
||||
|
||||
export default connectComponent(CodeInjection, mapStateToProps, actionCreators, styles);
|
||||
|
|
@ -189,13 +189,11 @@ const getUpdaterDesc = (status: any, info: any) => {
|
|||
};
|
||||
|
||||
interface PreferencesProps {
|
||||
allowNodeInJsCodeInjection: boolean;
|
||||
allowPrerelease: boolean;
|
||||
askForDownloadPath: boolean;
|
||||
attachToMenubar: boolean;
|
||||
blockAds: boolean;
|
||||
classes: any;
|
||||
cssCodeInjection?: string;
|
||||
customUserAgent?: string;
|
||||
darkReader: boolean;
|
||||
darkReaderBrightness: number;
|
||||
|
|
@ -206,7 +204,6 @@ interface PreferencesProps {
|
|||
hibernateUnusedWorkspacesAtLaunch: boolean;
|
||||
hideMenuBar: boolean;
|
||||
ignoreCertificateErrors: boolean;
|
||||
jsCodeInjection?: string;
|
||||
navigationBar: boolean;
|
||||
openAtLogin: 'yes' | 'yes-hidden' | 'no';
|
||||
pauseNotificationsBySchedule: boolean;
|
||||
|
|
@ -231,13 +228,11 @@ interface PreferencesProps {
|
|||
}
|
||||
|
||||
const Preferences = ({
|
||||
allowNodeInJsCodeInjection,
|
||||
allowPrerelease,
|
||||
askForDownloadPath,
|
||||
attachToMenubar,
|
||||
blockAds,
|
||||
classes,
|
||||
cssCodeInjection,
|
||||
customUserAgent,
|
||||
darkReader,
|
||||
darkReaderBrightness,
|
||||
|
|
@ -248,7 +243,6 @@ const Preferences = ({
|
|||
hibernateUnusedWorkspacesAtLaunch,
|
||||
hideMenuBar,
|
||||
ignoreCertificateErrors,
|
||||
jsCodeInjection,
|
||||
navigationBar,
|
||||
openAtLogin,
|
||||
pauseNotificationsBySchedule,
|
||||
|
|
@ -1161,19 +1155,6 @@ const Preferences = ({
|
|||
<ListItemText primary="Custom User Agent" secondary={customUserAgent || 'Not set'} classes={{ secondary: classes.secondaryEllipsis }} />
|
||||
<ChevronRightIcon color="action" />
|
||||
</ListItem>
|
||||
<Divider />
|
||||
<ListItem button onClick={async () => await window.service.window.open(WindowNames.codeInjection, { codeInjectionType: 'js' })}>
|
||||
<ListItemText
|
||||
primary="JS Code Injection"
|
||||
secondary={jsCodeInjection ? `Set ${allowNodeInJsCodeInjection ? ' (with access to Node.JS & Electron APIs)' : ''}` : 'Not set'}
|
||||
/>
|
||||
<ChevronRightIcon color="action" />
|
||||
</ListItem>
|
||||
<Divider />
|
||||
<ListItem button onClick={async () => await window.service.window.open(WindowNames.codeInjection, { codeInjectionType: 'css' })}>
|
||||
<ListItemText primary="CSS Code Injection" secondary={cssCodeInjection ? 'Set' : 'Not set'} />
|
||||
<ChevronRightIcon color="action" />
|
||||
</ListItem>
|
||||
</List>
|
||||
</Paper>
|
||||
|
||||
|
|
@ -1182,7 +1163,7 @@ const Preferences = ({
|
|||
</Typography>
|
||||
<Paper elevation={0} className={classes.paper}>
|
||||
<List dense disablePadding>
|
||||
<ListItem button onClick={async async () => await window.service.native.open(await window.service.context.get('LOG_FOLDER'), true)}>
|
||||
<ListItem button onClick={async () => await window.service.native.open(await window.service.context.get('LOG_FOLDER'), true)}>
|
||||
<ListItemText primary={t('Preference.OpenLogFolder')} secondary={t('Preference.OpenLogFolderDetail')} />
|
||||
<ChevronRightIcon color="action" />
|
||||
</ListItem>
|
||||
|
|
@ -1360,48 +1341,3 @@ const Preferences = ({
|
|||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const mapStateToProps = (state: any) => ({
|
||||
allowNodeInJsCodeInjection: state.preferences.allowNodeInJsCodeInjection,
|
||||
allowPrerelease: state.preferences.allowPrerelease,
|
||||
askForDownloadPath: state.preferences.askForDownloadPath,
|
||||
attachToMenubar: state.preferences.attachToMenubar,
|
||||
blockAds: state.preferences.blockAds,
|
||||
cssCodeInjection: state.preferences.cssCodeInjection,
|
||||
customUserAgent: state.preferences.customUserAgent,
|
||||
darkReader: state.preferences.darkReader,
|
||||
darkReaderBrightness: state.preferences.darkReaderBrightness,
|
||||
darkReaderContrast: state.preferences.darkReaderContrast,
|
||||
darkReaderGrayscale: state.preferences.darkReaderGrayscale,
|
||||
darkReaderSepia: state.preferences.darkReaderSepia,
|
||||
downloadPath: state.preferences.downloadPath,
|
||||
hibernateUnusedWorkspacesAtLaunch: state.preferences.hibernateUnusedWorkspacesAtLaunch,
|
||||
hideMenuBar: state.preferences.hideMenuBar,
|
||||
ignoreCertificateErrors: state.preferences.ignoreCertificateErrors,
|
||||
isDefaultMailClient: state.general.isDefaultMailClient,
|
||||
isDefaultWebBrowser: state.general.isDefaultWebBrowser,
|
||||
jsCodeInjection: state.preferences.jsCodeInjection,
|
||||
navigationBar: state.preferences.navigationBar,
|
||||
openAtLogin: state.systemPreferences.openAtLogin,
|
||||
pauseNotificationsBySchedule: state.preferences.pauseNotificationsBySchedule,
|
||||
pauseNotificationsByScheduleFrom: state.preferences.pauseNotificationsByScheduleFrom,
|
||||
pauseNotificationsByScheduleTo: state.preferences.pauseNotificationsByScheduleTo,
|
||||
pauseNotificationsMuteAudio: state.preferences.pauseNotificationsMuteAudio,
|
||||
rememberLastPageVisited: state.preferences.rememberLastPageVisited,
|
||||
shareWorkspaceBrowsingData: state.preferences.shareWorkspaceBrowsingData,
|
||||
sidebar: state.preferences.sidebar,
|
||||
sidebarShortcutHints: state.preferences.sidebarShortcutHints,
|
||||
spellcheck: state.preferences.spellcheck,
|
||||
spellcheckLanguages: state.preferences.spellcheckLanguages,
|
||||
swipeToNavigate: state.preferences.swipeToNavigate,
|
||||
syncDebounceInterval: state.preferences.syncDebounceInterval,
|
||||
themeSource: state.preferences.themeSource,
|
||||
titleBar: state.preferences.titleBar,
|
||||
unreadCountBadge: state.preferences.unreadCountBadge,
|
||||
updaterInfo: state.updater.info,
|
||||
updaterStatus: state.updater.status,
|
||||
useHardwareAcceleration: state.preferences.useHardwareAcceleration,
|
||||
userName: state.preferences.userName,
|
||||
});
|
||||
|
||||
export default connectComponent(Preferences, mapStateToProps, undefined, styles);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue