Skip to content

Commit

Permalink
clean up getters on model
Browse files Browse the repository at this point in the history
  • Loading branch information
Monkeychip committed Dec 18, 2024
1 parent 1442b4a commit 9b8fe6e
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions ui/app/models/azure/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,33 @@ export default class AzureConfig extends Model {
'environment',
];

// for configuration details view
// do not include clientSecret because it is never returned by the API
get displayAttrs() {
return this.formFields.filter((attr) => attr.name !== 'clientSecret');
}

/* GETTERS used by configure-azure component
these getters help:
1. determine if the model is new or existing
2. if wif or azure attributes have been configured
*/
get isConfigured() {
// if every value is falsy, this engine has not been configured yet
return !this.configurableParams.every((param) => !this[param]);
}

// formFields are iterated through to generate the edit/create view
get formFields() {
return expandAttributeMeta(this, this.configurableParams);
get isWifPluginConfigured() {
return !!this.identityTokenAudience || !!this.identityTokenTtl;
}

get isAzureAccountConfigured() {
// clientSecret is not checked here because it's never return by the API
// however it is an Azure account field
return !!this.rootPasswordTtl;
}

/* GETTERS used to generate array of fields to be displayed in:
1. details view
2. edit/create view
*/
get displayAttrs() {
const formFields = expandAttributeMeta(this, this.configurableParams);
return formFields.filter((attr) => attr.name !== 'clientSecret');
}

// "filedGroupsWif" and "fieldGroupsAzure" are passed to the FormFieldGroups component to determine which group to show in the form (ex: @groupName="fieldGroupsWif")
Expand All @@ -75,16 +88,6 @@ export default class AzureConfig extends Model {
return fieldToAttrs(this, this.formFieldGroups('azure'));
}

get isWifPluginConfigured() {
return !!this.identityTokenAudience || !!this.identityTokenTtl;
}

get isAzureAccountConfigured() {
// clientSecret is not checked here because it's never return by the API
// however it is an Azure account field
return !!this.rootPasswordTtl;
}

formFieldGroups(accessType = 'azure') {
const formFieldGroups = [];
formFieldGroups.push({
Expand Down

0 comments on commit 9b8fe6e

Please sign in to comment.