Refactoring
This commit is contained in:
25
src/App.js
25
src/App.js
@@ -10,7 +10,6 @@ import Grid from './components/UI/Grid/Grid';
|
|||||||
import InfoDetails from './components/InfoDetails/InfoDetails';
|
import InfoDetails from './components/InfoDetails/InfoDetails';
|
||||||
import IPCContainer from './containers/IPCContainer/IPCContainer';
|
import IPCContainer from './containers/IPCContainer/IPCContainer';
|
||||||
import Loading from './components/UI/Loading/Loading';
|
import Loading from './components/UI/Loading/Loading';
|
||||||
import Modal from './components/UI/Modal/Modal';
|
|
||||||
import MountItems from './containers/MountItems/MountItems';
|
import MountItems from './containers/MountItems/MountItems';
|
||||||
import {notifyError} from './redux/actions/error_actions';
|
import {notifyError} from './redux/actions/error_actions';
|
||||||
import Reboot from './components/Reboot/Reboot';
|
import Reboot from './components/Reboot/Reboot';
|
||||||
@@ -28,6 +27,7 @@ import {
|
|||||||
setDismissUIUpgrade
|
setDismissUIUpgrade
|
||||||
} from './redux/actions/release_version_actions';
|
} from './redux/actions/release_version_actions';
|
||||||
import YesNo from './components/YesNo/YesNo';
|
import YesNo from './components/YesNo/YesNo';
|
||||||
|
import {createModalConditionally} from './utils';
|
||||||
|
|
||||||
const Constants = require('./constants');
|
const Constants = require('./constants');
|
||||||
const Scheduler = require('node-schedule');
|
const Scheduler = require('node-schedule');
|
||||||
@@ -66,11 +66,6 @@ class App extends IPCContainer {
|
|||||||
super.componentWillUnmount();
|
super.componentWillUnmount();
|
||||||
}
|
}
|
||||||
|
|
||||||
createModalConditionally = (condition, jsx, critical) => {
|
|
||||||
const modalProps = {critical: critical};
|
|
||||||
return condition ? (<Modal {...modalProps}>{jsx}</Modal>) : null;
|
|
||||||
};
|
|
||||||
|
|
||||||
getSelectedVersion = () => {
|
getSelectedVersion = () => {
|
||||||
return (this.props.ReleaseVersion === -1) ?
|
return (this.props.ReleaseVersion === -1) ?
|
||||||
'unavailable' :
|
'unavailable' :
|
||||||
@@ -126,15 +121,15 @@ class App extends IPCContainer {
|
|||||||
!this.props.DismissDependencies &&
|
!this.props.DismissDependencies &&
|
||||||
this.props.AllowMount;
|
this.props.AllowMount;
|
||||||
|
|
||||||
const configDisplay = this.createModalConditionally(showConfig, <Configuration version={selectedVersion} remoteSupported={remoteSupported} />);
|
const configDisplay = createModalConditionally(showConfig, <Configuration version={selectedVersion} remoteSupported={remoteSupported} />);
|
||||||
const confirmDisplay = this.createModalConditionally(this.props.DisplayConfirmYesNo, <YesNo/>);
|
const confirmDisplay = createModalConditionally(this.props.DisplayConfirmYesNo, <YesNo/>);
|
||||||
const dependencyDisplay = this.createModalConditionally(showDependencies, <DependencyList/>);
|
const dependencyDisplay = createModalConditionally(showDependencies, <DependencyList/>);
|
||||||
const downloadDisplay = this.createModalConditionally(this.props.DownloadActive, <DownloadProgress/>);
|
const downloadDisplay = createModalConditionally(this.props.DownloadActive, <DownloadProgress/>);
|
||||||
const errorDisplay = this.createModalConditionally(this.props.DisplayError, <ErrorDetails/>, true);
|
const errorDisplay = createModalConditionally(this.props.DisplayError, <ErrorDetails/>, true);
|
||||||
const infoDisplay = this.createModalConditionally(this.props.DisplayInfo, <InfoDetails/>, true);
|
const infoDisplay = createModalConditionally(this.props.DisplayInfo, <InfoDetails/>, true);
|
||||||
const rebootDisplay = this.createModalConditionally(this.props.RebootRequired, <Reboot />);
|
const rebootDisplay = createModalConditionally(this.props.RebootRequired, <Reboot />);
|
||||||
const selectAppPlatformDisplay = this.createModalConditionally(this.props.DisplaySelectAppPlatform, <SelectAppPlatform/>);
|
const selectAppPlatformDisplay = createModalConditionally(this.props.DisplaySelectAppPlatform, <SelectAppPlatform/>);
|
||||||
const upgradeDisplay = this.createModalConditionally(showUpgrade, <UpgradeUI/>);
|
const upgradeDisplay = createModalConditionally(showUpgrade, <UpgradeUI/>);
|
||||||
|
|
||||||
let mainContent = [];
|
let mainContent = [];
|
||||||
if (this.props.DisplaySelectAppPlatform || !this.props.AppReady) {
|
if (this.props.DisplaySelectAppPlatform || !this.props.AppReady) {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import Box from '../../components/UI/Box/Box';
|
|||||||
import Text from '../../components/UI/Text/Text';
|
import Text from '../../components/UI/Text/Text';
|
||||||
import {notifyError} from '../../redux/actions/error_actions';
|
import {notifyError} from '../../redux/actions/error_actions';
|
||||||
import {addRemoteMount} from '../../redux/actions/mount_actions';
|
import {addRemoteMount} from '../../redux/actions/mount_actions';
|
||||||
|
import {createModalConditionally} from '../../utils';
|
||||||
|
|
||||||
const mapStateToProps = state => {
|
const mapStateToProps = state => {
|
||||||
return {
|
return {
|
||||||
@@ -52,11 +53,6 @@ export default connect(mapStateToProps, mapDispatchToProps)(class extends Compon
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
createModalConditionally = (condition, jsx, critical) => {
|
|
||||||
const modalProps = {critical: critical};
|
|
||||||
return condition ? (<Modal {...modalProps}>{jsx}</Modal>) : null;
|
|
||||||
};
|
|
||||||
|
|
||||||
handleAddRemoteMount = () => {
|
handleAddRemoteMount = () => {
|
||||||
this.setState({
|
this.setState({
|
||||||
Display: true,
|
Display: true,
|
||||||
@@ -64,7 +60,7 @@ export default connect(mapStateToProps, mapDispatchToProps)(class extends Compon
|
|||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const displayAdd = this.createModalConditionally(this.state.Display, (
|
const displayAdd = createModalConditionally(this.state.Display, (
|
||||||
<Box dxDark
|
<Box dxDark
|
||||||
dxStyle={{width: 'auto', height: 'auto', padding: '8px'}}>
|
dxStyle={{width: 'auto', height: 'auto', padding: '8px'}}>
|
||||||
<h1 style={{color: 'var(--text_color_error)', textAlign: 'center', paddingBottom: '8px'}}>Add Remote Mount</h1>
|
<h1 style={{color: 'var(--text_color_error)', textAlign: 'center', paddingBottom: '8px'}}>Add Remote Mount</h1>
|
||||||
|
|||||||
@@ -1,9 +1,16 @@
|
|||||||
|
import React from 'react';
|
||||||
import * as Constants from './constants';
|
import * as Constants from './constants';
|
||||||
|
import Modal from './components/UI/Modal/Modal';
|
||||||
|
|
||||||
const ipcRenderer = (!process.versions.hasOwnProperty('electron') && window && window.require) ?
|
const ipcRenderer = (!process.versions.hasOwnProperty('electron') && window && window.require) ?
|
||||||
window.require('electron').ipcRenderer :
|
window.require('electron').ipcRenderer :
|
||||||
null;
|
null;
|
||||||
|
|
||||||
|
export const createModalConditionally = (condition, jsx, critical) => {
|
||||||
|
const modalProps = {critical: critical};
|
||||||
|
return condition ? (<Modal {...modalProps}>{jsx}</Modal>) : null;
|
||||||
|
};
|
||||||
|
|
||||||
export const extractFileNameFromURL = url => {
|
export const extractFileNameFromURL = url => {
|
||||||
const parts = url.split('/');
|
const parts = url.split('/');
|
||||||
return parts[parts.length - 1];
|
return parts[parts.length - 1];
|
||||||
|
|||||||
Reference in New Issue
Block a user