Skip to content

Commit

Permalink
ui: Fixup notifications for tokens using and topology intention saving (
Browse files Browse the repository at this point in the history
  • Loading branch information
johncowen authored and hc-github-team-consul-core committed Dec 9, 2021
1 parent 44761e6 commit ef792c8
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -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}}
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down
4 changes: 2 additions & 2 deletions ui/packages/consul-ui/app/routes/dc/services/show/topology.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
14 changes: 7 additions & 7 deletions ui/packages/consul-ui/app/services/feedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
};
}

Expand All @@ -39,7 +39,7 @@ export default class FeedbackService extends Service {
// here..
action: getAction(),
item: item,
model: model
model: model,
});
}
}
Expand All @@ -55,15 +55,15 @@ export default class FeedbackService extends Service {
type: getStatus(TYPE_SUCCESS),
// and here
action: getAction(),
model: model
model: model,
});
} else {
this.notify.add({
...notificationDefaults(),
type: getStatus(TYPE_ERROR, e),
action: getAction(),
error: e,
model: model
model: model,
});
}
}
Expand Down

0 comments on commit ef792c8

Please sign in to comment.