Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disasters UI Improvements #2252

Merged
merged 4 commits into from
Jan 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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