From c5fb3899b5eb459471da64e045e055c41a22291c Mon Sep 17 00:00:00 2001 From: Susmitha Girumala Date: Tue, 18 Aug 2020 11:49:07 -0400 Subject: [PATCH 1/4] chore: View a host set --- .../app/components/form/host-set/index.hbs | 49 ++++++++++++++++ ui/core/app/router.js | 4 +- .../host-catalogs/host-catalog/host-sets.js | 56 +++++++++++++++++++ .../host-catalog/host-sets/host-set.js | 19 +++++++ .../host-catalog/host-sets/host-set/index.js | 4 ++ .../host-catalog/host-sets/index.js | 4 ++ .../host-catalogs/host-catalog/host-sets.hbs | 28 +--------- .../host-catalog/host-sets/host-set.hbs | 1 + .../host-catalog/host-sets/host-set/index.hbs | 23 ++++++++ .../host-catalog/host-sets/index.hbs | 30 ++++++++++ .../components/form/host-set-test.js | 24 ++++++++ .../host-catalog/host-sets/host-set-test.js | 11 ++++ .../host-sets/host-set/index-test.js | 11 ++++ .../host-catalog/host-sets/index-test.js | 11 ++++ ui/core/translations/en-us.yaml | 1 + 15 files changed, 250 insertions(+), 26 deletions(-) create mode 100644 ui/core/app/components/form/host-set/index.hbs create mode 100644 ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set.js create mode 100644 ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set/index.js create mode 100644 ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/index.js create mode 100644 ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set.hbs create mode 100644 ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set/index.hbs create mode 100644 ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/index.hbs create mode 100644 ui/core/tests/integration/components/form/host-set-test.js create mode 100644 ui/core/tests/unit/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set-test.js create mode 100644 ui/core/tests/unit/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set/index-test.js create mode 100644 ui/core/tests/unit/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/index-test.js diff --git a/ui/core/app/components/form/host-set/index.hbs b/ui/core/app/components/form/host-set/index.hbs new file mode 100644 index 000000000..45adc26d0 --- /dev/null +++ b/ui/core/app/components/form/host-set/index.hbs @@ -0,0 +1,49 @@ + + + + {{#if @model.errors.name}} + + {{#each @model.errors.name as |error|}} + {{error.message}} + {{/each}} + + {{/if}} + + + + {{#if @model.errors.description}} + + {{#each @model.errors.description as |error|}} + {{error.message}} + {{/each}} + + {{/if}} + + + + + diff --git a/ui/core/app/router.js b/ui/core/app/router.js index 91a8aceca..0c6640345 100644 --- a/ui/core/app/router.js +++ b/ui/core/app/router.js @@ -32,7 +32,9 @@ Router.map(function () { this.route('host-catalogs', function() { this.route('new'); this.route('host-catalog', { path: ':host_catalog_id' }, function() { - this.route('host-sets'); + this.route('host-sets', function() { + this.route('host-set', { path: ':host_set_id' }, function() {}); + }); }); }); }); diff --git a/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets.js b/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets.js index c4440322e..ae4b9d2a5 100644 --- a/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets.js +++ b/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets.js @@ -1,6 +1,15 @@ import Route from '@ember/routing/route'; +import { inject as service } from '@ember/service'; +import { action } from '@ember/object'; export default class ScopesScopeProjectsProjectHostCatalogsHostCatalogHostSetsRoute extends Route { + // =services + + @service intl; + @service notify; + + // =methods + /** * Loads all host-sets under the current scope and host catalog. * @return {Promise{[HostSetModel]}} @@ -10,4 +19,51 @@ export default class ScopesScopeProjectsProjectHostCatalogsHostCatalogHostSetsRo const hostCatalogID = this.modelFor('scopes.scope.projects.project.host-catalogs.host-catalog').id; return this.store.findAll('host-set', { adapterOptions: { scopeID, hostCatalogID } }); } + + + // =actions + + /** + * Rollback changes on a host set. + * @param {HostSetModel} hostSet + */ + @action + cancel(hostSet) { + hostSet.rollbackAttributes(); + } + + /** + * Handle save of a host set. + * @param {HostSetModel} hostSet + * @param {Event} e + */ + @action + async save(hostSet) { + try { + await hostSet.save(); + this.refresh(); + this.notify.success(this.intl.t('notify.save-success')); + this.transitionTo('scopes.scope.projects.project.host-catalogs.host-catalog.host-sets.host-set', hostSet); + } catch (error) { + // TODO: replace with translated strings + this.notify.error(error.message, { closeAfter: null }); + } + } + + /** + * Delete host set in current scope and redirect to index. + * @param {HostSetModel} hostSet + */ + @action + async delete(hostSet) { + try { + await hostSet.destroyRecord(); + this.refresh(); + this.notify.success(this.intl.t('notify.delete-success')); + this.transitionTo('scopes.scope.projects.project.host-catalogs.host-catalog.host-sets'); + } catch (error) { + // TODO: replace with translated strings + this.notify.error(error.message, { closeAfter: null }); + } + } } diff --git a/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set.js b/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set.js new file mode 100644 index 000000000..75f1f1fed --- /dev/null +++ b/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set.js @@ -0,0 +1,19 @@ +import Route from '@ember/routing/route'; + +export default class ScopesScopeProjectsProjectHostCatalogsHostCatalogHostSetsHostSetRoute extends Route { + // =methods + + /** + * Load a host set in current scope and host-catalog. + * @param {object} params + * @param {string} params.host_set_id + * @return {HostSetModel} + */ + async model({ host_set_id }) { + const { id: scopeID } = this.modelFor('scopes.scope.projects.project'); + const hostCatalogID = this.modelFor('scopes.scope.projects.project.host-catalogs.host-catalog').id; + return this.store.findRecord('host-set', host_set_id, { + adapterOptions: { scopeID, hostCatalogID } + }); + } +} diff --git a/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set/index.js b/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set/index.js new file mode 100644 index 000000000..261452404 --- /dev/null +++ b/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set/index.js @@ -0,0 +1,4 @@ +import Route from '@ember/routing/route'; + +export default class ScopesScopeProjectsProjectHostCatalogsHostCatalogHostSetsHostSetIndexRoute extends Route { +} diff --git a/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/index.js b/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/index.js new file mode 100644 index 000000000..dd0a311d8 --- /dev/null +++ b/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/index.js @@ -0,0 +1,4 @@ +import Route from '@ember/routing/route'; + +export default class ScopesScopeProjectsProjectHostCatalogsHostCatalogHostSetsIndexRoute extends Route { +} diff --git a/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets.hbs b/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets.hbs index 300abe57b..49966461b 100644 --- a/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets.hbs +++ b/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets.hbs @@ -1,25 +1,3 @@ - - - - {{t "form.label.name"}} - {{t "form.label.type"}} - {{t "form.label.id"}} - - - - {{#each @model as |hostSet|}} - - - {{hostSet.displayName}} -

{{hostSet.description}}

-
- - {{hostSet.type}} - - - {{hostSet.id}} - -
- {{/each}} -
-
\ No newline at end of file +{{title (t "resources.host-sets")}} + +{{outlet}} \ No newline at end of file diff --git a/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set.hbs b/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set.hbs new file mode 100644 index 000000000..e2147cab0 --- /dev/null +++ b/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set.hbs @@ -0,0 +1 @@ +{{outlet}} \ No newline at end of file diff --git a/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set/index.hbs b/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set/index.hbs new file mode 100644 index 000000000..64646aa20 --- /dev/null +++ b/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set/index.hbs @@ -0,0 +1,23 @@ + + + +

{{t "resources.host-set"}}

+
+ + + + + + {{t 'actions.delete'}} + + + +
diff --git a/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/index.hbs b/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/index.hbs new file mode 100644 index 000000000..d2cb5be5d --- /dev/null +++ b/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/index.hbs @@ -0,0 +1,30 @@ + + + + {{t "form.label.name"}} + {{t "form.label.type"}} + {{t "form.label.id"}} + + + + {{#each @model as |hostSet|}} + + + + {{hostSet.displayName}} + +

{{hostSet.description}}

+
+ + {{hostSet.type}} + + + {{hostSet.id}} + +
+ {{/each}} +
+
\ No newline at end of file diff --git a/ui/core/tests/integration/components/form/host-set-test.js b/ui/core/tests/integration/components/form/host-set-test.js new file mode 100644 index 000000000..17fb6f818 --- /dev/null +++ b/ui/core/tests/integration/components/form/host-set-test.js @@ -0,0 +1,24 @@ +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'ember-qunit'; +import { render, find } from '@ember/test-helpers'; +import { hbs } from 'ember-cli-htmlbars'; + +module('Integration | Component | form/host-set', function(hooks) { + setupRenderingTest(hooks); + + test('it renders', async function (assert) { + // Set any properties with this.set('myProperty', 'value'); + // Handle any actions with this.set('myAction', function(val) { ... }); + this.submit = () => {}; + this.cancel = () => {}; + + await render(hbs` + `); + + assert.ok(find('form')); + }); + }); +}); diff --git a/ui/core/tests/unit/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set-test.js b/ui/core/tests/unit/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set-test.js new file mode 100644 index 000000000..320e03551 --- /dev/null +++ b/ui/core/tests/unit/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set-test.js @@ -0,0 +1,11 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module('Unit | Route | scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set', function(hooks) { + setupTest(hooks); + + test('it exists', function(assert) { + let route = this.owner.lookup('route:scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set'); + assert.ok(route); + }); +}); diff --git a/ui/core/tests/unit/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set/index-test.js b/ui/core/tests/unit/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set/index-test.js new file mode 100644 index 000000000..5f0b9420b --- /dev/null +++ b/ui/core/tests/unit/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set/index-test.js @@ -0,0 +1,11 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module('Unit | Route | scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set/index', function(hooks) { + setupTest(hooks); + + test('it exists', function(assert) { + let route = this.owner.lookup('route:scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set/index'); + assert.ok(route); + }); +}); diff --git a/ui/core/tests/unit/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/index-test.js b/ui/core/tests/unit/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/index-test.js new file mode 100644 index 000000000..88f8a3f8b --- /dev/null +++ b/ui/core/tests/unit/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/index-test.js @@ -0,0 +1,11 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module('Unit | Route | scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/index', function(hooks) { + setupTest(hooks); + + test('it exists', function(assert) { + let route = this.owner.lookup('route:scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/index'); + assert.ok(route); + }); +}); diff --git a/ui/core/translations/en-us.yaml b/ui/core/translations/en-us.yaml index 2f2e4df01..0af92ef28 100644 --- a/ui/core/translations/en-us.yaml +++ b/ui/core/translations/en-us.yaml @@ -33,6 +33,7 @@ resources: host-catalogs: Host Catalogs auth-method: Auth Method auth-methods: Auth Methods + host-set: Host Set host-sets: Host Sets titles: iam: IAM From 921909aafd3df3b353572b2aa99becfa7ae68a5e Mon Sep 17 00:00:00 2001 From: Susmitha Girumala Date: Wed, 19 Aug 2020 15:49:51 -0400 Subject: [PATCH 2/4] chore: Add named outlets for host catalog template Host set updates host catalog template layout sections, thus named outlets need to be introduced to host catalog template. --- .../project/host-catalogs/host-catalog.js | 21 +++++++++++ .../host-catalog/host-sets/host-set.js | 24 +++++++++++++ .../project/host-catalogs/host-catalog.hbs | 15 ++++---- .../host-catalogs/host-catalog/-header.hbs | 1 + .../host-catalog/-navigation.hbs | 8 +++++ .../host-catalog/host-sets/-header.hbs | 1 + .../host-catalog/host-sets/-navigation.hbs | 5 +++ .../host-catalog/host-sets/host-set/index.hbs | 36 +++++++------------ .../components/form/host-set-test.js | 1 - 9 files changed, 79 insertions(+), 33 deletions(-) create mode 100644 ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/-header.hbs create mode 100644 ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/-navigation.hbs create mode 100644 ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/-header.hbs create mode 100644 ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/-navigation.hbs diff --git a/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog.js b/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog.js index d25608633..00d0b148d 100644 --- a/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog.js +++ b/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog.js @@ -17,4 +17,25 @@ export default class ScopesScopeProjectsProjectHostCatalogsHostCatalogRoute exte }); } + /** + * Renders the host-catalog specific templates for header and navigation page sections. + * @override + * @param {object} controller + * @param {object} model + */ + renderTemplate(controller, model) { + this.render('scopes/scope/projects/project/host-catalogs/host-catalog'); + + this.render('scopes/scope/projects/project/host-catalogs/host-catalog/-header', { + into: 'scopes/scope/projects/project/host-catalogs/host-catalog', + outlet: 'header', + model: model + }); + + this.render('scopes/scope/projects/project/host-catalogs/host-catalog/-navigation', { + into: 'scopes/scope/projects/project/host-catalogs/host-catalog', + outlet: 'navigation', + model: model + }); + } } diff --git a/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set.js b/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set.js index 75f1f1fed..4025a17bd 100644 --- a/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set.js +++ b/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set.js @@ -16,4 +16,28 @@ export default class ScopesScopeProjectsProjectHostCatalogsHostCatalogHostSetsHo adapterOptions: { scopeID, hostCatalogID } }); } + + /** + * Renders the host-set specific templates for header and navigation page sections. + * @override + * @param {object} controller + * @param {object} model + */ + renderTemplate(controller, model) { + this.render('scopes/scope/projects/project/host-catalogs/host-catalog/host-sets'); + + this.render('scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/-header', { + into: 'scopes/scope/projects/project/host-catalogs/host-catalog', + outlet: 'header', + model: model + }); + + this.render('scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/-navigation', { + into: 'scopes/scope/projects/project/host-catalogs/host-catalog', + outlet: 'navigation', + model: model + }); + + super.renderTemplate(...arguments); + } } diff --git a/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog.hbs b/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog.hbs index 529b61a34..e9bdb8c81 100644 --- a/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog.hbs +++ b/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog.hbs @@ -5,18 +5,15 @@ -

{{t "resources.host-catalog"}}

+ {{outlet "header"}}
+ + {{outlet "actions"}} + + - - - {{t 'titles.details'}} - - - {{t 'titles.host-sets'}} - - + {{outlet "navigation"}} diff --git a/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/-header.hbs b/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/-header.hbs new file mode 100644 index 000000000..82af78ffe --- /dev/null +++ b/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/-header.hbs @@ -0,0 +1 @@ +

{{t "resources.host-catalog"}}

diff --git a/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/-navigation.hbs b/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/-navigation.hbs new file mode 100644 index 000000000..030326509 --- /dev/null +++ b/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/-navigation.hbs @@ -0,0 +1,8 @@ + + + {{t 'titles.details'}} + + + {{t 'titles.host-sets'}} + + diff --git a/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/-header.hbs b/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/-header.hbs new file mode 100644 index 000000000..ae86a8707 --- /dev/null +++ b/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/-header.hbs @@ -0,0 +1 @@ +

{{t "resources.host-set"}}

\ No newline at end of file diff --git a/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/-navigation.hbs b/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/-navigation.hbs new file mode 100644 index 000000000..62f603a0b --- /dev/null +++ b/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/-navigation.hbs @@ -0,0 +1,5 @@ + + + {{t 'titles.details'}} + + \ No newline at end of file diff --git a/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set/index.hbs b/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set/index.hbs index 64646aa20..4ea8678d7 100644 --- a/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set/index.hbs +++ b/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set/index.hbs @@ -1,23 +1,13 @@ - - - -

{{t "resources.host-set"}}

-
- - - - - - {{t 'actions.delete'}} - - - -
+ + + + {{t 'actions.delete'}} + diff --git a/ui/core/tests/integration/components/form/host-set-test.js b/ui/core/tests/integration/components/form/host-set-test.js index 17fb6f818..9797376cc 100644 --- a/ui/core/tests/integration/components/form/host-set-test.js +++ b/ui/core/tests/integration/components/form/host-set-test.js @@ -20,5 +20,4 @@ module('Integration | Component | form/host-set', function(hooks) { assert.ok(find('form')); }); - }); }); From 10ab1070cc350a71ea951bf48ba409c6777c341e Mon Sep 17 00:00:00 2001 From: Susmitha Girumala Date: Wed, 19 Aug 2020 16:23:49 -0400 Subject: [PATCH 3/4] chore: Save and delete host-set with host-catalog adapteropts --- .../host-catalogs/host-catalog/host-sets.js | 17 +++++++++---- .../host-catalog/host-sets/host-set.js | 4 +--- ui/core/mirage/serializers/host-set.js | 5 ++++ ui/core/tests/acceptance/host-sets-test.js | 24 +++++++++++++++++++ 4 files changed, 43 insertions(+), 7 deletions(-) create mode 100644 ui/core/mirage/serializers/host-set.js diff --git a/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets.js b/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets.js index ae4b9d2a5..f69de9f1a 100644 --- a/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets.js +++ b/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets.js @@ -11,7 +11,7 @@ export default class ScopesScopeProjectsProjectHostCatalogsHostCatalogHostSetsRo // =methods /** - * Loads all host-sets under the current scope and host catalog. + * Loads all host-sets under the current host catalog and it's parent scope. * @return {Promise{[HostSetModel]}} */ async model() { @@ -20,7 +20,6 @@ export default class ScopesScopeProjectsProjectHostCatalogsHostCatalogHostSetsRo return this.store.findAll('host-set', { adapterOptions: { scopeID, hostCatalogID } }); } - // =actions /** @@ -40,7 +39,7 @@ export default class ScopesScopeProjectsProjectHostCatalogsHostCatalogHostSetsRo @action async save(hostSet) { try { - await hostSet.save(); + await hostSet.save(this.adapterOptions()); this.refresh(); this.notify.success(this.intl.t('notify.save-success')); this.transitionTo('scopes.scope.projects.project.host-catalogs.host-catalog.host-sets.host-set', hostSet); @@ -57,7 +56,7 @@ export default class ScopesScopeProjectsProjectHostCatalogsHostCatalogHostSetsRo @action async delete(hostSet) { try { - await hostSet.destroyRecord(); + await hostSet.destroyRecord(this.adapterOptions()); this.refresh(); this.notify.success(this.intl.t('notify.delete-success')); this.transitionTo('scopes.scope.projects.project.host-catalogs.host-catalog.host-sets'); @@ -66,4 +65,14 @@ export default class ScopesScopeProjectsProjectHostCatalogsHostCatalogHostSetsRo this.notify.error(error.message, { closeAfter: null }); } } + + /** + * Configure adapter options using current host catalog scope and it's parent project scope. + * @return {object} + */ + adapterOptions() { + const scopeID = this.modelFor('scopes.scope.projects.project').id; + const hostCatalogID = this.modelFor('scopes.scope.projects.project.host-catalogs.host-catalog').id; + return { adapterOptions : { scopeID, hostCatalogID } }; + } } diff --git a/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set.js b/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set.js index 4025a17bd..7211982fb 100644 --- a/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set.js +++ b/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set.js @@ -4,7 +4,7 @@ export default class ScopesScopeProjectsProjectHostCatalogsHostCatalogHostSetsHo // =methods /** - * Load a host set in current scope and host-catalog. + * Load a host-set using current host-catalog and it's parent project scope. * @param {object} params * @param {string} params.host_set_id * @return {HostSetModel} @@ -37,7 +37,5 @@ export default class ScopesScopeProjectsProjectHostCatalogsHostCatalogHostSetsHo outlet: 'navigation', model: model }); - - super.renderTemplate(...arguments); } } diff --git a/ui/core/mirage/serializers/host-set.js b/ui/core/mirage/serializers/host-set.js new file mode 100644 index 000000000..fa67b50ba --- /dev/null +++ b/ui/core/mirage/serializers/host-set.js @@ -0,0 +1,5 @@ +import ApplicationSerializer from './application'; + +export default ApplicationSerializer.extend({ + modelName: 'host-set' +}); diff --git a/ui/core/tests/acceptance/host-sets-test.js b/ui/core/tests/acceptance/host-sets-test.js index 4f398902f..d01bb6796 100644 --- a/ui/core/tests/acceptance/host-sets-test.js +++ b/ui/core/tests/acceptance/host-sets-test.js @@ -75,4 +75,28 @@ module('Acceptance | host sets', function (hooks) { await a11yAudit(); assert.equal(currentURL(), urls.hostSets); }); + + test('can navigate to a host set form', async function (assert) { + assert.expect(0); + }); + + test('can update a host set and save changes', async function (assert) { + assert.expect(0); + }); + + test('can update a host set and cancel changes', async function (assert) { + assert.expect(0); + }); + + test('errors are displayed when save on auth method fails', async function (assert) { + assert.expect(0); + }); + + test('errors are displayed when delete on a host set fails', async function (assert) { + assert.expect(0); + }); + + test('saving an existing auth method with invalid fields displays error messages', async function (assert) { + assert.expect(0); + }); }); From b2aa10fd40771be17fbb271b98303c20e742cf2a Mon Sep 17 00:00:00 2001 From: Susmitha Girumala Date: Wed, 19 Aug 2020 16:37:44 -0400 Subject: [PATCH 4/4] chore: Add Manage>delete dropdown to host-catalog & host-set --- .../scopes/scope/projects/project/host-catalogs.js | 10 ++++++---- .../projects/project/host-catalogs/host-catalog.js | 8 +++++++- .../host-catalogs/host-catalog/host-sets/host-set.js | 8 +++++++- .../project/host-catalogs/host-catalog/-actions.hbs | 9 +++++++++ .../host-catalogs/host-catalog/host-sets/-actions.hbs | 9 +++++++++ .../host-catalog/host-sets/host-set/index.hbs | 8 -------- ui/core/translations/en-us.yaml | 1 + 7 files changed, 39 insertions(+), 14 deletions(-) create mode 100644 ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/-actions.hbs create mode 100644 ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/-actions.hbs diff --git a/ui/core/app/routes/scopes/scope/projects/project/host-catalogs.js b/ui/core/app/routes/scopes/scope/projects/project/host-catalogs.js index de945f71c..8ef0f103d 100644 --- a/ui/core/app/routes/scopes/scope/projects/project/host-catalogs.js +++ b/ui/core/app/routes/scopes/scope/projects/project/host-catalogs.js @@ -6,6 +6,7 @@ export default class ScopesScopeProjectsProjectHostCatalogsRoute extends Route { // =services + @service intl; @service notify; // =methods @@ -40,11 +41,13 @@ export default class ScopesScopeProjectsProjectHostCatalogsRoute extends Route { */ @action async save(hostCatalog) { + const { isNew } = hostCatalog; try { await hostCatalog.save(); this.refresh(); - // TODO: replace with translated strings - this.notify.success('Save succeeded.'); + this.notify.success( + this.intl.t(isNew ? 'notify.create-success' : 'notify.save-success') + ); this.transitionTo('scopes.scope.projects.project.host-catalogs.host-catalog', hostCatalog); } catch (error) { // TODO: replace with translated strings @@ -61,9 +64,8 @@ export default class ScopesScopeProjectsProjectHostCatalogsRoute extends Route { try { await project.destroyRecord(); this.refresh(); + this.notify.success(this.intl.t('notify.delete-success')); this.transitionTo('scopes.scope.projects.project.host-catalogs'); - // TODO: replace with translated strings - this.notify.success('Deleted host catalog succesfully.'); } catch (error) { // TODO: replace with translated strings this.notify.error(error.message, { closeAfter: null }); diff --git a/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog.js b/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog.js index 00d0b148d..00768575f 100644 --- a/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog.js +++ b/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog.js @@ -18,7 +18,7 @@ export default class ScopesScopeProjectsProjectHostCatalogsHostCatalogRoute exte } /** - * Renders the host-catalog specific templates for header and navigation page sections. + * Renders the host-catalog specific templates for header, navigation, and actions page sections. * @override * @param {object} controller * @param {object} model @@ -37,5 +37,11 @@ export default class ScopesScopeProjectsProjectHostCatalogsHostCatalogRoute exte outlet: 'navigation', model: model }); + + this.render('scopes/scope/projects/project/host-catalogs/host-catalog/-actions', { + into: 'scopes/scope/projects/project/host-catalogs/host-catalog', + outlet: 'actions', + model: model + }); } } diff --git a/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set.js b/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set.js index 7211982fb..66c552c4d 100644 --- a/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set.js +++ b/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set.js @@ -18,7 +18,7 @@ export default class ScopesScopeProjectsProjectHostCatalogsHostCatalogHostSetsHo } /** - * Renders the host-set specific templates for header and navigation page sections. + * Renders the host-set specific templates for header, navigation, and action page sections. * @override * @param {object} controller * @param {object} model @@ -37,5 +37,11 @@ export default class ScopesScopeProjectsProjectHostCatalogsHostCatalogHostSetsHo outlet: 'navigation', model: model }); + + this.render('scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/-actions', { + into: 'scopes/scope/projects/project/host-catalogs/host-catalog', + outlet: 'actions', + model: model + }); } } diff --git a/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/-actions.hbs b/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/-actions.hbs new file mode 100644 index 000000000..b905f8d7d --- /dev/null +++ b/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/-actions.hbs @@ -0,0 +1,9 @@ + + + {{t 'actions.delete-host-catalog'}} + + \ No newline at end of file diff --git a/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/-actions.hbs b/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/-actions.hbs new file mode 100644 index 000000000..9497cdee3 --- /dev/null +++ b/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/-actions.hbs @@ -0,0 +1,9 @@ + + + {{t 'actions.delete-host-set'}} + + \ No newline at end of file diff --git a/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set/index.hbs b/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set/index.hbs index 4ea8678d7..ac0b64897 100644 --- a/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set/index.hbs +++ b/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set/index.hbs @@ -3,11 +3,3 @@ @submit={{route-action "save" @model}} @cancel={{route-action "cancel" @model}} /> - - - {{t 'actions.delete'}} - diff --git a/ui/core/translations/en-us.yaml b/ui/core/translations/en-us.yaml index c8b35c17b..b274633f8 100644 --- a/ui/core/translations/en-us.yaml +++ b/ui/core/translations/en-us.yaml @@ -14,6 +14,7 @@ actions: delete-role: Delete role delete-project: Delete project delete-host-catalog: Delete host catalog + delete-host-set: Delete host set auth: titles: no-scopes: No Scopes Available