ui: Fixup intention notifications and add SyncTime (#7702)

* ui: Specifically check for error rather than anything but success

* ui: Add SyncTime to intentions for reconciliation
This commit is contained in:
John Cowen 2020-04-24 14:37:35 +01:00 committed by John Cowen
parent bc74c7bbdf
commit 056a5d3090
3 changed files with 9 additions and 2 deletions

View File

@ -20,6 +20,7 @@ export default Model.extend({
DefaultPort: attr('number'), DefaultPort: attr('number'),
// //
Meta: attr(), Meta: attr(),
SyncTime: attr('number'),
Datacenter: attr('string'), Datacenter: attr('string'),
CreatedAt: attr('date'), CreatedAt: attr('date'),
UpdatedAt: attr('date'), UpdatedAt: attr('date'),

View File

@ -9,13 +9,13 @@
{{else if (eq type 'update') }} {{else if (eq type 'update') }}
{{#if (eq status 'success') }} {{#if (eq status 'success') }}
Your intention has been saved. Your intention has been saved.
{{else}} {{else if (eq status 'error')}}
There was an error saving your intention. There was an error saving your intention.
{{/if}} {{/if}}
{{ else if (eq type 'delete')}} {{ else if (eq type 'delete')}}
{{#if (eq status 'success') }} {{#if (eq status 'success') }}
Your intention was deleted. Your intention was deleted.
{{else}} {{else if (eq status 'error')}}
There was an error deleting your intention. There was an error deleting your intention.
{{/if}} {{/if}}
{{/if}} {{/if}}

View File

@ -1,14 +1,19 @@
import { moduleFor, test } from 'ember-qunit'; import { moduleFor, test } from 'ember-qunit';
import repo from 'consul-ui/tests/helpers/repo'; import repo from 'consul-ui/tests/helpers/repo';
import { get } from '@ember/object';
const NAME = 'intention'; const NAME = 'intention';
moduleFor(`service:repository/${NAME}`, `Integration | Service | ${NAME}`, { moduleFor(`service:repository/${NAME}`, `Integration | Service | ${NAME}`, {
integration: true, integration: true,
}); });
const now = new Date().getTime();
const dc = 'dc-1'; const dc = 'dc-1';
const id = 'token-name'; const id = 'token-name';
const nspace = 'default'; const nspace = 'default';
test('findAllByDatacenter returns the correct data for list endpoint', function(assert) { test('findAllByDatacenter returns the correct data for list endpoint', function(assert) {
get(this.subject(), 'store').serializerFor(NAME).timestamp = function() {
return now;
};
return repo( return repo(
'Intention', 'Intention',
'findAllByDatacenter', 'findAllByDatacenter',
@ -29,6 +34,7 @@ test('findAllByDatacenter returns the correct data for list endpoint', function(
Object.assign({}, item, { Object.assign({}, item, {
CreatedAt: new Date(item.CreatedAt), CreatedAt: new Date(item.CreatedAt),
UpdatedAt: new Date(item.UpdatedAt), UpdatedAt: new Date(item.UpdatedAt),
SyncTime: now,
Datacenter: dc, Datacenter: dc,
// TODO: nspace isn't required here, once we've // TODO: nspace isn't required here, once we've
// refactored out our Serializer this can go // refactored out our Serializer this can go