mirror of https://github.com/hashicorp/consul
ui: Fixup notifications for tokens using and topology intention saving (#11763)
parent
340a0e03f5
commit
c434fefda2
|
@ -0,0 +1,24 @@
|
||||||
|
{{#if (eq @type 'create')}}
|
||||||
|
{{#if (eq @status 'success') }}
|
||||||
|
Your intention has been added.
|
||||||
|
{{else}}
|
||||||
|
There was an error adding your intention.
|
||||||
|
{{/if}}
|
||||||
|
{{else if (eq @type 'update') }}
|
||||||
|
{{#if (eq @status 'success') }}
|
||||||
|
Your intention has been saved.
|
||||||
|
{{else}}
|
||||||
|
There was an error saving your intention.
|
||||||
|
{{/if}}
|
||||||
|
{{ else if (eq @type 'delete')}}
|
||||||
|
{{#if (eq @status 'success') }}
|
||||||
|
Your intention was deleted.
|
||||||
|
{{else}}
|
||||||
|
There was an error deleting your intention.
|
||||||
|
{{/if}}
|
||||||
|
{{/if}}
|
||||||
|
{{#let @error.errors.firstObject as |error|}}
|
||||||
|
{{#if error.detail }}
|
||||||
|
<br />{{concat '(' (if error.status (concat error.status ': ')) error.detail ')'}}
|
||||||
|
{{/if}}
|
||||||
|
{{/let}}
|
|
@ -39,13 +39,20 @@
|
||||||
There was an error, please check your SecretID/Token
|
There was an error, please check your SecretID/Token
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{#if (eq flash.model 'token')}}
|
{{#if (or (eq type 'use') (eq flash.model 'token'))}}
|
||||||
<Consul::Token::Notifications
|
<Consul::Token::Notifications
|
||||||
@type={{type}}
|
@type={{type}}
|
||||||
@status={{status}}
|
@status={{status}}
|
||||||
@item={{flash.item}}
|
@item={{flash.item}}
|
||||||
@error={{flash.error}}
|
@error={{flash.error}}
|
||||||
/>
|
/>
|
||||||
|
{{else if (eq flash.model 'intention')}}
|
||||||
|
<Consul::Intention::Notifications
|
||||||
|
@type={{type}}
|
||||||
|
@status={{status}}
|
||||||
|
@item={{flash.item}}
|
||||||
|
@error={{flash.error}}
|
||||||
|
/>
|
||||||
{{else if (eq flash.model 'role')}}
|
{{else if (eq flash.model 'role')}}
|
||||||
<Consul::Role::Notifications
|
<Consul::Role::Notifications
|
||||||
@type={{type}}
|
@type={{type}}
|
||||||
|
|
|
@ -11,7 +11,7 @@ export default class TopologyRoute extends Route {
|
||||||
async createIntention(source, destination) {
|
async createIntention(source, destination) {
|
||||||
// begin with a create action as it makes more sense if the we can't even
|
// begin with a create action as it makes more sense if the we can't even
|
||||||
// get a list of intentions
|
// get a list of intentions
|
||||||
let notification = this.feedback.notification('create');
|
let notification = this.feedback.notification('create', 'intention');
|
||||||
try {
|
try {
|
||||||
// intentions will be a proxy object
|
// intentions will be a proxy object
|
||||||
let intentions = await this.intentions;
|
let intentions = await this.intentions;
|
||||||
|
@ -34,7 +34,7 @@ export default class TopologyRoute extends Route {
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// we found an intention in the find higher up, so we are updating
|
// we found an intention in the find higher up, so we are updating
|
||||||
notification = this.feedback.notification('update');
|
notification = this.feedback.notification('update', 'intention');
|
||||||
}
|
}
|
||||||
set(intention, 'Action', 'allow');
|
set(intention, 'Action', 'allow');
|
||||||
await this.repo.persist(intention);
|
await this.repo.persist(intention);
|
||||||
|
|
|
@ -10,17 +10,17 @@ const notificationDefaults = function() {
|
||||||
return {
|
return {
|
||||||
timeout: 6000,
|
timeout: 6000,
|
||||||
extendedTimeout: 300,
|
extendedTimeout: 300,
|
||||||
destroyOnClick: true
|
destroyOnClick: true,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
export default class FeedbackService extends Service {
|
export default class FeedbackService extends Service {
|
||||||
@service('flashMessages') notify;
|
@service('flashMessages') notify;
|
||||||
@service('logger') logger;
|
@service('logger') logger;
|
||||||
|
|
||||||
notification(action) {
|
notification(action, modelName) {
|
||||||
return {
|
return {
|
||||||
success: item => this.success(item, action),
|
success: item => this.success(item, action, undefined, modelName),
|
||||||
error: e => this.error(e, action),
|
error: e => this.error(e, action, undefined, modelName),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ export default class FeedbackService extends Service {
|
||||||
// here..
|
// here..
|
||||||
action: getAction(),
|
action: getAction(),
|
||||||
item: item,
|
item: item,
|
||||||
model: model
|
model: model,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ export default class FeedbackService extends Service {
|
||||||
type: getStatus(TYPE_SUCCESS),
|
type: getStatus(TYPE_SUCCESS),
|
||||||
// and here
|
// and here
|
||||||
action: getAction(),
|
action: getAction(),
|
||||||
model: model
|
model: model,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.notify.add({
|
this.notify.add({
|
||||||
|
@ -63,7 +63,7 @@ export default class FeedbackService extends Service {
|
||||||
type: getStatus(TYPE_ERROR, e),
|
type: getStatus(TYPE_ERROR, e),
|
||||||
action: getAction(),
|
action: getAction(),
|
||||||
error: e,
|
error: e,
|
||||||
model: model
|
model: model,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue