mirror of
https://github.com/hashicorp/vault.git
synced 2026-05-28 04:10:44 -04:00
* updating policies to use api instead of ember models * minor fixes * pr comments pt1 * PR comments pt2 * test fix * updating test * updating intefaces * updating to remove model arg * remove comments * refactor for pr comments * fixes * form field fix Co-authored-by: Dan Rivera <dan.rivera@hashicorp.com>
47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
/**
|
|
* Copyright IBM Corp. 2016, 2025
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import { tracked } from '@glimmer/tracking';
|
|
import Form from 'vault/forms/form';
|
|
import FormField from 'vault/utils/forms/field';
|
|
|
|
type PolicyFormData = {
|
|
name: string;
|
|
policy: string;
|
|
enforcement_level?: string;
|
|
paths?: string[];
|
|
};
|
|
|
|
export default class PolicyForm extends Form<PolicyFormData> {
|
|
@tracked declare policyType: string;
|
|
|
|
formFields = [
|
|
new FormField('name', 'string', {
|
|
label: 'Policy name',
|
|
placeholder: 'Enter the policy name',
|
|
}),
|
|
new FormField('policy', undefined, { editType: 'yield', label: '' }),
|
|
];
|
|
fieldProps = ['formFields', 'additionalFields'];
|
|
|
|
get additionalFields() {
|
|
if (this.policyType === 'acl') {
|
|
return [];
|
|
}
|
|
|
|
const fields = [
|
|
new FormField('enforcement_level', 'string', {
|
|
possibleValues: ['hard-mandatory', 'soft-mandatory', 'advisory'],
|
|
label: 'Enforcement level',
|
|
}),
|
|
];
|
|
|
|
if (this.policyType == 'egp') {
|
|
fields.push(new FormField('paths', 'string', { editType: 'stringArray' }));
|
|
}
|
|
|
|
return fields;
|
|
}
|
|
}
|