From 240a544d82f38c157f74f3148d891cbe4cde9555 Mon Sep 17 00:00:00 2001 From: hashicc <191911133+hashicc@users.noreply.github.com> Date: Mon, 6 Oct 2025 12:09:42 -0700 Subject: [PATCH] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20remove=20dynamic=20c?= =?UTF-8?q?omponent=20helper=20from=20form/authenticate=20(#3012)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: 💡 remove dynamic component helper from form/authenticate * Add missing copyright headers --- .../components/form/authenticate/index.hbs | 9 +++---- .../components/form/authenticate/index.js | 27 +++++++++++++++++++ .../app/components/form/authenticate/index.js | 6 +++++ 3 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 addons/core/addon/components/form/authenticate/index.js create mode 100644 addons/core/app/components/form/authenticate/index.js diff --git a/addons/core/addon/components/form/authenticate/index.hbs b/addons/core/addon/components/form/authenticate/index.hbs index fff4ef916..a46f6bdc0 100644 --- a/addons/core/addon/components/form/authenticate/index.hbs +++ b/addons/core/addon/components/form/authenticate/index.hbs @@ -4,9 +4,8 @@ }} {{#if @model.type}} - {{component - (concat 'form/authenticate/' @model.type) - onSubmit=@submit - disabled=@disabled - }} + {{/if}} \ No newline at end of file diff --git a/addons/core/addon/components/form/authenticate/index.js b/addons/core/addon/components/form/authenticate/index.js new file mode 100644 index 000000000..5b39c5bb5 --- /dev/null +++ b/addons/core/addon/components/form/authenticate/index.js @@ -0,0 +1,27 @@ +/** + * Copyright (c) HashiCorp, Inc. + * SPDX-License-Identifier: BUSL-1.1 + */ + +import Component from '@glimmer/component'; +import { assert } from '@ember/debug'; +import oidc from './oidc'; +import ldap from './ldap'; +import password from './password'; + +const modelTypeToComponent = { + ldap, + password, + oidc, +}; + +export default class FormAuthenticateIndex extends Component { + get authenticateFormComponent() { + const component = modelTypeToComponent[this.args.model.type]; + assert( + `Mapped component must exist for auth method: ${this.args.model.type}`, + component, + ); + return component; + } +} diff --git a/addons/core/app/components/form/authenticate/index.js b/addons/core/app/components/form/authenticate/index.js new file mode 100644 index 000000000..b33d6c167 --- /dev/null +++ b/addons/core/app/components/form/authenticate/index.js @@ -0,0 +1,6 @@ +/** + * Copyright (c) HashiCorp, Inc. + * SPDX-License-Identifier: BUSL-1.1 + */ + +export { default } from 'core/components/form/authenticate/index';