From feec5d96f3a68bcf6fbeb8ab7f11f2ba81842274 Mon Sep 17 00:00:00 2001 From: dharini Date: Tue, 25 Jan 2022 19:12:18 -0800 Subject: [PATCH 01/19] typed host catalog init --- .../form/host-catalog/aws/index.hbs | 38 +++++++++++++++++++ .../form/host-catalog/azure/index.hbs | 38 +++++++++++++++++++ .../form/host-catalog/static/index.hbs | 38 +++++++++++++++++++ 3 files changed, 114 insertions(+) create mode 100644 ui/admin/app/components/form/host-catalog/aws/index.hbs create mode 100644 ui/admin/app/components/form/host-catalog/azure/index.hbs create mode 100644 ui/admin/app/components/form/host-catalog/static/index.hbs diff --git a/ui/admin/app/components/form/host-catalog/aws/index.hbs b/ui/admin/app/components/form/host-catalog/aws/index.hbs new file mode 100644 index 000000000..2632020d2 --- /dev/null +++ b/ui/admin/app/components/form/host-catalog/aws/index.hbs @@ -0,0 +1,38 @@ + + + + {{#if @model.errors.name}} + + {{#each @model.errors.name as |error|}} + {{error.message}} + {{/each}} + + {{/if}} + + + + {{#if (can 'save model' @model)}} + + {{/if}} + \ No newline at end of file diff --git a/ui/admin/app/components/form/host-catalog/azure/index.hbs b/ui/admin/app/components/form/host-catalog/azure/index.hbs new file mode 100644 index 000000000..2632020d2 --- /dev/null +++ b/ui/admin/app/components/form/host-catalog/azure/index.hbs @@ -0,0 +1,38 @@ + + + + {{#if @model.errors.name}} + + {{#each @model.errors.name as |error|}} + {{error.message}} + {{/each}} + + {{/if}} + + + + {{#if (can 'save model' @model)}} + + {{/if}} + \ No newline at end of file diff --git a/ui/admin/app/components/form/host-catalog/static/index.hbs b/ui/admin/app/components/form/host-catalog/static/index.hbs new file mode 100644 index 000000000..2632020d2 --- /dev/null +++ b/ui/admin/app/components/form/host-catalog/static/index.hbs @@ -0,0 +1,38 @@ + + + + {{#if @model.errors.name}} + + {{#each @model.errors.name as |error|}} + {{error.message}} + {{/each}} + + {{/if}} + + + + {{#if (can 'save model' @model)}} + + {{/if}} + \ No newline at end of file From f13a3ee18cafe39b4ff1d8d446f2bf8b59675649 Mon Sep 17 00:00:00 2001 From: dharini Date: Wed, 26 Jan 2022 09:34:23 -0800 Subject: [PATCH 02/19] split host catalog into other types --- .../app/components/form/auth-method/index.hbs | 4 +- .../form/host-catalog/aws/index.hbs | 2 +- .../form/host-catalog/azure/index.hbs | 2 +- .../components/form/host-catalog/index.hbs | 65 +++---------------- .../form/host-catalog/static/index.hbs | 2 +- 5 files changed, 16 insertions(+), 59 deletions(-) diff --git a/ui/admin/app/components/form/auth-method/index.hbs b/ui/admin/app/components/form/auth-method/index.hbs index 77cf37d4d..224c8006f 100644 --- a/ui/admin/app/components/form/auth-method/index.hbs +++ b/ui/admin/app/components/form/auth-method/index.hbs @@ -8,4 +8,6 @@ addStringItem=@addStringItem addAccountClaimMapItem=@addAccountClaimMapItem }} -{{/if}} \ No newline at end of file +{{/if}} + +{{{log @model 'mdelll'}}} \ No newline at end of file diff --git a/ui/admin/app/components/form/host-catalog/aws/index.hbs b/ui/admin/app/components/form/host-catalog/aws/index.hbs index 2632020d2..5c8278a97 100644 --- a/ui/admin/app/components/form/host-catalog/aws/index.hbs +++ b/ui/admin/app/components/form/host-catalog/aws/index.hbs @@ -6,7 +6,7 @@ @showEditToggle={{if @model.isNew false true}} --}} as |form| > - +AWASSS! - +AZURE!! +{{#if @model.compositeType}} + {{component + (concat 'form/host-catalog/' @model.compositeType) + model=@model + submit=@submit + cancel=@cancel + changeType=@changeType + }} +{{/if}} - - {{#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}} - - {{#if (can 'save model' @model)}} - - {{/if}} - \ No newline at end of file +{{{log @model 'modede'}}} \ No newline at end of file diff --git a/ui/admin/app/components/form/host-catalog/static/index.hbs b/ui/admin/app/components/form/host-catalog/static/index.hbs index 2632020d2..ab96e4e79 100644 --- a/ui/admin/app/components/form/host-catalog/static/index.hbs +++ b/ui/admin/app/components/form/host-catalog/static/index.hbs @@ -6,7 +6,7 @@ @showEditToggle={{if @model.isNew false true}} --}} as |form| > - +STATIC!! Date: Wed, 26 Jan 2022 14:35:31 -0800 Subject: [PATCH 03/19] static form with radioCards --- .../form/host-catalog/aws/index.hbs | 39 +------------------ .../form/host-catalog/azure/index.hbs | 39 +------------------ .../components/form/host-catalog/index.hbs | 1 - .../form/host-catalog/static/index.hbs | 38 ++++++++++++++++-- 4 files changed, 36 insertions(+), 81 deletions(-) diff --git a/ui/admin/app/components/form/host-catalog/aws/index.hbs b/ui/admin/app/components/form/host-catalog/aws/index.hbs index 5c8278a97..d4a50149c 100644 --- a/ui/admin/app/components/form/host-catalog/aws/index.hbs +++ b/ui/admin/app/components/form/host-catalog/aws/index.hbs @@ -1,38 +1 @@ - -AWASSS! - - {{#if @model.errors.name}} - - {{#each @model.errors.name as |error|}} - {{error.message}} - {{/each}} - - {{/if}} - - - - {{#if (can 'save model' @model)}} - - {{/if}} - \ No newline at end of file +AWS Form \ No newline at end of file diff --git a/ui/admin/app/components/form/host-catalog/azure/index.hbs b/ui/admin/app/components/form/host-catalog/azure/index.hbs index 3bfff4bd0..2c7cb5293 100644 --- a/ui/admin/app/components/form/host-catalog/azure/index.hbs +++ b/ui/admin/app/components/form/host-catalog/azure/index.hbs @@ -1,38 +1 @@ - -AZURE!! - - {{#if @model.errors.name}} - - {{#each @model.errors.name as |error|}} - {{error.message}} - {{/each}} - - {{/if}} - - - - {{#if (can 'save model' @model)}} - - {{/if}} - \ No newline at end of file +Azure Form \ No newline at end of file diff --git a/ui/admin/app/components/form/host-catalog/index.hbs b/ui/admin/app/components/form/host-catalog/index.hbs index 2177276d7..975d98f62 100644 --- a/ui/admin/app/components/form/host-catalog/index.hbs +++ b/ui/admin/app/components/form/host-catalog/index.hbs @@ -4,7 +4,6 @@ model=@model submit=@submit cancel=@cancel - changeType=@changeType }} {{/if}} diff --git a/ui/admin/app/components/form/host-catalog/static/index.hbs b/ui/admin/app/components/form/host-catalog/static/index.hbs index ab96e4e79..b77d02fa5 100644 --- a/ui/admin/app/components/form/host-catalog/static/index.hbs +++ b/ui/admin/app/components/form/host-catalog/static/index.hbs @@ -2,11 +2,8 @@ @onSubmit={{@submit}} @cancel={{@cancel}} @disabled={{@model.isSaving}} - {{!-- @error={{@model.errors.base}} - @showEditToggle={{if @model.isNew false true}} --}} as |form| > -STATIC!! - + + {{#if @model.errors.description}} + + {{#each @model.errors.description as |error|}} + {{error.message}} + {{/each}} + + {{/if}} + + + + + + {{#if (can 'save model' @model)}} Date: Wed, 26 Jan 2022 16:36:11 -0800 Subject: [PATCH 04/19] further updates --- addons/core/translations/resources/en-us.yaml | 1 + .../form/host-catalog/static/index.hbs | 38 +++++++++++-------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/addons/core/translations/resources/en-us.yaml b/addons/core/translations/resources/en-us.yaml index 4ac6c4023..308161cb1 100644 --- a/addons/core/translations/resources/en-us.yaml +++ b/addons/core/translations/resources/en-us.yaml @@ -78,6 +78,7 @@ host-catalog: title: Host Catalog title_plural: Host Catalogs description: A host catalog is a collection of hosts and host sets. + type: Type messages: welcome: title: Welcome to Host Catalogs diff --git a/ui/admin/app/components/form/host-catalog/static/index.hbs b/ui/admin/app/components/form/host-catalog/static/index.hbs index b77d02fa5..1c88faefc 100644 --- a/ui/admin/app/components/form/host-catalog/static/index.hbs +++ b/ui/admin/app/components/form/host-catalog/static/index.hbs @@ -42,21 +42,25 @@ {{/if}} - - - - - + + <:title>{{t 'resources.host-catalog.type'}} + <:body> + + + + + + {{#if (can 'save model' @model)}} {{/if}} - \ No newline at end of file + + +{{{log @model.compositeType 'compostite type'}}} \ No newline at end of file From c1d71e51663889d2dec2818497db7df181b12abf Mon Sep 17 00:00:00 2001 From: Susmitha Girumala Date: Wed, 26 Jan 2022 10:38:04 -0500 Subject: [PATCH 05/19] feat: Add type param support to creation form of host catalog --- .../components/form/host-catalog/index.hbs | 66 ++++++++++++++++++- .../form/host-catalog/static/index.hbs | 2 +- .../routes/scopes/scope/host-catalogs/new.js | 15 ++++- 3 files changed, 79 insertions(+), 4 deletions(-) diff --git a/ui/admin/app/components/form/host-catalog/index.hbs b/ui/admin/app/components/form/host-catalog/index.hbs index 975d98f62..fc04f322d 100644 --- a/ui/admin/app/components/form/host-catalog/index.hbs +++ b/ui/admin/app/components/form/host-catalog/index.hbs @@ -7,4 +7,68 @@ }} {{/if}} -{{{log @model 'modede'}}} \ No newline at end of file +<<<<<<< HEAD +{{{log @model 'modede'}}} +======= + + {{#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}} + + +

Place Radio Button Group Here

+ + {{#if @model.isNew}} + {{#if @model.type}} + {{component + (concat 'form/host-catalog/' @model.type) + model=@model + submit=@submit + cancel=@cancel + }} + {{/if}} + {{/if}} + + {{#if (can 'save model' @model)}} + + {{/if}} + +>>>>>>> 6a8bbcad (feat: Add type param support to creation form of host catalog) diff --git a/ui/admin/app/components/form/host-catalog/static/index.hbs b/ui/admin/app/components/form/host-catalog/static/index.hbs index 1c88faefc..42c75e421 100644 --- a/ui/admin/app/components/form/host-catalog/static/index.hbs +++ b/ui/admin/app/components/form/host-catalog/static/index.hbs @@ -71,4 +71,4 @@ {{/if}} -{{{log @model.compositeType 'compostite type'}}} \ No newline at end of file +{{{log @model.compositeType 'compostite type'}}} diff --git a/ui/admin/app/routes/scopes/scope/host-catalogs/new.js b/ui/admin/app/routes/scopes/scope/host-catalogs/new.js index 9af8baaef..5105e168a 100644 --- a/ui/admin/app/routes/scopes/scope/host-catalogs/new.js +++ b/ui/admin/app/routes/scopes/scope/host-catalogs/new.js @@ -1,16 +1,27 @@ import Route from '@ember/routing/route'; export default class ScopesScopeHostCatalogsNewRoute extends Route { + // =attributes + + queryParams = { + type: { + refreshModel: true, + }, + }; + // =methods /** * Creates a new unsaved host catalog belonging to the current scope. * @return {HostCatalogModel} */ - model() { + model(params) { const scopeModel = this.modelFor('scopes.scope'); + // TODO Use model provider type method + // to set params.type to 'static' if type is not provided + params.type = 'static'; return this.store.createRecord('host-catalog', { - type: 'static', + type: params.type, scopeModel, }); } From cc56fb9636c99667e668f183570e505fcc81bab0 Mon Sep 17 00:00:00 2001 From: Susmitha Girumala Date: Wed, 26 Jan 2022 10:49:28 -0500 Subject: [PATCH 06/19] feat: Trigger update to host catalog type --- ui/admin/app/routes/scopes/scope/host-catalogs/new.js | 10 ++++++++++ .../app/templates/scopes/scope/host-catalogs/new.hbs | 1 + 2 files changed, 11 insertions(+) diff --git a/ui/admin/app/routes/scopes/scope/host-catalogs/new.js b/ui/admin/app/routes/scopes/scope/host-catalogs/new.js index 5105e168a..b8f6a396d 100644 --- a/ui/admin/app/routes/scopes/scope/host-catalogs/new.js +++ b/ui/admin/app/routes/scopes/scope/host-catalogs/new.js @@ -1,4 +1,5 @@ import Route from '@ember/routing/route'; +import { action } from '@ember/object'; export default class ScopesScopeHostCatalogsNewRoute extends Route { // =attributes @@ -25,4 +26,13 @@ export default class ScopesScopeHostCatalogsNewRoute extends Route { scopeModel, }); } + + /** + * Update type of host catalog + * @param {string} type + */ + @action + async changeType(type) { + await this.router.replaceWith({ type }); + } } diff --git a/ui/admin/app/templates/scopes/scope/host-catalogs/new.hbs b/ui/admin/app/templates/scopes/scope/host-catalogs/new.hbs index fb936598e..983c1e86f 100644 --- a/ui/admin/app/templates/scopes/scope/host-catalogs/new.hbs +++ b/ui/admin/app/templates/scopes/scope/host-catalogs/new.hbs @@ -18,6 +18,7 @@ @model={{@model}} @submit={{route-action 'save' @model}} @cancel={{route-action 'cancel' @model}} + @changeType={{route-action 'changeType' @model.type}} /> From 46b6c51f5de0cdbf3ceaadcc8ea3be78fd298601 Mon Sep 17 00:00:00 2001 From: Susmitha Girumala Date: Wed, 26 Jan 2022 10:56:38 -0500 Subject: [PATCH 07/19] feat: Question on default host catalog type value --- ui/admin/app/routes/scopes/scope/host-catalogs/new.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ui/admin/app/routes/scopes/scope/host-catalogs/new.js b/ui/admin/app/routes/scopes/scope/host-catalogs/new.js index b8f6a396d..c95aea7b4 100644 --- a/ui/admin/app/routes/scopes/scope/host-catalogs/new.js +++ b/ui/admin/app/routes/scopes/scope/host-catalogs/new.js @@ -18,8 +18,7 @@ export default class ScopesScopeHostCatalogsNewRoute extends Route { */ model(params) { const scopeModel = this.modelFor('scopes.scope'); - // TODO Use model provider type method - // to set params.type to 'static' if type is not provided + // FIXME Should default static type be specified when type is undefined? params.type = 'static'; return this.store.createRecord('host-catalog', { type: params.type, From 2de2a79e7c8ec4b259aa12af596afea8c6513672 Mon Sep 17 00:00:00 2001 From: Susmitha Girumala Date: Thu, 27 Jan 2022 10:07:50 -0500 Subject: [PATCH 08/19] fix: Protect catalog type selectors in edit mode --- .../components/form/host-catalog/index.hbs | 6 +---- .../form/host-catalog/static/index.hbs | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/ui/admin/app/components/form/host-catalog/index.hbs b/ui/admin/app/components/form/host-catalog/index.hbs index fc04f322d..28a7711d1 100644 --- a/ui/admin/app/components/form/host-catalog/index.hbs +++ b/ui/admin/app/components/form/host-catalog/index.hbs @@ -7,9 +7,6 @@ }} {{/if}} -<<<<<<< HEAD -{{{log @model 'modede'}}} -======= {{/if}} - ->>>>>>> 6a8bbcad (feat: Add type param support to creation form of host catalog) + \ No newline at end of file diff --git a/ui/admin/app/components/form/host-catalog/static/index.hbs b/ui/admin/app/components/form/host-catalog/static/index.hbs index 42c75e421..e39512155 100644 --- a/ui/admin/app/components/form/host-catalog/static/index.hbs +++ b/ui/admin/app/components/form/host-catalog/static/index.hbs @@ -42,6 +42,7 @@ {{/if}} +<<<<<<< HEAD <:title>{{t 'resources.host-catalog.type'}} <:body> @@ -61,6 +62,32 @@ +======= + + {{#if @model.isNew}} + + <:title>{{t 'resources.host-catalog.type'}} + <:body> + + + + + + + {{/if}} + +>>>>>>> f3d3bdd7 (fix: Protect catalog type selectors in edit mode) {{#if (can 'save model' @model)}} Date: Thu, 27 Jan 2022 10:11:12 -0500 Subject: [PATCH 09/19] feat: Add missing queryParam to hostcatalog create controller --- .../controllers/scopes/scope/host-catalogs/new.js | 7 +++++++ .../app/routes/scopes/scope/host-catalogs/new.js | 5 +++++ .../scopes/scope/host-catalogs/new-test.js | 14 ++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 ui/admin/app/controllers/scopes/scope/host-catalogs/new.js create mode 100644 ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/new-test.js diff --git a/ui/admin/app/controllers/scopes/scope/host-catalogs/new.js b/ui/admin/app/controllers/scopes/scope/host-catalogs/new.js new file mode 100644 index 000000000..182b9c423 --- /dev/null +++ b/ui/admin/app/controllers/scopes/scope/host-catalogs/new.js @@ -0,0 +1,7 @@ +import Controller from '@ember/controller'; + +export default class ScopesScopeHostCatalogsNewController extends Controller { + // =attributes + + queryParams = ['type']; +} diff --git a/ui/admin/app/routes/scopes/scope/host-catalogs/new.js b/ui/admin/app/routes/scopes/scope/host-catalogs/new.js index c95aea7b4..43c4a025e 100644 --- a/ui/admin/app/routes/scopes/scope/host-catalogs/new.js +++ b/ui/admin/app/routes/scopes/scope/host-catalogs/new.js @@ -1,7 +1,12 @@ import Route from '@ember/routing/route'; import { action } from '@ember/object'; +import { inject as service } from '@ember/service'; export default class ScopesScopeHostCatalogsNewRoute extends Route { + // =services + + @service router; + // =attributes queryParams = { diff --git a/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/new-test.js b/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/new-test.js new file mode 100644 index 000000000..c872fa28a --- /dev/null +++ b/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/new-test.js @@ -0,0 +1,14 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module('Unit | Controller | scopes/scope/host-catalogs/new', function (hooks) { + setupTest(hooks); + + // TODO: Replace this with your real tests. + test('it exists', function (assert) { + let controller = this.owner.lookup( + 'controller:scopes/scope/host-catalogs/new' + ); + assert.ok(controller); + }); +}); From 67c4440a9091c0ecc29502ad0a233b8471fad387 Mon Sep 17 00:00:00 2001 From: Susmitha Girumala Date: Thu, 27 Jan 2022 10:43:22 -0500 Subject: [PATCH 10/19] fix: Reflect catalog type in creation url --- ui/admin/app/routes/scopes/scope/host-catalogs/new.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ui/admin/app/routes/scopes/scope/host-catalogs/new.js b/ui/admin/app/routes/scopes/scope/host-catalogs/new.js index 43c4a025e..e8bf1cef8 100644 --- a/ui/admin/app/routes/scopes/scope/host-catalogs/new.js +++ b/ui/admin/app/routes/scopes/scope/host-catalogs/new.js @@ -23,20 +23,24 @@ export default class ScopesScopeHostCatalogsNewRoute extends Route { */ model(params) { const scopeModel = this.modelFor('scopes.scope'); - // FIXME Should default static type be specified when type is undefined? - params.type = 'static'; + if (!params.type) params.type = 'static'; return this.store.createRecord('host-catalog', { type: params.type, scopeModel, }); } + afterModel(model) { + this.router.replaceWith({ queryParams: { type: model.compositeType } }); + } + /** * Update type of host catalog * @param {string} type */ @action async changeType(type) { - await this.router.replaceWith({ type }); + console.log(type, 'GET TYPE HERE'); + await this.router.replaceWith({ queryParams: { type } }); } } From 0577cdec76f7bc9b1337140e677a4823731816f0 Mon Sep 17 00:00:00 2001 From: dharini Date: Fri, 28 Jan 2022 00:01:17 -0800 Subject: [PATCH 11/19] more updates --- .../components/form/host-catalog/index.hbs | 70 ++----------------- .../form/host-catalog/plugin/index.hbs | 2 + .../form/host-catalog/static/index.hbs | 30 +------- .../routes/scopes/scope/host-catalogs/new.js | 3 +- 4 files changed, 13 insertions(+), 92 deletions(-) create mode 100644 ui/admin/app/components/form/host-catalog/plugin/index.hbs diff --git a/ui/admin/app/components/form/host-catalog/index.hbs b/ui/admin/app/components/form/host-catalog/index.hbs index 28a7711d1..1b1dbf68d 100644 --- a/ui/admin/app/components/form/host-catalog/index.hbs +++ b/ui/admin/app/components/form/host-catalog/index.hbs @@ -1,70 +1,14 @@ -{{#if @model.compositeType}} +COMES JERE +{{{log 'BLLL' @model.compositeType}}} +{{{log 'NNFRM' @model.isNew}}} + +{{#if @model.isNew}} +{{!-- {{#if @model.compositeType}} --}} {{component (concat 'form/host-catalog/' @model.compositeType) model=@model submit=@submit cancel=@cancel }} +{{!-- {{/if}} --}} {{/if}} - - - {{#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}} - - -

Place Radio Button Group Here

- - {{#if @model.isNew}} - {{#if @model.type}} - {{component - (concat 'form/host-catalog/' @model.type) - model=@model - submit=@submit - cancel=@cancel - }} - {{/if}} - {{/if}} - - {{#if (can 'save model' @model)}} - - {{/if}} - \ No newline at end of file diff --git a/ui/admin/app/components/form/host-catalog/plugin/index.hbs b/ui/admin/app/components/form/host-catalog/plugin/index.hbs new file mode 100644 index 000000000..0191a0174 --- /dev/null +++ b/ui/admin/app/components/form/host-catalog/plugin/index.hbs @@ -0,0 +1,2 @@ +THIS IS DYNAINC +{{{log @model 'NAMEEEE'}}} diff --git a/ui/admin/app/components/form/host-catalog/static/index.hbs b/ui/admin/app/components/form/host-catalog/static/index.hbs index e39512155..bad64bf24 100644 --- a/ui/admin/app/components/form/host-catalog/static/index.hbs +++ b/ui/admin/app/components/form/host-catalog/static/index.hbs @@ -1,3 +1,4 @@ +STATIC {{{log 'STATTTTTIC' @model}}} {{/if}} -
+
--}} {{/if}} -<<<<<<< HEAD <:title>{{t 'resources.host-catalog.type'}} <:body> @@ -62,32 +62,6 @@ -======= - - {{#if @model.isNew}} - - <:title>{{t 'resources.host-catalog.type'}} - <:body> - - - - - - - {{/if}} - ->>>>>>> f3d3bdd7 (fix: Protect catalog type selectors in edit mode) {{#if (can 'save model' @model)}} Date: Fri, 28 Jan 2022 08:53:16 -0800 Subject: [PATCH 12/19] unknown type --- addons/api/addon/models/host-catalog.js | 14 +++++++++++++- .../app/components/form/host-catalog/index.hbs | 4 ++-- .../app/routes/scopes/scope/host-catalogs/new.js | 2 ++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/addons/api/addon/models/host-catalog.js b/addons/api/addon/models/host-catalog.js index ec34b50e3..33fce7bc7 100644 --- a/addons/api/addon/models/host-catalog.js +++ b/addons/api/addon/models/host-catalog.js @@ -26,7 +26,15 @@ export default class HostCatalogModel extends GeneratedHostCatalogModel { * @type {boolean} */ get isUnknown() { - return this.isPlugin && !types.includes(this.plugin.name); + console.log(this.isPlugin, 'IS IT PLUGIN', this.plugin, types); + // if(this.plugin === undefined) { + // console.log('in USEFNNFNF') + // return false; + // } else { + // console.log('in ELSE EE') + + return this.isPlugin && !types.includes(this.plugin.name); + // } } /** @@ -51,6 +59,8 @@ export default class HostCatalogModel extends GeneratedHostCatalogModel { * @type {string} */ get compositeType() { + console.log(this, this.isPlugin, 'WHAT IS PLUGNI'); + // if(this.plugin === undefined) return 'static'; if (this.isUnknown) return 'unknown'; if (this.isPlugin) return this.plugin.name; return 'static'; @@ -65,7 +75,9 @@ export default class HostCatalogModel extends GeneratedHostCatalogModel { this.type = 'static'; } else { this.type = 'plugin'; + this.plugin = { name: type }; + console.log('COMPOSITI' , this.plugin, type) } } } diff --git a/ui/admin/app/components/form/host-catalog/index.hbs b/ui/admin/app/components/form/host-catalog/index.hbs index 1b1dbf68d..1740712ef 100644 --- a/ui/admin/app/components/form/host-catalog/index.hbs +++ b/ui/admin/app/components/form/host-catalog/index.hbs @@ -2,8 +2,8 @@ COMES JERE {{{log 'BLLL' @model.compositeType}}} {{{log 'NNFRM' @model.isNew}}} -{{#if @model.isNew}} -{{!-- {{#if @model.compositeType}} --}} +{{!-- {{#if @model.isNew}} --}} +{{#if @model.compositeType}} {{component (concat 'form/host-catalog/' @model.compositeType) model=@model diff --git a/ui/admin/app/routes/scopes/scope/host-catalogs/new.js b/ui/admin/app/routes/scopes/scope/host-catalogs/new.js index cf9f74624..c93bdbce6 100644 --- a/ui/admin/app/routes/scopes/scope/host-catalogs/new.js +++ b/ui/admin/app/routes/scopes/scope/host-catalogs/new.js @@ -25,8 +25,10 @@ export default class ScopesScopeHostCatalogsNewRoute extends Route { model(params) { const scopeModel = this.modelFor('scopes.scope'); if (!params.type) params.type = 'plugin'; + params.name = 'Avon'; return this.store.createRecord('host-catalog', { type: params.type, + name: params.name, scopeModel, }); } From 19f48b2ca308a1102eca57d910d66a20a965735b Mon Sep 17 00:00:00 2001 From: dharini Date: Fri, 28 Jan 2022 17:27:59 -0800 Subject: [PATCH 13/19] show provider info when dynamic is selected --- .../form/host-catalog/plugin/index.hbs | 2 -- .../form/host-catalog/static/index.hbs | 3 +-- .../form/host-catalog/static/index.js | 26 +++++++++++++++++++ .../routes/scopes/scope/host-catalogs/new.js | 7 ++--- 4 files changed, 29 insertions(+), 9 deletions(-) delete mode 100644 ui/admin/app/components/form/host-catalog/plugin/index.hbs create mode 100644 ui/admin/app/components/form/host-catalog/static/index.js diff --git a/ui/admin/app/components/form/host-catalog/plugin/index.hbs b/ui/admin/app/components/form/host-catalog/plugin/index.hbs deleted file mode 100644 index 0191a0174..000000000 --- a/ui/admin/app/components/form/host-catalog/plugin/index.hbs +++ /dev/null @@ -1,2 +0,0 @@ -THIS IS DYNAINC -{{{log @model 'NAMEEEE'}}} diff --git a/ui/admin/app/components/form/host-catalog/static/index.hbs b/ui/admin/app/components/form/host-catalog/static/index.hbs index bad64bf24..42c75e421 100644 --- a/ui/admin/app/components/form/host-catalog/static/index.hbs +++ b/ui/admin/app/components/form/host-catalog/static/index.hbs @@ -1,4 +1,3 @@ -STATIC {{{log 'STATTTTTIC' @model}}} {{/if}} -
--}} +
Date: Tue, 25 Jan 2022 19:12:18 -0800 Subject: [PATCH 14/19] typed host catalog init --- ui/admin/app/components/form/host-catalog/aws/index.hbs | 2 +- ui/admin/app/components/form/host-catalog/azure/index.hbs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/admin/app/components/form/host-catalog/aws/index.hbs b/ui/admin/app/components/form/host-catalog/aws/index.hbs index d4a50149c..b9990fda4 100644 --- a/ui/admin/app/components/form/host-catalog/aws/index.hbs +++ b/ui/admin/app/components/form/host-catalog/aws/index.hbs @@ -1 +1 @@ -AWS Form \ No newline at end of file +AWS Form diff --git a/ui/admin/app/components/form/host-catalog/azure/index.hbs b/ui/admin/app/components/form/host-catalog/azure/index.hbs index 2c7cb5293..0dea00f73 100644 --- a/ui/admin/app/components/form/host-catalog/azure/index.hbs +++ b/ui/admin/app/components/form/host-catalog/azure/index.hbs @@ -1 +1 @@ -Azure Form \ No newline at end of file +Azure Form From 043b760cd67397c42cc668b4fb2edf3f5431f485 Mon Sep 17 00:00:00 2001 From: dharini Date: Fri, 28 Jan 2022 00:01:17 -0800 Subject: [PATCH 15/19] more updates --- ui/admin/app/components/form/host-catalog/plugin/index.hbs | 2 ++ ui/admin/app/components/form/host-catalog/static/index.hbs | 3 ++- ui/admin/app/routes/scopes/scope/host-catalogs/new.js | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 ui/admin/app/components/form/host-catalog/plugin/index.hbs diff --git a/ui/admin/app/components/form/host-catalog/plugin/index.hbs b/ui/admin/app/components/form/host-catalog/plugin/index.hbs new file mode 100644 index 000000000..0191a0174 --- /dev/null +++ b/ui/admin/app/components/form/host-catalog/plugin/index.hbs @@ -0,0 +1,2 @@ +THIS IS DYNAINC +{{{log @model 'NAMEEEE'}}} diff --git a/ui/admin/app/components/form/host-catalog/static/index.hbs b/ui/admin/app/components/form/host-catalog/static/index.hbs index 42c75e421..bad64bf24 100644 --- a/ui/admin/app/components/form/host-catalog/static/index.hbs +++ b/ui/admin/app/components/form/host-catalog/static/index.hbs @@ -1,3 +1,4 @@ +STATIC {{{log 'STATTTTTIC' @model}}} {{/if}} -
+ --}} Date: Fri, 28 Jan 2022 08:53:16 -0800 Subject: [PATCH 16/19] unknown type --- ui/admin/app/routes/scopes/scope/host-catalogs/new.js | 1 + 1 file changed, 1 insertion(+) diff --git a/ui/admin/app/routes/scopes/scope/host-catalogs/new.js b/ui/admin/app/routes/scopes/scope/host-catalogs/new.js index 62ed87dfc..f299f980c 100644 --- a/ui/admin/app/routes/scopes/scope/host-catalogs/new.js +++ b/ui/admin/app/routes/scopes/scope/host-catalogs/new.js @@ -25,6 +25,7 @@ export default class ScopesScopeHostCatalogsNewRoute extends Route { model(params) { const scopeModel = this.modelFor('scopes.scope'); if (!params.type) params.type = 'plugin'; + params.name = 'Avon'; return this.store.createRecord('host-catalog', { compositeType: params.type, //static or aws or azure scopeModel, From 73566b0583f3475271fd2c31909fb763071f826d Mon Sep 17 00:00:00 2001 From: dharini Date: Fri, 28 Jan 2022 17:27:59 -0800 Subject: [PATCH 17/19] show provider info when dynamic is selected --- ui/admin/app/components/form/host-catalog/plugin/index.hbs | 2 -- ui/admin/app/components/form/host-catalog/static/index.hbs | 3 +-- ui/admin/app/routes/scopes/scope/host-catalogs/new.js | 3 +-- 3 files changed, 2 insertions(+), 6 deletions(-) delete mode 100644 ui/admin/app/components/form/host-catalog/plugin/index.hbs diff --git a/ui/admin/app/components/form/host-catalog/plugin/index.hbs b/ui/admin/app/components/form/host-catalog/plugin/index.hbs deleted file mode 100644 index 0191a0174..000000000 --- a/ui/admin/app/components/form/host-catalog/plugin/index.hbs +++ /dev/null @@ -1,2 +0,0 @@ -THIS IS DYNAINC -{{{log @model 'NAMEEEE'}}} diff --git a/ui/admin/app/components/form/host-catalog/static/index.hbs b/ui/admin/app/components/form/host-catalog/static/index.hbs index bad64bf24..42c75e421 100644 --- a/ui/admin/app/components/form/host-catalog/static/index.hbs +++ b/ui/admin/app/components/form/host-catalog/static/index.hbs @@ -1,4 +1,3 @@ -STATIC {{{log 'STATTTTTIC' @model}}} {{/if}} - --}} + Date: Mon, 31 Jan 2022 13:16:03 -0800 Subject: [PATCH 18/19] rebase main --- addons/api/addon/models/host-catalog.js | 14 +------------- ui/admin/app/components/form/auth-method/index.hbs | 4 +--- .../app/components/form/host-catalog/index.hbs | 8 ++------ 3 files changed, 4 insertions(+), 22 deletions(-) diff --git a/addons/api/addon/models/host-catalog.js b/addons/api/addon/models/host-catalog.js index 33fce7bc7..ec34b50e3 100644 --- a/addons/api/addon/models/host-catalog.js +++ b/addons/api/addon/models/host-catalog.js @@ -26,15 +26,7 @@ export default class HostCatalogModel extends GeneratedHostCatalogModel { * @type {boolean} */ get isUnknown() { - console.log(this.isPlugin, 'IS IT PLUGIN', this.plugin, types); - // if(this.plugin === undefined) { - // console.log('in USEFNNFNF') - // return false; - // } else { - // console.log('in ELSE EE') - - return this.isPlugin && !types.includes(this.plugin.name); - // } + return this.isPlugin && !types.includes(this.plugin.name); } /** @@ -59,8 +51,6 @@ export default class HostCatalogModel extends GeneratedHostCatalogModel { * @type {string} */ get compositeType() { - console.log(this, this.isPlugin, 'WHAT IS PLUGNI'); - // if(this.plugin === undefined) return 'static'; if (this.isUnknown) return 'unknown'; if (this.isPlugin) return this.plugin.name; return 'static'; @@ -75,9 +65,7 @@ export default class HostCatalogModel extends GeneratedHostCatalogModel { this.type = 'static'; } else { this.type = 'plugin'; - this.plugin = { name: type }; - console.log('COMPOSITI' , this.plugin, type) } } } diff --git a/ui/admin/app/components/form/auth-method/index.hbs b/ui/admin/app/components/form/auth-method/index.hbs index 224c8006f..77cf37d4d 100644 --- a/ui/admin/app/components/form/auth-method/index.hbs +++ b/ui/admin/app/components/form/auth-method/index.hbs @@ -8,6 +8,4 @@ addStringItem=@addStringItem addAccountClaimMapItem=@addAccountClaimMapItem }} -{{/if}} - -{{{log @model 'mdelll'}}} \ No newline at end of file +{{/if}} \ No newline at end of file diff --git a/ui/admin/app/components/form/host-catalog/index.hbs b/ui/admin/app/components/form/host-catalog/index.hbs index 1740712ef..35a4a94bd 100644 --- a/ui/admin/app/components/form/host-catalog/index.hbs +++ b/ui/admin/app/components/form/host-catalog/index.hbs @@ -1,8 +1,4 @@ -COMES JERE -{{{log 'BLLL' @model.compositeType}}} -{{{log 'NNFRM' @model.isNew}}} - -{{!-- {{#if @model.isNew}} --}} +{{#if @model.isNew}} {{#if @model.compositeType}} {{component (concat 'form/host-catalog/' @model.compositeType) @@ -10,5 +6,5 @@ COMES JERE submit=@submit cancel=@cancel }} -{{!-- {{/if}} --}} +{{/if}} {{/if}} From 55acdc76b6abf595209f55781014dd7fcd075873 Mon Sep 17 00:00:00 2001 From: dharini Date: Tue, 1 Feb 2022 11:12:33 -0800 Subject: [PATCH 19/19] move up component logic --- addons/core/translations/resources/en-us.yaml | 8 ++ .../form/host-catalog/aws/index.hbs | 130 +++++++++++++++++- .../form/host-catalog/azure/index.hbs | 130 +++++++++++++++++- .../components/form/host-catalog/index.hbs | 32 +++-- .../app/components/form/host-catalog/index.js | 29 ++++ .../form/host-catalog/static/index.hbs | 40 +++++- .../form/host-catalog/static/index.js | 26 ---- .../scopes/scope/host-catalogs/new.js | 16 +++ .../routes/scopes/scope/host-catalogs/new.js | 3 +- 9 files changed, 370 insertions(+), 44 deletions(-) create mode 100644 ui/admin/app/components/form/host-catalog/index.js delete mode 100644 ui/admin/app/components/form/host-catalog/static/index.js diff --git a/addons/core/translations/resources/en-us.yaml b/addons/core/translations/resources/en-us.yaml index 308161cb1..d7a3a1db3 100644 --- a/addons/core/translations/resources/en-us.yaml +++ b/addons/core/translations/resources/en-us.yaml @@ -89,6 +89,14 @@ host-catalog: unknown: Unknown aws: AWS azure: Azure + dynamic: Dynamic + form: + provider-details: Provider Details + types: + static: + help: Provide a list of hosts and host sets with static addresses + dynamic: + help: Automate discovery of target hosts and services on Azure or AWS host-set: title: Host Set title_plural: Host Sets diff --git a/ui/admin/app/components/form/host-catalog/aws/index.hbs b/ui/admin/app/components/form/host-catalog/aws/index.hbs index b9990fda4..208468752 100644 --- a/ui/admin/app/components/form/host-catalog/aws/index.hbs +++ b/ui/admin/app/components/form/host-catalog/aws/index.hbs @@ -1 +1,129 @@ -AWS Form + + + {{#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}} + + + <:title>{{t 'form.type.label'}} + <:body> + + + + + + + + {{#if @showDynamicPlugins}} + + <:title>{{t 'resources.host-catalog.form.provider-details'}} + <:body> + + + + + + + {{/if}} + + + + + + + + {{#if (can 'save model' @model)}} + + {{/if}} + \ No newline at end of file diff --git a/ui/admin/app/components/form/host-catalog/azure/index.hbs b/ui/admin/app/components/form/host-catalog/azure/index.hbs index 0dea00f73..208468752 100644 --- a/ui/admin/app/components/form/host-catalog/azure/index.hbs +++ b/ui/admin/app/components/form/host-catalog/azure/index.hbs @@ -1 +1,129 @@ -Azure Form + + + {{#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}} + + + <:title>{{t 'form.type.label'}} + <:body> + + + + + + + + {{#if @showDynamicPlugins}} + + <:title>{{t 'resources.host-catalog.form.provider-details'}} + <:body> + + + + + + + {{/if}} + + + + + + + + {{#if (can 'save model' @model)}} + + {{/if}} + \ No newline at end of file diff --git a/ui/admin/app/components/form/host-catalog/index.hbs b/ui/admin/app/components/form/host-catalog/index.hbs index 35a4a94bd..d41b3749b 100644 --- a/ui/admin/app/components/form/host-catalog/index.hbs +++ b/ui/admin/app/components/form/host-catalog/index.hbs @@ -1,10 +1,24 @@ {{#if @model.isNew}} -{{#if @model.compositeType}} - {{component - (concat 'form/host-catalog/' @model.compositeType) - model=@model - submit=@submit - cancel=@cancel - }} -{{/if}} -{{/if}} +
{{@model.type}} {{@model.compositeType}}
+ {{#if @model.isStatic}} + {{component + (concat 'form/host-catalog/' @model.compositeType) + model=@model + submit=@submit + cancel=@cancel + toggleType=this.toggleType + showDynamicPlugins=this.showDynamicPlugins + }} + {{/if}} + + {{#if this.showDynamicPlugins}} + {{component + (concat 'form/host-catalog/' @model.compositeType) + model=@model + submit=@submit + cancel=@cancel + toggleType=this.toggleType + showDynamicPlugins=this.showDynamicPlugins + }} + {{/if}} +{{/if}} \ No newline at end of file diff --git a/ui/admin/app/components/form/host-catalog/index.js b/ui/admin/app/components/form/host-catalog/index.js new file mode 100644 index 000000000..ed49133db --- /dev/null +++ b/ui/admin/app/components/form/host-catalog/index.js @@ -0,0 +1,29 @@ +import Component from '@glimmer/component'; +import { action } from '@ember/object'; +import { tracked } from '@glimmer/tracking'; + +export default class FormHostCatalogIndexComponent extends Component { + // =properties + /** + /** + */ + @tracked showDynamicPlugins = false; + // =actions + + @action + toggleType(type) { + this.renderDynamicPlugins(type); + } + //show dynamic type radio cards -> aws and azure if the type is dynamic + //call route action to update the query and rerender the model if static is selected + renderDynamicPlugins(type) { + if (type === 'dynamic') { + this.showDynamicPlugins = true; + } else { + this.showDynamicPlugins = false; + //CHECK:how to call the action to update query param + this.args.model.type = 'static'; + this.args.changeType(); + } + } +} diff --git a/ui/admin/app/components/form/host-catalog/static/index.hbs b/ui/admin/app/components/form/host-catalog/static/index.hbs index 42c75e421..c3201cb81 100644 --- a/ui/admin/app/components/form/host-catalog/static/index.hbs +++ b/ui/admin/app/components/form/host-catalog/static/index.hbs @@ -43,9 +43,14 @@ {{/if}}
- <:title>{{t 'resources.host-catalog.type'}} + <:title>{{t 'form.type.label'}} <:body> - + + + {{#if @showDynamicPlugins}} + + <:title>{{t 'resources.host-catalog.form.provider-details'}} + <:body> + + + + + + + {{/if}} + {{#if (can 'save model' @model)}} {{/if}} -
- -{{{log @model.compositeType 'compostite type'}}} + \ No newline at end of file diff --git a/ui/admin/app/components/form/host-catalog/static/index.js b/ui/admin/app/components/form/host-catalog/static/index.js deleted file mode 100644 index 8b55cf8b8..000000000 --- a/ui/admin/app/components/form/host-catalog/static/index.js +++ /dev/null @@ -1,26 +0,0 @@ -import Component from '@glimmer/component'; -import { options } from 'api/models/credential-library'; -import { computed, action } from '@ember/object'; -import { tracked } from '@glimmer/tracking'; - -export default class FormHostCatalogIndexComponent extends Component { - // =properties - /** - /** - */ - @tracked showDynamicPlugins = false; - // =actions - - @action - toggleType(type) { - this.renderDynamicPlugins(type); - } - renderDynamicPlugins(type) { - if(type === 'dynamic') { - this.showDynamicPlugins = true; - } else { - this.showDynamicPlugins = false; - } - } - -} diff --git a/ui/admin/app/controllers/scopes/scope/host-catalogs/new.js b/ui/admin/app/controllers/scopes/scope/host-catalogs/new.js index 182b9c423..3b0c5b729 100644 --- a/ui/admin/app/controllers/scopes/scope/host-catalogs/new.js +++ b/ui/admin/app/controllers/scopes/scope/host-catalogs/new.js @@ -1,7 +1,23 @@ import Controller from '@ember/controller'; +import { tracked } from '@glimmer/tracking'; +import { action } from '@ember/object'; export default class ScopesScopeHostCatalogsNewController extends Controller { // =attributes queryParams = ['type']; + @tracked showDynamicPlugins = false; + + @action + async toggleType(type) { + this.renderDynamicPlugins(type); + } + + renderDynamicPlugins(type) { + if (type !== 'static') { + this.showDynamicPlugins = true; + } else { + this.showDynamicPlugins = false; + } + } } diff --git a/ui/admin/app/routes/scopes/scope/host-catalogs/new.js b/ui/admin/app/routes/scopes/scope/host-catalogs/new.js index 49a4a69da..53a2fea97 100644 --- a/ui/admin/app/routes/scopes/scope/host-catalogs/new.js +++ b/ui/admin/app/routes/scopes/scope/host-catalogs/new.js @@ -6,13 +6,12 @@ export default class ScopesScopeHostCatalogsNewRoute extends Route { // =services @service router; - // =attributes queryParams = { type: { refreshModel: true, - replace: true + replace: true, }, };