Fix roles listing for custom plan
Closes-Bug: 1644310
Change-Id: I18d5387b51703b1858166696cef65a9a7111a409
(cherry picked from commit a5460035b2
)
This commit is contained in:
parent
ab54196fb4
commit
fa26140f96
|
@ -3,10 +3,10 @@ import PlansConstants from '../constants/PlansConstants';
|
|||
import ValidationsActions from '../actions/ValidationsActions';
|
||||
|
||||
export default {
|
||||
detectPlan(plans) {
|
||||
detectPlan() {
|
||||
return (dispatch, getState) => {
|
||||
let state = getState();
|
||||
let plans = state.plans.get('all').map(plan => plan.get('name'));
|
||||
let plans = state.plans.all.map(plan => plan.get('name'));
|
||||
let conflict;
|
||||
let currentPlanName = state.currentPlan.get('currentPlanName');
|
||||
let previousPlan = currentPlanName || getStoredPlan();
|
||||
|
|
|
@ -36,7 +36,7 @@ export default {
|
|||
ZaqarWebSocketService.init(getState, dispatch);
|
||||
browserHistory.push(nextPath);
|
||||
}).catch((error) => {
|
||||
logger.error('Error in LoginActions.authenticateUser', error);
|
||||
logger.error('Error in LoginActions.authenticateUser', error.stack || error);
|
||||
let errorHandler = new KeystoneApiErrorHandler(error, formFields);
|
||||
dispatch(this.userAuthFailure(errorHandler.errors, errorHandler.formFieldErrors));
|
||||
});
|
||||
|
|
|
@ -35,9 +35,9 @@ export default {
|
|||
MistralApiService.runAction(MistralConstants.PLAN_LIST).then((response) => {
|
||||
let plans = JSON.parse(response.output).result || [];
|
||||
dispatch(this.receivePlans(plans));
|
||||
dispatch(CurrentPlanActions.detectPlan(plans));
|
||||
dispatch(CurrentPlanActions.detectPlan());
|
||||
}).catch((error) => {
|
||||
logger.error('Error in PlansActions.fetchPlan', error);
|
||||
logger.error('Error in PlansActions.fetchPlans', error.stack || error);
|
||||
let errorHandler = new MistralApiErrorHandler(error);
|
||||
errorHandler.errors.forEach((error) => {
|
||||
dispatch(NotificationActions.notify(error));
|
||||
|
@ -69,7 +69,7 @@ export default {
|
|||
dispatch(this.receivePlan(planName,
|
||||
normalize(response, arrayOf(planFileSchema)).entities.planFiles));
|
||||
}).catch(error => {
|
||||
logger.error('Error retrieving plan PlansActions.fetchPlan', error);
|
||||
logger.error('Error retrieving plan PlansActions.fetchPlan', error.stack || error);
|
||||
let errorHandler = new SwiftApiErrorHandler(error);
|
||||
errorHandler.errors.forEach((error) => {
|
||||
dispatch(NotificationActions.notify(error));
|
||||
|
@ -322,6 +322,7 @@ export default {
|
|||
message: `The plan ${planName} was successfully deleted.`,
|
||||
type: 'success'
|
||||
}));
|
||||
dispatch(CurrentPlanActions.detectPlan());
|
||||
}).catch(error => {
|
||||
logger.error('Error deleting plan MistralApiService.runAction', error);
|
||||
dispatch(this.planDeleted(planName));
|
||||
|
|
|
@ -53,10 +53,12 @@ class DeploymentPlan extends React.Component {
|
|||
|
||||
render() {
|
||||
let children;
|
||||
const currentPlanName = this.props.hasPlans ? this.props.currentPlan.name : undefined;
|
||||
|
||||
// Render children only when current plan is already selected
|
||||
if (this.props.children && this.props.currentPlan.name) {
|
||||
if (this.props.children && currentPlanName) {
|
||||
children = React.cloneElement(this.props.children,
|
||||
{currentPlanName: this.props.currentPlan.name,
|
||||
{currentPlanName: currentPlanName,
|
||||
parentPath: '/' + this.props.route.path});
|
||||
}
|
||||
|
||||
|
@ -66,8 +68,8 @@ class DeploymentPlan extends React.Component {
|
|||
<div className="col-sm-12">
|
||||
<div className="page-header page-header-bleed-right">
|
||||
<h1>
|
||||
{this.props.currentPlan.name}
|
||||
<PlansDropdown currentPlanName={this.props.currentPlan.name}
|
||||
{currentPlanName}
|
||||
<PlansDropdown currentPlanName={currentPlanName}
|
||||
plans={this.props.inactivePlans}
|
||||
choosePlan={this.props.choosePlan}/>
|
||||
</h1>
|
||||
|
@ -82,7 +84,7 @@ class DeploymentPlan extends React.Component {
|
|||
<ConfigurePlanStep
|
||||
fetchEnvironmentConfiguration={this.props.fetchEnvironmentConfiguration}
|
||||
summary={this.props.environmentConfigurationSummary}
|
||||
planName={this.props.currentPlan.name}
|
||||
planName={currentPlanName}
|
||||
isFetching={this.props.isFetchingEnvironmentConfiguration}
|
||||
loaded={this.props.environmentConfigurationLoaded}/>
|
||||
</DeploymentPlanStep>
|
||||
|
@ -90,7 +92,7 @@ class DeploymentPlan extends React.Component {
|
|||
disabled={this.props.currentStackDeploymentInProgress}>
|
||||
<RolesStep availableNodes={this.props.availableNodes}
|
||||
fetchNodes={this.props.fetchNodes}
|
||||
fetchRoles={this.props.fetchRoles}
|
||||
fetchRoles={this.props.fetchRoles.bind(this, currentPlanName)}
|
||||
isFetchingNodes={this.props.isFetchingNodes}
|
||||
isFetchingRoles={this.props.isFetchingRoles}
|
||||
roles={this.props.roles}
|
||||
|
@ -110,7 +112,7 @@ class DeploymentPlan extends React.Component {
|
|||
fetchStackResource={this.props.fetchStackResource}
|
||||
isRequestingStackDelete={this.props.isRequestingStackDelete}
|
||||
runPostDeploymentValidations={
|
||||
this.props.runPostDeploymentValidations.bind(this.props.currentPlan.name)}
|
||||
this.props.runPostDeploymentValidations.bind(this, currentPlanName)}
|
||||
stacksLoaded={this.props.stacksLoaded}/>
|
||||
</DeploymentPlanStep>
|
||||
</ol>
|
||||
|
@ -198,7 +200,7 @@ function mapDispatchToProps(dispatch) {
|
|||
dispatch(EnvironmentConfigurationActions.fetchEnvironmentConfiguration(planName, parentPath));
|
||||
},
|
||||
fetchNodes: () => dispatch(NodesActions.fetchNodes()),
|
||||
fetchRoles: () => dispatch(RolesActions.fetchRoles()),
|
||||
fetchRoles: planName => dispatch(RolesActions.fetchRoles(planName)),
|
||||
fetchStackResources: (stack) =>
|
||||
dispatch(StacksActions.fetchResources(stack.stack_name, stack.id)),
|
||||
fetchStackResource: (stack, resourceName) =>
|
||||
|
|
|
@ -14,13 +14,13 @@ import { getRegisteredNodes,
|
|||
class Nodes extends React.Component {
|
||||
componentDidMount() {
|
||||
this.props.dispatch(NodesActions.fetchNodes());
|
||||
this.props.dispatch(RolesActions.fetchRoles());
|
||||
this.props.dispatch(RolesActions.fetchRoles(this.props.currentPlanName));
|
||||
}
|
||||
|
||||
refreshResults(e) {
|
||||
e.preventDefault();
|
||||
this.props.dispatch(NodesActions.fetchNodes());
|
||||
this.props.dispatch(RolesActions.fetchRoles());
|
||||
this.props.dispatch(RolesActions.fetchRoles(this.props.currentPlanName));
|
||||
}
|
||||
|
||||
render() {
|
||||
|
@ -61,12 +61,14 @@ class Nodes extends React.Component {
|
|||
}
|
||||
Nodes.propTypes = {
|
||||
children: React.PropTypes.node.isRequired,
|
||||
currentPlanName: React.PropTypes.string.isRequired,
|
||||
dispatch: React.PropTypes.func.isRequired,
|
||||
nodes: ImmutablePropTypes.map.isRequired
|
||||
};
|
||||
|
||||
function mapStateToProps(state) {
|
||||
return {
|
||||
currentPlanName: state.currentPlan.currentPlanName,
|
||||
nodes: state.nodes.merge(
|
||||
Map({
|
||||
registered: getRegisteredNodes(state),
|
||||
|
|
Loading…
Reference in New Issue