ui: Fixup notifications for tokens using and topology intention saving (#11763)

This commit is contained in:
John Cowen 2021-12-09 09:45:24 +00:00 committed by GitHub
parent a104b0e9da
commit 27c85bcea0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 41 additions and 10 deletions

View File

@ -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}}

View File

@ -39,13 +39,20 @@
There was an error, please check your SecretID/Token
{{/if}}
{{else}}
{{#if (eq flash.model 'token')}}
{{#if (or (eq type 'use') (eq flash.model 'token'))}}
<Consul::Token::Notifications
@type={{type}}
@status={{status}}
@item={{flash.item}}
@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')}}
<Consul::Role::Notifications
@type={{type}}

View File

@ -11,7 +11,7 @@ export default class TopologyRoute extends Route {
async createIntention(source, destination) {
// begin with a create action as it makes more sense if the we can't even
// get a list of intentions
let notification = this.feedback.notification('create');
let notification = this.feedback.notification('create', 'intention');
try {
// intentions will be a proxy object
let intentions = await this.intentions;
@ -34,7 +34,7 @@ export default class TopologyRoute extends Route {
});
} else {
// 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');
await this.repo.persist(intention);

View File

@ -10,17 +10,17 @@ const notificationDefaults = function() {
return {
timeout: 6000,
extendedTimeout: 300,
destroyOnClick: true
destroyOnClick: true,
};
};
export default class FeedbackService extends Service {
@service('flashMessages') notify;
@service('logger') logger;
notification(action) {
notification(action, modelName) {
return {
success: item => this.success(item, action),
error: e => this.error(e, action),
success: item => this.success(item, action, undefined, modelName),
error: e => this.error(e, action, undefined, modelName),
};
}
@ -39,7 +39,7 @@ export default class FeedbackService extends Service {
// here..
action: getAction(),
item: item,
model: model
model: model,
});
}
}
@ -55,7 +55,7 @@ export default class FeedbackService extends Service {
type: getStatus(TYPE_SUCCESS),
// and here
action: getAction(),
model: model
model: model,
});
} else {
this.notify.add({
@ -63,7 +63,7 @@ export default class FeedbackService extends Service {
type: getStatus(TYPE_ERROR, e),
action: getAction(),
error: e,
model: model
model: model,
});
}
}