forked from Katello/katello
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #26434 - move system statuses from deface to react
- Loading branch information
Showing
11 changed files
with
134 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { translate as __ } from 'foremanReact/common/I18n'; | ||
import { LoadingState } from '../../../move_to_pf/LoadingState'; | ||
|
||
class SystemStatuses extends Component { | ||
componentDidMount() { | ||
this.props.getSystemStatuses('/katello/api/ping'); | ||
} | ||
|
||
render() { | ||
const { services, status } = this.props; | ||
const isLoaidng = status === 'PENDING'; | ||
|
||
return ( | ||
<div className="col-md-7 stats-well"> | ||
<h4>{__('Backend System Status')}</h4> | ||
<table className="table table-fixed table-striped table-border"> | ||
<tr> | ||
<th>{__('Component')}</th> | ||
<th>{__('Status')}</th> | ||
<th>{__('Message')}</th> | ||
</tr> | ||
<LoadingState loading={isLoaidng} loadingText=""> | ||
<tbody> | ||
{Object.entries(services).map(([key, value]) => ( | ||
<tr key={key}> | ||
<td> {key} </td> | ||
<td>{value.status.toUpperCase()}</td> | ||
<td> {value.message}</td> | ||
</tr> | ||
))} | ||
</tbody> | ||
</LoadingState> | ||
</table> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
SystemStatuses.propTypes = { | ||
getSystemStatuses: PropTypes.func.isRequired, | ||
services: PropTypes.shape({}), | ||
status: PropTypes.string, | ||
}; | ||
|
||
SystemStatuses.defaultProps = { | ||
services: {}, | ||
status: '', | ||
}; | ||
|
||
export default SystemStatuses; |
15 changes: 15 additions & 0 deletions
15
webpack/components/extensions/about/SystemStatusesActions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { | ||
SYSTEM_STATUSES_FAILURE, | ||
SYSTEM_STATUSES_SUCCESS, | ||
SYSTEM_STATUSES_REQUEST, | ||
} from './SystemStatusesConsts'; | ||
import { ajaxRequestAction } from 'foremanReact/redux/actions/common'; | ||
|
||
export const getSystemStatuses = url => dispatch => | ||
ajaxRequestAction({ | ||
dispatch, | ||
requestAction: SYSTEM_STATUSES_REQUEST, | ||
successAction: SYSTEM_STATUSES_SUCCESS, | ||
failedAction: SYSTEM_STATUSES_FAILURE, | ||
url, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const SYSTEM_STATUSES_REQUEST = 'SYSTEM_STATUSES_REQUEST'; | ||
export const SYSTEM_STATUSES_SUCCESS = 'SYSTEM_STATUSES_SUCCESS'; | ||
export const SYSTEM_STATUSES_FAILURE = 'SYSTEM_STATUSES_FAILURE'; |
26 changes: 26 additions & 0 deletions
26
webpack/components/extensions/about/SystemStatusesReducer.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import Immutable from 'seamless-immutable'; | ||
import { | ||
SYSTEM_STATUSES_FAILURE, | ||
SYSTEM_STATUSES_SUCCESS, | ||
SYSTEM_STATUSES_REQUEST, | ||
} from './SystemStatusesConsts'; | ||
|
||
const initialState = Immutable({ | ||
services: [], | ||
loaderStatus: '', | ||
}); | ||
|
||
export default (state = initialState, action) => { | ||
switch (action.type) { | ||
case SYSTEM_STATUSES_REQUEST: | ||
return state.set('loaderStatus', 'PENDING'); | ||
case SYSTEM_STATUSES_SUCCESS: | ||
return state | ||
.set('services', action.payload.services) | ||
.set('loaderStatus', 'RESOLVED'); | ||
case SYSTEM_STATUSES_FAILURE: | ||
return state.set('loaderStatus', 'ERROR'); | ||
default: | ||
return state; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { connect } from 'react-redux'; | ||
import * as actions from './SystemStatusesActions'; | ||
import reducer from './SystemStatusesReducer'; | ||
|
||
import FactChart from './SystemStatuses'; | ||
|
||
const mapStateToProps = state => ({ | ||
services: state.katelloExtends.systemServices.services || [], | ||
status: state.katelloExtends.systemServices.loaderStatus, | ||
}); | ||
|
||
// export reducers | ||
export const reducers = { systemServices: reducer }; | ||
|
||
export default connect( | ||
mapStateToProps, | ||
actions, | ||
)(FactChart); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { combineReducers } from 'redux'; | ||
import { reducers as systemStatuses } from './about'; | ||
|
||
export default combineReducers({ | ||
...systemStatuses, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import React from 'react'; | ||
import SystemStatuses from './components/extensions/about'; | ||
import { addGlobalFill } from 'foremanReact/components/common/Fill/GlobalFill'; | ||
|
||
import { registerReducer } from 'foremanReact/common/MountingService'; | ||
import extendReducer from './components/extensions/reducers'; | ||
|
||
registerReducer('katelloExtends', extendReducer); | ||
|
||
addGlobalFill('aboutFooterSlot', '[katello]AboutSystemStatuses', <SystemStatuses key="abc" />, 300); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters