2023-03-01 09:39:41 -06:00
|
|
|
/**
|
2026-01-28 17:09:06 -08:00
|
|
|
* Copyright IBM Corp. 2021, 2026
|
2024-05-31 11:29:24 -07:00
|
|
|
* SPDX-License-Identifier: BUSL-1.1
|
2023-03-01 09:39:41 -06:00
|
|
|
*/
|
|
|
|
|
|
2022-12-12 16:37:01 -08:00
|
|
|
import Component from '@glimmer/component';
|
2025-11-25 13:32:58 -05:00
|
|
|
import { assert } from '@ember/debug';
|
|
|
|
|
import {
|
|
|
|
|
TYPES_CREDENTIAL,
|
|
|
|
|
TYPE_CREDENTIAL_USERNAME_PASSWORD,
|
|
|
|
|
TYPE_CREDENTIAL_SSH_PRIVATE_KEY,
|
|
|
|
|
TYPE_CREDENTIAL_JSON,
|
|
|
|
|
TYPE_CREDENTIAL_USERNAME_PASSWORD_DOMAIN,
|
|
|
|
|
TYPE_CREDENTIAL_PASSWORD,
|
|
|
|
|
} from 'api/models/credential';
|
|
|
|
|
import usernamePasswordFormComponent from './username_password';
|
|
|
|
|
import sshPrivateKeyFormComponent from './ssh_private_key';
|
|
|
|
|
import jsonFormComponent from './json';
|
|
|
|
|
import usernamePasswordDomainFormComponent from './username_password_domain';
|
|
|
|
|
import passwordFormComponent from './password';
|
|
|
|
|
|
|
|
|
|
const modelTypeToComponent = {
|
|
|
|
|
[TYPE_CREDENTIAL_USERNAME_PASSWORD]: usernamePasswordFormComponent,
|
|
|
|
|
[TYPE_CREDENTIAL_SSH_PRIVATE_KEY]: sshPrivateKeyFormComponent,
|
|
|
|
|
[TYPE_CREDENTIAL_JSON]: jsonFormComponent,
|
|
|
|
|
[TYPE_CREDENTIAL_USERNAME_PASSWORD_DOMAIN]:
|
|
|
|
|
usernamePasswordDomainFormComponent,
|
|
|
|
|
[TYPE_CREDENTIAL_PASSWORD]: passwordFormComponent,
|
|
|
|
|
};
|
2022-12-12 16:37:01 -08:00
|
|
|
|
|
|
|
|
export default class FormCredentialComponent extends Component {
|
|
|
|
|
// =attributes
|
2025-11-06 14:44:53 -08:00
|
|
|
|
2022-12-12 16:37:01 -08:00
|
|
|
/**
|
|
|
|
|
* Returns an array of available credential types the user can create
|
|
|
|
|
* @type {object}
|
|
|
|
|
*/
|
|
|
|
|
get credentialTypes() {
|
2025-11-06 14:44:53 -08:00
|
|
|
return TYPES_CREDENTIAL;
|
2022-12-12 16:37:01 -08:00
|
|
|
}
|
2025-11-25 13:32:58 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the form component for the credential model type
|
|
|
|
|
* @type {Component}
|
|
|
|
|
*/
|
|
|
|
|
get credentialFormComponent() {
|
|
|
|
|
const component = modelTypeToComponent[this.args.model.type];
|
|
|
|
|
assert(
|
|
|
|
|
`Mapped component must exist for credential type: ${this.args.model.type}`,
|
|
|
|
|
component,
|
|
|
|
|
);
|
|
|
|
|
return component;
|
|
|
|
|
}
|
2022-12-12 16:37:01 -08:00
|
|
|
}
|