From 55acdc76b6abf595209f55781014dd7fcd075873 Mon Sep 17 00:00:00 2001 From: dharini Date: Tue, 1 Feb 2022 11:12:33 -0800 Subject: [PATCH] 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, }, };