Skip to content

Commit

Permalink
Merge pull request #2252 from HubSpot/disasters-ui
Browse files Browse the repository at this point in the history
Disasters UI Improvements
  • Loading branch information
WH77 authored Jan 3, 2022
2 parents bbb3e20 + 669eeab commit e70da7a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
5 changes: 5 additions & 0 deletions SingularityUI/app/actions/api/base.es6
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ export function buildApiAction(actionName, opts = {}, keyFunc = undefined) {
return Promise.resolve();
}
if (response.headers.get('Content-Type') === 'application/json') {
// void response cannot be parsed as JSON
if (response.headers.get('Content-Length') === '0') {
return Promise.resolve();
}

return response.json();
}
return response.text();
Expand Down
33 changes: 30 additions & 3 deletions SingularityUI/app/components/disasters/LiveConfiguration.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { PropTypes, Component } from 'react';
import { connect } from 'react-redux';
import Messenger from 'messenger';
import Utils from '../../utils';
import Section from '../common/Section';
import { EnableRackSensitivity, DisableRackSensitivity, OverridePlacementStrategy } from '../../actions/api/config';
Expand Down Expand Up @@ -58,6 +59,13 @@ class LiveConfiguration extends Component {
onClick={() => this.props.overridePlacementStrategy(this.state.placementStrategy)}>
Override
</button>
<button
className="btn btn-primary"
alt="Clear Placement Strategy Override"
title="Clear Placement Strategy Override"
onClick={() => this.props.overridePlacementStrategy('')}>
Clear
</button>
</div>
</div>
</Section>
Expand All @@ -74,9 +82,28 @@ function mapStateToProps(state) {

function mapDispatchToProps(dispatch) {
return {
enableRackSensitivity: () => dispatch(EnableRackSensitivity.trigger()),
disableRackSensitivity: () => dispatch(DisableRackSensitivity.trigger()),
overridePlacementStrategy: strategy => dispatch(OverridePlacementStrategy.trigger(strategy)),
enableRackSensitivity: () => dispatch(EnableRackSensitivity.trigger()).then(() => {
Messenger().info({
message: `Enabled rack sensitivity.`,
hideAfter: 5,
});
}),
disableRackSensitivity: () => dispatch(DisableRackSensitivity.trigger()).then(() => {
Messenger().info({
message: `Disabled rack sensitivity.`,
hideAfter: 5,
});
}),
overridePlacementStrategy: strategy => dispatch(OverridePlacementStrategy.trigger(strategy)).then(() => {
const message = strategy
? `Set default placement strategy to ${strategy}.`
: `Cleared default placement strategy override`;

Messenger().info({
message,
hideAfter: 5,
});
}),
}
}

Expand Down

0 comments on commit e70da7a

Please sign in to comment.