PropTypes and refactoring

This commit is contained in:
2021-05-04 19:22:45 -05:00
parent 811f022229
commit ace51f61d1
30 changed files with 491 additions and 279 deletions

View File

@@ -25,9 +25,6 @@
"jest" "jest"
], ],
"rules": { "rules": {
"prettier/prettier": "warn", "prettier/prettier": "warn"
"react/prop-types": "warn",
"no-prototype-builtins": "warn",
"react/no-string-refs": "warn"
} }
} }

View File

@@ -262,7 +262,7 @@ class App extends IPCContainer {
col={0} col={0}
colSpan={'remain'} colSpan={'remain'}
row={10} row={10}
rowSpan={'17'} rowSpan={17}
key={'md_' + key++} key={'md_' + key++}
dxStyle={{ padding: 'var(--default_spacing)' }}> dxStyle={{ padding: 'var(--default_spacing)' }}>
<ReleaseVersionDisplay downloadDisabled={!downloadEnabled} version={selectedVersion} /> <ReleaseVersionDisplay downloadDisabled={!downloadEnabled} version={selectedVersion} />

View File

@@ -1,18 +1,10 @@
import React from 'react'; import React from 'react';
import './Dependency.css'; import './Dependency.css';
import { connect } from 'react-redux';
import * as Constants from '../../../constants'; import * as Constants from '../../../constants';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
const mapStateToProps = (state) => { const Dependency = (props) => {
return {
AllowDownload:
state.download.DownloadType !== Constants.INSTALL_TYPES.Dependency &&
!state.download.DownloadActive &&
!state.install.InstallActive,
};
};
export default connect(mapStateToProps)((props) => {
return ( return (
<div className={'Dependency'}> <div className={'Dependency'}>
<table width="100%"> <table width="100%">
@@ -41,4 +33,21 @@ export default connect(mapStateToProps)((props) => {
</table> </table>
</div> </div>
); );
}); };
const mapStateToProps = (state) => {
return {
AllowDownload:
state.download.DownloadType !== Constants.INSTALL_TYPES.Dependency &&
!state.download.DownloadActive &&
!state.install.InstallActive,
};
};
Dependency.propTypes = {
AllowDownload: PropTypes.bool,
name: PropTypes.string.isRequired,
onDownload: PropTypes.func.isRequired,
};
export default connect(mapStateToProps)(Dependency);

View File

@@ -1,32 +1,16 @@
import React from 'react'; import React from 'react';
import './DependencyList.css'; import './DependencyList.css';
import { connect } from 'react-redux';
import * as Constants from '../../constants'; import * as Constants from '../../constants';
import { createDismissDisplay } from '../../utils.jsx';
import Dependency from './Dependency/Dependency';
import Box from '../UI/Box/Box'; import Box from '../UI/Box/Box';
import Dependency from './Dependency/Dependency';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { createDismissDisplay } from '../../utils.jsx';
import { downloadItem } from '../../redux/actions/download_actions'; import { downloadItem } from '../../redux/actions/download_actions';
import { extractFileNameFromURL } from '../../utils.jsx'; import { extractFileNameFromURL } from '../../utils.jsx';
import { setDismissDependencies } from '../../redux/actions/install_actions'; import { setDismissDependencies } from '../../redux/actions/install_actions';
const mapStateToProps = (state) => { const DependencyList = (props) => {
return {
AllowDismissDependencies: state.relver.AllowDismissDependencies,
MissingDependencies: state.install.MissingDependencies,
};
};
const mapDispatchToProps = (dispatch) => {
return {
downloadItem: (name, type, url, isWinFSP) => dispatch(downloadItem(name, type, url, isWinFSP)),
setDismissDependencies: (dismiss) => dispatch(setDismissDependencies(dismiss)),
};
};
export default connect(
mapStateToProps,
mapDispatchToProps
)((props) => {
const items = props.MissingDependencies.map((k, i) => { const items = props.MissingDependencies.map((k, i) => {
return ( return (
<Dependency <Dependency
@@ -69,4 +53,27 @@ export default connect(
{items} {items}
</Box> </Box>
); );
}); };
const mapStateToProps = (state) => {
return {
AllowDismissDependencies: state.relver.AllowDismissDependencies,
MissingDependencies: state.install.MissingDependencies,
};
};
const mapDispatchToProps = (dispatch) => {
return {
downloadItem: (name, type, url, isWinFSP) => dispatch(downloadItem(name, type, url, isWinFSP)),
setDismissDependencies: (dismiss) => dispatch(setDismissDependencies(dismiss)),
};
};
DependencyList.propTypes = {
AllowDismissDependencies: PropTypes.bool,
MissingDependencies: PropTypes.array,
downloadItem: PropTypes.func.isRequired,
setDismissDependencies: PropTypes.func.isRequired,
};
export default connect(mapStateToProps, mapDispatchToProps)(DependencyList);

View File

@@ -1,17 +1,10 @@
import Box from '../UI/Box/Box'; import Box from '../UI/Box/Box';
import { connect } from 'react-redux';
import React from 'react';
import './DownloadProgress.css'; import './DownloadProgress.css';
import PropTypes from 'prop-types';
import React from 'react';
import { connect } from 'react-redux';
const mapStateToProps = (state) => { const DownloadProgress = (props) => {
return {
DownloadName: state.download.DownloadName,
DownloadProgress: state.download.DownloadProgress,
Platform: state.common.Platform,
};
};
export default connect(mapStateToProps)((props) => {
const width = props.Platform === 'linux' ? '480px' : '380px'; const width = props.Platform === 'linux' ? '480px' : '380px';
return ( return (
<Box dxStyle={{ width: width, height: 'auto', padding: '5px' }}> <Box dxStyle={{ width: width, height: 'auto', padding: '5px' }}>
@@ -28,4 +21,20 @@ export default connect(mapStateToProps)((props) => {
/> />
</Box> </Box>
); );
}); };
const mapStateToProps = (state) => {
return {
DownloadName: state.download.DownloadName,
DownloadProgress: state.download.DownloadProgress,
Platform: state.common.Platform,
};
};
DownloadProgress.propTypes = {
DownloadName: PropTypes.string.isRequired,
DownloadProgress: PropTypes.number,
Platform: PropTypes.string.isRequired,
};
export default connect(mapStateToProps)(DownloadProgress);

View File

@@ -1,9 +1,22 @@
import React from 'react'; import React from 'react';
import { dismissError } from '../../redux/actions/error_actions'; import './ErrorDetails.css';
import { connect } from 'react-redux';
import Box from '../UI/Box/Box'; import Box from '../UI/Box/Box';
import Button from '../UI/Button/Button'; import Button from '../UI/Button/Button';
import './ErrorDetails.css'; import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { dismissError } from '../../redux/actions/error_actions';
const ErrorDetails = (props) => {
return (
<Box dxDark dxStyle={{ padding: 'var(--default_spacing)' }}>
<h1 className={'ErrorDetailsHeading'}>Application Error</h1>
<div className={'ErrorDetailsContent'}>
<p>{props.ErrorMessage}</p>
</div>
<Button clicked={props.dismissError}>Dismiss</Button>
</Box>
);
};
const mapStateToProps = (state) => { const mapStateToProps = (state) => {
return { return {
@@ -17,17 +30,9 @@ const mapDispatchToProps = (dispatch) => {
}; };
}; };
export default connect( ErrorDetails.propTypes = {
mapStateToProps, ErrorMessage: PropTypes.string.isRequired,
mapDispatchToProps dismissError: PropTypes.func.isRequired,
)((props) => { };
return (
<Box dxDark dxStyle={{ padding: 'var(--default_spacing)' }}> export default connect(mapStateToProps, mapDispatchToProps)(ErrorDetails);
<h1 className={'ErrorDetailsHeading'}>Application Error</h1>
<div className={'ErrorDetailsContent'}>
<p>{props.ErrorMessage}</p>
</div>
<Button clicked={props.dismissError}>Dismiss</Button>
</Box>
);
});

View File

@@ -1,28 +1,13 @@
import React from 'react'; import React from 'react';
import { dismissInfo, notifyError } from '../../redux/actions/error_actions'; import './InfoDetails.css';
import { connect } from 'react-redux';
import Box from '../UI/Box/Box'; import Box from '../UI/Box/Box';
import Button from '../UI/Button/Button'; import Button from '../UI/Button/Button';
import './InfoDetails.css'; import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { dismissInfo, notifyError } from '../../redux/actions/error_actions';
import { promptLocationAndSaveFile } from '../../utils'; import { promptLocationAndSaveFile } from '../../utils';
const mapStateToProps = (state) => { const InfoDetails = (props) => {
return {
InfoMessage: state.error.InfoStack.length > 0 ? state.error.InfoStack[0] : '',
};
};
const mapDispatchToProps = (dispatch) => {
return {
notifyError: (msg) => dispatch(notifyError(msg)),
dismissInfo: () => dispatch(dismissInfo()),
};
};
export default connect(
mapStateToProps,
mapDispatchToProps
)((props) => {
let msg = props.InfoMessage.message; let msg = props.InfoMessage.message;
const classes = ['InfoDetailsContent']; const classes = ['InfoDetailsContent'];
@@ -90,4 +75,25 @@ export default connect(
)} )}
</Box> </Box>
); );
}); };
const mapStateToProps = (state) => {
return {
InfoMessage: state.error.InfoStack.length > 0 ? state.error.InfoStack[0] : '',
};
};
const mapDispatchToProps = (dispatch) => {
return {
notifyError: (msg) => dispatch(notifyError(msg)),
dismissInfo: () => dispatch(dismissInfo()),
};
};
InfoDetails.propTypes = {
InfoMessage: PropTypes.object.isRequired,
dismissInfo: PropTypes.func.isRequired,
notifyError: PropTypes.func.isRequired,
};
export default connect(mapStateToProps, mapDispatchToProps)(InfoDetails);

View File

@@ -1,33 +1,14 @@
import React from 'react'; import React from 'react';
import { connect } from 'react-redux';
import * as Constants from '../../../constants'; import * as Constants from '../../../constants';
import Button from '../../UI/Button/Button'; import Button from '../../UI/Button/Button';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { formatLinesForDisplay, getChangesForRepertoryVersion } from '../../../utils.jsx'; import { formatLinesForDisplay, getChangesForRepertoryVersion } from '../../../utils.jsx';
import { notifyError, notifyInfo } from '../../../redux/actions/error_actions'; import { notifyError, notifyInfo } from '../../../redux/actions/error_actions';
import { setActiveRelease } from '../../../redux/actions/release_version_actions'; import { setActiveRelease } from '../../../redux/actions/release_version_actions';
import { unmountAll } from '../../../redux/actions/mount_actions'; import { unmountAll } from '../../../redux/actions/mount_actions';
const mapStateToProps = (state) => { const NewRelease = ({
return {
ActiveRelease: state.relver.Release,
ActiveVersion: state.relver.Version,
};
};
const mapDispatchToProps = (dispatch) => {
return {
setActiveRelease: (release, version) => dispatch(setActiveRelease(release, version)),
notifyError: (msg) => dispatch(notifyError(msg)),
notifyInfo: (title, msg) => dispatch(notifyInfo(title, msg)),
unmountAll: (completedCallback) => dispatch(unmountAll(completedCallback)),
};
};
export default connect(
mapStateToProps,
mapDispatchToProps
)(
({
ActiveRelease, ActiveRelease,
ActiveVersion, ActiveVersion,
dismiss, dismiss,
@@ -37,7 +18,7 @@ export default connect(
notifyInfo, notifyInfo,
setActiveRelease, setActiveRelease,
unmountAll, unmountAll,
}) => { }) => {
const title = '[' + Constants.RELEASE_TYPES[release.Release] + '] ' + release.Display; const title = '[' + Constants.RELEASE_TYPES[release.Release] + '] ' + release.Display;
const displayChanges = async () => { const displayChanges = async () => {
try { try {
@@ -84,5 +65,34 @@ export default connect(
</table> </table>
</div> </div>
); );
} };
);
const mapStateToProps = (state) => {
return {
ActiveRelease: state.relver.Release,
ActiveVersion: state.relver.Version,
};
};
const mapDispatchToProps = (dispatch) => {
return {
setActiveRelease: (release, version) => dispatch(setActiveRelease(release, version)),
notifyError: (msg) => dispatch(notifyError(msg)),
notifyInfo: (title, msg) => dispatch(notifyInfo(title, msg)),
unmountAll: (completedCallback) => dispatch(unmountAll(completedCallback)),
};
};
NewRelease.propTypes = {
ActiveRelease: PropTypes.number.isRequired,
ActiveVersion: PropTypes.number.isRequired,
dismiss: PropTypes.func.isRequired,
lastItem: PropTypes.bool.isRequired,
notifyError: PropTypes.func.isRequired,
notifyInfo: PropTypes.func.isRequired,
release: PropTypes.object.isRequired,
setActiveRelease: PropTypes.func.isRequired,
unmountAll: PropTypes.func.isRequired,
};
export default connect(mapStateToProps, mapDispatchToProps)(NewRelease);

View File

@@ -1,27 +1,13 @@
import React from 'react'; import React from 'react';
import { connect } from 'react-redux'; import './NewReleases.css';
import Box from '../UI/Box/Box'; import Box from '../UI/Box/Box';
import Button from '../UI/Button/Button'; import Button from '../UI/Button/Button';
import NewRelease from './NewRelease/NewRelease.jsx'; import NewRelease from './NewRelease/NewRelease.jsx';
import './NewReleases.css'; import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { setDismissNewReleasesAvailable } from '../../redux/actions/release_version_actions'; import { setDismissNewReleasesAvailable } from '../../redux/actions/release_version_actions';
const mapStateToProps = (state) => { const NewReleases = (props) => {
return {
NewReleasesAvailable: state.relver.NewReleasesAvailable,
};
};
const mapDispatchToProps = (dispatch) => {
return {
dismissNewReleasesAvailable: () => dispatch(setDismissNewReleasesAvailable(true)),
};
};
export default connect(
mapStateToProps,
mapDispatchToProps
)((props) => {
const newReleases = props.NewReleasesAvailable.map((i, idx) => { const newReleases = props.NewReleasesAvailable.map((i, idx) => {
return ( return (
<NewRelease <NewRelease
@@ -40,4 +26,23 @@ export default connect(
<Button clicked={props.dismissNewReleasesAvailable}>Dismiss</Button> <Button clicked={props.dismissNewReleasesAvailable}>Dismiss</Button>
</Box> </Box>
); );
}); };
const mapStateToProps = (state) => {
return {
NewReleasesAvailable: state.relver.NewReleasesAvailable,
};
};
const mapDispatchToProps = (dispatch) => {
return {
dismissNewReleasesAvailable: () => dispatch(setDismissNewReleasesAvailable(true)),
};
};
NewReleases.propTypes = {
NewReleasesAvailable: PropTypes.array.isRequired,
dismissNewReleasesAvailable: PropTypes.func.isRequired,
};
export default connect(mapStateToProps, mapDispatchToProps)(NewReleases);

View File

@@ -1,20 +1,12 @@
import React from 'react'; import React from 'react';
import './Reboot.css'; import './Reboot.css';
import { connect } from 'react-redux';
import Box from '../UI/Box/Box'; import Box from '../UI/Box/Box';
import Button from '../UI/Button/Button'; import Button from '../UI/Button/Button';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { rebootSystem } from '../../redux/actions/common_actions'; import { rebootSystem } from '../../redux/actions/common_actions';
const mapDispatchToProps = (dispatch) => { const Reboot = (props) => {
return {
rebootSystem: () => dispatch(rebootSystem()),
};
};
export default connect(
null,
mapDispatchToProps
)((props) => {
return ( return (
<Box dxDark dxStyle={{ padding: 'var(--default_spacing)' }}> <Box dxDark dxStyle={{ padding: 'var(--default_spacing)' }}>
<h1 className={'RebootHeading'}>Reboot System</h1> <h1 className={'RebootHeading'}>Reboot System</h1>
@@ -24,4 +16,16 @@ export default connect(
<Button clicked={() => props.rebootSystem()}>Reboot Now</Button> <Button clicked={() => props.rebootSystem()}>Reboot Now</Button>
</Box> </Box>
); );
}); };
const mapDispatchToProps = (dispatch) => {
return {
rebootSystem: () => dispatch(rebootSystem()),
};
};
Reboot.propTypes = {
rebootSystem: PropTypes.func.isRequired,
};
export default connect(null, mapDispatchToProps)(Reboot);

View File

@@ -1,44 +1,17 @@
import React from 'react'; import React from 'react';
import './ReleaseVersionDisplay.css'; import './ReleaseVersionDisplay.css';
import * as Constants from '../../constants'; import * as Constants from '../../constants';
import { connect } from 'react-redux'; import Button from '../UI/Button/Button';
import DropDown from '../UI/DropDown/DropDown'; import DropDown from '../UI/DropDown/DropDown';
import Grid from '../UI/Grid/Grid'; import Grid from '../UI/Grid/Grid';
import PropTypes from 'prop-types';
import Text from '../UI/Text/Text'; import Text from '../UI/Text/Text';
import Button from '../UI/Button/Button';
import UpgradeIcon from '../UpgradeIcon/UpgradeIcon'; import UpgradeIcon from '../UpgradeIcon/UpgradeIcon';
import { setActiveRelease } from '../../redux/actions/release_version_actions'; import { connect } from 'react-redux';
import { downloadItem } from '../../redux/actions/download_actions'; import { downloadItem } from '../../redux/actions/download_actions';
import { setActiveRelease } from '../../redux/actions/release_version_actions';
const mapStateToProps = (state) => { const ReleaseVersionDisplay = (props) => {
return {
AllowMount: state.common.AllowMount,
AppPlatform: state.common.AppPlatform,
DismissDependencies: state.install.DismissDependencies,
DownloadActive: state.download.DownloadActive,
InstallActive: state.install.InstallActive,
InstallType: state.install.InstallType,
InstalledVersion: state.relver.InstalledVersion,
LocationsLookup: state.relver.LocationsLookup,
MountsBusy: state.mounts.MountsBusy,
Release: state.relver.Release,
ReleaseUpgradeAvailable: state.relver.ReleaseUpgradeAvailable,
ReleaseVersion: state.relver.Version,
VersionLookup: state.relver.VersionLookup,
};
};
const mapDispatchToProps = (dispatch) => {
return {
downloadItem: (name, type, urls) => dispatch(downloadItem(name, type, urls)),
setActiveRelease: (release, version) => dispatch(setActiveRelease(release, version)),
};
};
export default connect(
mapStateToProps,
mapDispatchToProps
)((props) => {
const getSelectedVersion = () => { const getSelectedVersion = () => {
return props.ReleaseVersion === -1 return props.ReleaseVersion === -1
? 'unavailable' ? 'unavailable'
@@ -184,4 +157,51 @@ export default connect(
{optionsDisplay} {optionsDisplay}
</Grid> </Grid>
); );
}); };
const mapStateToProps = (state) => {
return {
AllowMount: state.common.AllowMount,
AppPlatform: state.common.AppPlatform,
DismissDependencies: state.install.DismissDependencies,
DownloadActive: state.download.DownloadActive,
InstallActive: state.install.InstallActive,
InstallType: state.install.InstallType,
InstalledVersion: state.relver.InstalledVersion,
LocationsLookup: state.relver.LocationsLookup,
MountsBusy: state.mounts.MountsBusy,
Release: state.relver.Release,
ReleaseUpgradeAvailable: state.relver.ReleaseUpgradeAvailable,
ReleaseVersion: state.relver.Version,
VersionLookup: state.relver.VersionLookup,
};
};
const mapDispatchToProps = (dispatch) => {
return {
downloadItem: (name, type, urls) => dispatch(downloadItem(name, type, urls)),
setActiveRelease: (release, version) => dispatch(setActiveRelease(release, version)),
};
};
ReleaseVersionDisplay.propTypes = {
AllowMount: PropTypes.bool,
AppPlatform: PropTypes.string.isRequired,
DismissDependencies: PropTypes.bool.isRequired,
DownloadActive: PropTypes.bool,
InstallActive: PropTypes.bool,
InstallType: PropTypes.string,
InstalledVersion: PropTypes.string,
LocationsLookup: PropTypes.object.isRequired,
MountsBusy: PropTypes.bool,
Release: PropTypes.number.isRequired,
ReleaseUpgradeAvailable: PropTypes.bool,
ReleaseVersion: PropTypes.number.isRequired,
VersionLookup: PropTypes.object.isRequired,
downloadDisabled: PropTypes.bool,
downloadItem: PropTypes.func.isRequired,
setActiveRelease: PropTypes.func.isRequired,
version: PropTypes.string.isRequired,
};
export default connect(mapStateToProps, mapDispatchToProps)(ReleaseVersionDisplay);

View File

@@ -1,5 +1,6 @@
import React from 'react'; import React from 'react';
import './Box.css'; import './Box.css';
import PropTypes from 'prop-types';
const Box = (props) => { const Box = (props) => {
const styleList = []; const styleList = [];
@@ -23,4 +24,14 @@ const Box = (props) => {
); );
}; };
Box.propTypes = {
children: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
clicked: PropTypes.func,
dxDark: PropTypes.bool,
dxFadeIn: PropTypes.bool,
dxSlideOut: PropTypes.bool,
dxSlideOutTop: PropTypes.bool,
dxStyle: PropTypes.object,
};
export default Box; export default Box;

View File

@@ -1,5 +1,6 @@
import React from 'react'; import React from 'react';
import './Button.css'; import './Button.css';
import PropTypes from 'prop-types';
const Button = (props) => { const Button = (props) => {
return ( return (
@@ -14,4 +15,12 @@ const Button = (props) => {
); );
}; };
Button.propTypes = {
children: PropTypes.oneOfType([PropTypes.object, PropTypes.array, PropTypes.string]),
autoFocus: PropTypes.bool,
buttonStyles: PropTypes.object,
clicked: PropTypes.func,
disabled: PropTypes.bool,
};
export default Button; export default Button;

View File

@@ -1,5 +1,6 @@
import React from 'react'; import React from 'react';
import './CheckBox.css'; import './CheckBox.css';
import PropTypes from 'prop-types';
const CheckBox = (props) => { const CheckBox = (props) => {
return ( return (
@@ -19,4 +20,12 @@ const CheckBox = (props) => {
); );
}; };
CheckBox.propTypes = {
autoFocus: PropTypes.bool,
checked: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
disabled: PropTypes.bool,
label: PropTypes.string,
changed: PropTypes.func,
};
export default CheckBox; export default CheckBox;

View File

@@ -1,5 +1,6 @@
import React from 'react'; import React from 'react';
import './DropDown.css'; import './DropDown.css';
import PropTypes from 'prop-types';
const DropDown = (props) => { const DropDown = (props) => {
const options = props.items.map((s, i) => { const options = props.items.map((s, i) => {
@@ -24,4 +25,14 @@ const DropDown = (props) => {
); );
}; };
DropDown.propTypes = {
alt: PropTypes.bool,
auto: PropTypes.bool,
autoFocus: PropTypes.bool,
changed: PropTypes.func,
disabled: PropTypes.bool,
items: PropTypes.array,
selected: PropTypes.string,
};
export default DropDown; export default DropDown;

View File

@@ -1,10 +1,16 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import './Grid.css'; import './Grid.css';
import GridComponent from './GridComponent/GridComponent'; import GridComponent from './GridComponent/GridComponent';
import PropTypes from 'prop-types';
const DEFAULT_GRID_SIZE = 4; const DEFAULT_GRID_SIZE = 4;
export default class Grid extends Component { class Grid extends Component {
constructor(props) {
super(props);
this.sizeRef = React.createRef();
}
resizeTimeout; resizeTimeout;
state = { state = {
calculated: false, calculated: false,
@@ -40,7 +46,7 @@ export default class Grid extends Component {
}; };
getSize = () => { getSize = () => {
const elem = this.refs.GridOwner; const elem = this.sizeRef.current;
return { return {
height: elem ? elem.offsetHeight : 0, height: elem ? elem.offsetHeight : 0,
width: elem ? elem.offsetWidth : 0, width: elem ? elem.offsetWidth : 0,
@@ -128,7 +134,7 @@ export default class Grid extends Component {
} }
return ( return (
<div ref="GridOwner" className={'GridOwner'}> <div ref={this.sizeRef} className={'GridOwner'}>
<div className={'Grid'} {...style}> <div className={'Grid'} {...style}>
{children} {children}
</div> </div>
@@ -136,3 +142,11 @@ export default class Grid extends Component {
); );
} }
} }
Grid.propTypes = {
children: PropTypes.oneOfType([PropTypes.object, PropTypes.array, PropTypes.string]),
gridSize: PropTypes.number,
noScroll: PropTypes.bool,
};
export default Grid;

View File

@@ -1,5 +1,6 @@
import React from 'react'; import React from 'react';
import './GridComponent.css'; import './GridComponent.css';
import PropTypes from 'prop-types';
const GridComponent = (props) => { const GridComponent = (props) => {
const style = { const style = {
@@ -18,4 +19,12 @@ const GridComponent = (props) => {
); );
}; };
GridComponent.propTypes = {
children: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
col: PropTypes.number.isRequired,
colSpan: PropTypes.number,
row: PropTypes.number.isRequired,
rowSpan: PropTypes.number,
};
export default GridComponent; export default GridComponent;

View File

@@ -1,7 +1,7 @@
import React from 'react'; import React from 'react';
import './Modal.css'; import './Modal.css';
import FocusTrap from 'focus-trap-react'; import FocusTrap from 'focus-trap-react';
import PropTypes from 'prop-types';
const Modal = (props) => { const Modal = (props) => {
let modalStyles = []; let modalStyles = [];
@@ -26,4 +26,12 @@ const Modal = (props) => {
); );
}; };
Modal.propTypes = {
children: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
clicked: PropTypes.func,
critical: PropTypes.bool,
disableFocusTrap: PropTypes.bool,
transparent: PropTypes.bool,
};
export default Modal; export default Modal;

View File

@@ -1,4 +1,5 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types';
const RootElem = (props) => { const RootElem = (props) => {
return ( return (
@@ -8,4 +9,8 @@ const RootElem = (props) => {
); );
}; };
RootElem.propTypes = {
children: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
};
export default RootElem; export default RootElem;

View File

@@ -1,5 +1,6 @@
import React from 'react';
import './Text.css'; import './Text.css';
import PropTypes from 'prop-types';
import React from 'react';
const Text = (props) => { const Text = (props) => {
const styleList = []; const styleList = [];
@@ -22,4 +23,12 @@ const Text = (props) => {
return props.noOwner ? text : <div className={'TextOwner'}>{text}</div>; return props.noOwner ? text : <div className={'TextOwner'}>{text}</div>;
}; };
Text.propTypes = {
noOwner: PropTypes.bool,
style: PropTypes.object,
text: PropTypes.string,
textAlign: PropTypes.string,
type: PropTypes.string,
};
export default Text; export default Text;

View File

@@ -1,9 +1,9 @@
import './UpgradeIcon.css'; import './UpgradeIcon.css';
import PropTypes from 'prop-types';
import { faExclamationTriangle } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import React from 'react'; import React from 'react';
import ReactTooltip from 'react-tooltip'; import ReactTooltip from 'react-tooltip';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faExclamationTriangle } from '@fortawesome/free-solid-svg-icons';
const UpgradeIcon = (props) => { const UpgradeIcon = (props) => {
const styles = ['UpgradeIcon']; const styles = ['UpgradeIcon'];
@@ -32,4 +32,11 @@ const UpgradeIcon = (props) => {
) : null; ) : null;
}; };
UpgradeIcon.propTypes = {
available: PropTypes.bool,
clicked: PropTypes.func,
newReleases: PropTypes.bool,
release: PropTypes.bool,
};
export default UpgradeIcon; export default UpgradeIcon;

View File

@@ -1,31 +1,14 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import Button from '../UI/Button/Button';
import Box from '../UI/Box/Box';
import * as Constants from '../../constants';
import React from 'react';
import './UpgradeUI.css'; import './UpgradeUI.css';
import { setDismissUIUpgrade } from '../../redux/actions/release_version_actions'; import * as Constants from '../../constants';
import Box from '../UI/Box/Box';
import Button from '../UI/Button/Button';
import PropTypes from 'prop-types';
import React from 'react';
import { downloadItem } from '../../redux/actions/download_actions'; import { downloadItem } from '../../redux/actions/download_actions';
import { setDismissUIUpgrade } from '../../redux/actions/release_version_actions';
const mapStateToProps = (state) => { const UpgradeUI = (props) => {
return {
Platform: state.common.Platform,
UpgradeData: state.relver.UpgradeData,
UpgradeVersion: state.relver.UpgradeVersion,
};
};
const mapDispatchToProps = (dispatch) => {
return {
downloadItem: (name, type, urls) => dispatch(downloadItem(name, type, urls)),
setDismissUIUpgrade: (dismiss) => dispatch(setDismissUIUpgrade(dismiss)),
};
};
export default connect(
mapStateToProps,
mapDispatchToProps
)((props) => {
const handleDownload = () => { const handleDownload = () => {
const name = const name =
props.Platform === 'win32' props.Platform === 'win32'
@@ -61,4 +44,29 @@ export default connect(
</table> </table>
</Box> </Box>
); );
}); };
const mapStateToProps = (state) => {
return {
Platform: state.common.Platform,
UpgradeData: state.relver.UpgradeData,
UpgradeVersion: state.relver.UpgradeVersion,
};
};
const mapDispatchToProps = (dispatch) => {
return {
downloadItem: (name, type, urls) => dispatch(downloadItem(name, type, urls)),
setDismissUIUpgrade: (dismiss) => dispatch(setDismissUIUpgrade(dismiss)),
};
};
UpgradeUI.propTypes = {
Platform: PropTypes.string.isRequired,
UpgradeData: PropTypes.object.isRequired,
UpgradeVersion: PropTypes.string.isRequired,
downloadItem: PropTypes.func.isRequired,
setDismissUIUpgrade: PropTypes.func.isRequired,
};
export default connect(mapStateToProps, mapDispatchToProps)(UpgradeUI);

View File

@@ -1,26 +1,12 @@
import { connect } from 'react-redux';
import Button from '../UI/Button/Button';
import Box from '../UI/Box/Box';
import React from 'react'; import React from 'react';
import './YesNo.css'; import './YesNo.css';
import Box from '../UI/Box/Box';
import Button from '../UI/Button/Button';
import PropTypes from 'prop-types';
import { confirmYesNoAction } from '../../redux/actions/common_actions'; import { confirmYesNoAction } from '../../redux/actions/common_actions';
import { connect } from 'react-redux';
const mapStateToProps = (state) => { const YesNo = (props) => {
return {
Title: state.common.ConfirmTitle,
};
};
const mapDispatchToProps = (dispatch) => {
return {
confirm: (confirmed) => dispatch(confirmYesNoAction.complete(confirmed)),
};
};
export default connect(
mapStateToProps,
mapDispatchToProps
)((props) => {
return ( return (
<Box <Box
dxStyle={{ dxStyle={{
@@ -49,4 +35,23 @@ export default connect(
</table> </table>
</Box> </Box>
); );
}); };
const mapStateToProps = (state) => {
return {
Title: state.common.ConfirmTitle,
};
};
const mapDispatchToProps = (dispatch) => {
return {
confirm: (confirmed) => dispatch(confirmYesNoAction.complete(confirmed)),
};
};
YesNo.propTypes = {
Title: PropTypes.string.isRequired,
confirm: PropTypes.func.isRequired,
};
export default connect(mapStateToProps, mapDispatchToProps)(YesNo);

View File

@@ -1,15 +1,16 @@
import React from 'react'; import React from 'react';
import './Configuration.css'; import './Configuration.css';
import { connect } from 'react-redux';
import { createDismissDisplay } from '../../utils.jsx';
import Box from '../../components/UI/Box/Box'; import Box from '../../components/UI/Box/Box';
import Button from '../../components/UI/Button/Button'; import Button from '../../components/UI/Button/Button';
import ConfigurationItem from './ConfigurationItem/ConfigurationItem'; import ConfigurationItem from './ConfigurationItem/ConfigurationItem';
import Modal from '../../components/UI/Modal/Modal';
import IPCContainer from '../IPCContainer/IPCContainer'; import IPCContainer from '../IPCContainer/IPCContainer';
import Modal from '../../components/UI/Modal/Modal';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { createDismissDisplay } from '../../utils.jsx';
import { displayConfiguration } from '../../redux/actions/mount_actions'; import { displayConfiguration } from '../../redux/actions/mount_actions';
import { notifyError } from '../../redux/actions/error_actions';
import { displayPinnedManager } from '../../redux/actions/pinned_manager_actions'; import { displayPinnedManager } from '../../redux/actions/pinned_manager_actions';
import { notifyError } from '../../redux/actions/error_actions';
const Constants = require('../../constants'); const Constants = require('../../constants');
@@ -455,4 +456,15 @@ const mapDispatchToProps = (dispatch) => {
}; };
}; };
Configuration.propTypes = {
displayPinnedManager: PropTypes.func.isRequired,
DisplayConfiguration: PropTypes.string.isRequired,
hideConfiguration: PropTypes.func.isRequired,
remoteSupported: PropTypes.bool.isRequired,
notifyError: PropTypes.func.isRequired,
MState: PropTypes.object.isRequired,
Platform: PropTypes.string.isRequired,
version: PropTypes.string.isRequired,
};
export default connect(mapStateToProps, mapDispatchToProps)(Configuration); export default connect(mapStateToProps, mapDispatchToProps)(Configuration);

View File

@@ -9,7 +9,7 @@ export default class IPCContainer extends Component {
componentWillUnmount() { componentWillUnmount() {
if (ipcRenderer) { if (ipcRenderer) {
for (let name in this.handlerList) { for (let name in this.handlerList) {
if (this.handlerList.hasOwnProperty(name)) { if (Object.prototype.hasOwnProperty.call(this.handlerList, name)) {
ipcRenderer.removeListener(name, this.handlerList[name]); ipcRenderer.removeListener(name, this.handlerList[name]);
} }
} }

View File

@@ -68,7 +68,7 @@ class MountItems extends IPCContainer {
componentWillUnmount() { componentWillUnmount() {
for (const provider in this.state.RetryItems) { for (const provider in this.state.RetryItems) {
if (this.state.RetryItems.hasOwnProperty(provider)) { if (Object.prototype.hasOwnProperty.call(this.state.RetryItems, provider)) {
this.cancelRetryMount(provider); this.cancelRetryMount(provider);
} }
} }
@@ -387,7 +387,7 @@ class MountItems extends IPCContainer {
let retryList = []; let retryList = [];
let retryCount = 0; let retryCount = 0;
for (const provider in this.state.RetryItems) { for (const provider in this.state.RetryItems) {
if (this.state.RetryItems.hasOwnProperty(provider)) { if (Object.prototype.hasOwnProperty.call(this.state.RetryItems, provider)) {
if (this.state.RetryItems[provider].RetryMessage) { if (this.state.RetryItems[provider].RetryMessage) {
retryList.push( retryList.push(
<p key={'rl_' + retryList.length}>{this.state.RetryItems[provider].RetryMessage}</p> <p key={'rl_' + retryList.length}>{this.state.RetryItems[provider].RetryMessage}</p>

View File

@@ -1,5 +1,6 @@
import React from 'react'; import React from 'react';
import './Import.css'; import './Import.css';
import PropTypes from 'prop-types';
const Import = ({ data }) => { const Import = ({ data }) => {
return ( return (
@@ -35,4 +36,8 @@ const Import = ({ data }) => {
); );
}; };
Import.propTypes = {
data: PropTypes.object,
};
export default Import; export default Import;

View File

@@ -1,6 +1,7 @@
import React from 'react'; import React from 'react';
import './ImportList.css'; import './ImportList.css';
import Import from './Import/Import'; import Import from './Import/Import';
import PropTypes from 'prop-types';
import Text from '../../../components/UI/Text/Text'; import Text from '../../../components/UI/Text/Text';
const ImportList = ({ imports_array }) => { const ImportList = ({ imports_array }) => {
@@ -34,4 +35,8 @@ const ImportList = ({ imports_array }) => {
); );
}; };
ImportList.propTypes = {
imports_array: PropTypes.array.isRequired,
};
export default ImportList; export default ImportList;

View File

@@ -1,9 +1,10 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import './Password.css'; import './Password.css';
import { faEye, faEyeSlash } from '@fortawesome/free-solid-svg-icons'; import PropTypes from 'prop-types';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faEye, faEyeSlash } from '@fortawesome/free-solid-svg-icons';
export default class Password extends Component { class Password extends Component {
state = { state = {
button_text: 'clear', button_text: 'clear',
password: '', password: '',
@@ -137,3 +138,15 @@ export default class Password extends Component {
); );
} }
} }
Password.propTypes = {
autoFocus: PropTypes.bool,
changed: PropTypes.func,
disabled: PropTypes.bool,
mismatchHandler: PropTypes.func,
readOnly: PropTypes.bool,
style: PropTypes.object,
value: PropTypes.string,
};
export default Password;

View File

@@ -5,7 +5,7 @@ import Modal from './components/UI/Modal/Modal';
import * as Constants from './constants'; import * as Constants from './constants';
const ipcRenderer = const ipcRenderer =
!process.versions.hasOwnProperty('electron') && window && window.require !Object.prototype.hasOwnProperty.call(process.versions, 'electron') && window && window.require
? window.require('electron').ipcRenderer ? window.require('electron').ipcRenderer
: null; : null;