* feat: 🎸 ldap auth-method new form component ✅ Closes: ICU-10073 * style: 💄 fix linting error and add comment * style: 💄 add spacing and make titles more bold * Update ui/admin/app/components/form/auth-method/ldap/index.hbs Co-authored-by: Dharini Jeeva <dharini@hashicorp.com> * refactor: 💡 pr feedback updates --------- Co-authored-by: Dharini Jeeva <dharini@hashicorp.com>
82 lines
1.6 KiB
JavaScript
82 lines
1.6 KiB
JavaScript
import Component from '@glimmer/component';
|
|
import { action } from '@ember/object';
|
|
import { tracked } from '@glimmer/tracking';
|
|
import { options } from 'api/models/auth-method';
|
|
|
|
export default class FormAuthMethodLdapComponent extends Component {
|
|
// =attributes
|
|
/**
|
|
* @type {object}
|
|
*/
|
|
toAttributes = options.ldap.account_attribute_maps.to;
|
|
|
|
/**
|
|
* @type {string}
|
|
*/
|
|
newToAttribute = options.ldap.account_attribute_maps.to[0];
|
|
|
|
/**
|
|
* @type {string}
|
|
*/
|
|
@tracked newFromAttribute = '';
|
|
|
|
/**
|
|
* @type {string}
|
|
*/
|
|
@tracked newCertificate = '';
|
|
|
|
/**
|
|
* @type {string}
|
|
*/
|
|
@tracked urlsArrayString = this.parseUrlsArray();
|
|
|
|
//actions
|
|
|
|
/**
|
|
* @param {object} event
|
|
*/
|
|
@action
|
|
toggleField(event) {
|
|
const { name: field } = event.target;
|
|
this.args.model[field] = !this.args.model[field];
|
|
}
|
|
|
|
@action
|
|
addCertificate() {
|
|
if (this.newCertificate) {
|
|
this.args.addStringItem('certificates', this.newCertificate);
|
|
}
|
|
this.newCertificate = '';
|
|
}
|
|
|
|
@action
|
|
addAttributeMap() {
|
|
if (this.newFromAttribute) {
|
|
this.args.addAccountMapItem(
|
|
'account_attribute_maps',
|
|
this.newFromAttribute,
|
|
this.newToAttribute
|
|
);
|
|
}
|
|
this.newFromAttribute = '';
|
|
}
|
|
|
|
/**
|
|
* @param {object} event
|
|
*/
|
|
@action
|
|
setUrls(event) {
|
|
const { value } = event.target;
|
|
this.urlsArrayString = value;
|
|
const array = value.split(',').map((item) => ({ value: item }));
|
|
this.args.model.set('urls', array);
|
|
}
|
|
|
|
/**
|
|
* @returns {string}
|
|
*/
|
|
parseUrlsArray() {
|
|
return (this.args.model.urls || []).map((item) => item.value).toString();
|
|
}
|
|
}
|