Jordan Reimer 771d8c6e7f
[UI] Ember Data Migration - Sync Destination Create/Edit (#30620)
* adds field group support to forms

* adds forms for sync destination types

* adds type for sync destination form

* adds readonlyParams to sync-destinations helper and error handling to findDestination util

* updates sync destinations create/edit routes to use forms

* updates sync create-and-edit component to use form class and api service

* updates sync destinations tests
2025-05-14 20:00:28 -06:00

48 lines
1.7 KiB
TypeScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import Form from 'vault/forms/form';
import FormField from 'vault/utils/forms/field';
import FormFieldGroup from 'vault/utils/forms/field-group';
import { commonFields, getPayload } from './shared';
import type { SystemWriteSyncDestinationsGhNameRequest } from '@hashicorp/vault-client-typescript';
type GhFormData = Partial<SystemWriteSyncDestinationsGhNameRequest>;
export default class GcpSmForm extends Form {
declare data: GhFormData;
formFieldGroups = [
new FormFieldGroup('default', [
commonFields.name,
new FormField('repositoryOwner', 'string', {
subText:
'Github organization or username that owns the repository. If empty, Vault will use the GITHUB_REPOSITORY_OWNER environment variable if configured.',
editDisabled: true,
}),
new FormField('repositoryName', 'string', {
subText:
'The name of the Github repository to connect to. If empty, Vault will use the GITHUB_REPOSITORY_NAME environment variable if configured.',
editDisabled: true,
}),
]),
new FormFieldGroup('Credentials', [
new FormField('accessToken', 'string', {
subText:
'Personal access token to authenticate to the GitHub repository. If empty, Vault will use the GITHUB_ACCESS_TOKEN environment variable if configured.',
sensitive: true,
noCopy: true,
}),
]),
new FormFieldGroup('Advanced configuration', [commonFields.granularity, commonFields.secretNameTemplate]),
];
toJSON() {
const formState = super.toJSON();
return { ...formState, data: getPayload('gh', this.data, this.isNew) };
}
}