From 3d9a55c28b5f59ebe9a2f7c71cfee1cd96a8c82c Mon Sep 17 00:00:00 2001 From: John Cowen Date: Fri, 24 Apr 2020 14:37:35 +0100 Subject: [PATCH] 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 --- ui-v2/app/models/intention.js | 1 + ui-v2/app/templates/dc/intentions/-notifications.hbs | 4 ++-- .../tests/integration/services/repository/intention-test.js | 6 ++++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ui-v2/app/models/intention.js b/ui-v2/app/models/intention.js index 0c16c79310..6d0e782350 100644 --- a/ui-v2/app/models/intention.js +++ b/ui-v2/app/models/intention.js @@ -20,6 +20,7 @@ export default Model.extend({ DefaultPort: attr('number'), // Meta: attr(), + SyncTime: attr('number'), Datacenter: attr('string'), CreatedAt: attr('date'), UpdatedAt: attr('date'), diff --git a/ui-v2/app/templates/dc/intentions/-notifications.hbs b/ui-v2/app/templates/dc/intentions/-notifications.hbs index cdef9d5f2c..15e86dc6bf 100644 --- a/ui-v2/app/templates/dc/intentions/-notifications.hbs +++ b/ui-v2/app/templates/dc/intentions/-notifications.hbs @@ -9,13 +9,13 @@ {{else if (eq type 'update') }} {{#if (eq status 'success') }} Your intention has been saved. - {{else}} + {{else if (eq status 'error')}} There was an error saving your intention. {{/if}} {{ else if (eq type 'delete')}} {{#if (eq status 'success') }} Your intention was deleted. - {{else}} + {{else if (eq status 'error')}} There was an error deleting your intention. {{/if}} {{/if}} diff --git a/ui-v2/tests/integration/services/repository/intention-test.js b/ui-v2/tests/integration/services/repository/intention-test.js index f6ccdd153e..3dedd97f42 100644 --- a/ui-v2/tests/integration/services/repository/intention-test.js +++ b/ui-v2/tests/integration/services/repository/intention-test.js @@ -1,14 +1,19 @@ import { moduleFor, test } from 'ember-qunit'; import repo from 'consul-ui/tests/helpers/repo'; +import { get } from '@ember/object'; const NAME = 'intention'; moduleFor(`service:repository/${NAME}`, `Integration | Service | ${NAME}`, { integration: true, }); +const now = new Date().getTime(); const dc = 'dc-1'; const id = 'token-name'; const nspace = 'default'; test('findAllByDatacenter returns the correct data for list endpoint', function(assert) { + get(this.subject(), 'store').serializerFor(NAME).timestamp = function() { + return now; + }; return repo( 'Intention', 'findAllByDatacenter', @@ -29,6 +34,7 @@ test('findAllByDatacenter returns the correct data for list endpoint', function( Object.assign({}, item, { CreatedAt: new Date(item.CreatedAt), UpdatedAt: new Date(item.UpdatedAt), + SyncTime: now, Datacenter: dc, // TODO: nspace isn't required here, once we've // refactored out our Serializer this can go