|
|
|
@ -2,6 +2,7 @@ import PropTypes from 'prop-types';
|
|
|
|
|
import React, { Component } from 'react';
|
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
import { createSelector } from 'reselect';
|
|
|
|
|
import { fetchGeneralSettings } from 'Store/Actions/settingsActions';
|
|
|
|
|
import { fetchUpdates } from 'Store/Actions/systemActions';
|
|
|
|
|
import { executeCommand } from 'Store/Actions/commandActions';
|
|
|
|
|
import createCommandExecutingSelector from 'Store/Selectors/createCommandExecutingSelector';
|
|
|
|
@ -17,29 +18,31 @@ function createMapStateToProps() {
|
|
|
|
|
(state) => state.system.updates,
|
|
|
|
|
(state) => state.settings.general,
|
|
|
|
|
createUISettingsSelector(),
|
|
|
|
|
createCommandExecutingSelector(commandNames.APPLICATION_UPDATE),
|
|
|
|
|
createSystemStatusSelector(),
|
|
|
|
|
createCommandExecutingSelector(commandNames.APPLICATION_UPDATE),
|
|
|
|
|
(
|
|
|
|
|
currentVersion,
|
|
|
|
|
status,
|
|
|
|
|
updates,
|
|
|
|
|
generalSettings,
|
|
|
|
|
uiSettings,
|
|
|
|
|
isInstallingUpdate,
|
|
|
|
|
systemStatus
|
|
|
|
|
systemStatus,
|
|
|
|
|
isInstallingUpdate
|
|
|
|
|
) => {
|
|
|
|
|
const {
|
|
|
|
|
isFetching,
|
|
|
|
|
isPopulated,
|
|
|
|
|
error,
|
|
|
|
|
error: updatesError,
|
|
|
|
|
items
|
|
|
|
|
} = updates;
|
|
|
|
|
|
|
|
|
|
const isFetching = updates.isFetching || generalSettings.isFetching;
|
|
|
|
|
const isPopulated = updates.isPopulated && generalSettings.isPopulated;
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
currentVersion,
|
|
|
|
|
isFetching,
|
|
|
|
|
isPopulated,
|
|
|
|
|
error,
|
|
|
|
|
updatesError,
|
|
|
|
|
generalSettingsError: generalSettings.error,
|
|
|
|
|
items,
|
|
|
|
|
isInstallingUpdate,
|
|
|
|
|
isDocker: systemStatus.isDocker,
|
|
|
|
@ -52,8 +55,9 @@ function createMapStateToProps() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const mapDispatchToProps = {
|
|
|
|
|
fetchUpdates,
|
|
|
|
|
executeCommand
|
|
|
|
|
dispatchFetchUpdates: fetchUpdates,
|
|
|
|
|
dispatchFetchGeneralSettings: fetchGeneralSettings,
|
|
|
|
|
dispatchExecuteCommand: executeCommand
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class UpdatesConnector extends Component {
|
|
|
|
@ -62,14 +66,15 @@ class UpdatesConnector extends Component {
|
|
|
|
|
// Lifecycle
|
|
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
|
this.props.fetchUpdates();
|
|
|
|
|
this.props.dispatchFetchUpdates();
|
|
|
|
|
this.props.dispatchFetchGeneralSettings();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Listeners
|
|
|
|
|
|
|
|
|
|
onInstallLatestPress = () => {
|
|
|
|
|
this.props.executeCommand({ name: commandNames.APPLICATION_UPDATE });
|
|
|
|
|
this.props.dispatchExecuteCommand({ name: commandNames.APPLICATION_UPDATE });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
@ -86,8 +91,9 @@ class UpdatesConnector extends Component {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UpdatesConnector.propTypes = {
|
|
|
|
|
fetchUpdates: PropTypes.func.isRequired,
|
|
|
|
|
executeCommand: PropTypes.func.isRequired
|
|
|
|
|
dispatchFetchUpdates: PropTypes.func.isRequired,
|
|
|
|
|
dispatchFetchGeneralSettings: PropTypes.func.isRequired,
|
|
|
|
|
dispatchExecuteCommand: PropTypes.func.isRequired
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default connect(createMapStateToProps, mapDispatchToProps)(UpdatesConnector);
|
|
|
|
|