bzp2010 commented on code in PR #3019:
URL: https://github.com/apache/apisix-dashboard/pull/3019#discussion_r2078890550
##########
src/components/form-slice/FormPartSecret.tsx:
##########
@@ -0,0 +1,172 @@
+import { useFormContext } from 'react-hook-form';
+import { APISIX, type APISIXType } from '@/types/schema/apisix';
+import { FormItemSwitch } from '@/components/form/Switch';
+import { FormItemTextInput } from '@/components/form/TextInput';
+import { useTranslation } from 'react-i18next';
+import { FormSection } from './FormSection';
+import { FormItemSelect } from '@/components/form/Select';
+import { Divider, InputWrapper } from '@mantine/core';
+import { FormItemTagsInput } from '../form/TagInput';
+
+const VaultSecretForm = () => {
+ const { t } = useTranslation();
+ const { control } = useFormContext<APISIXType['Secret']>();
+
+ return (
+ <>
+ <FormItemTextInput
+ control={control}
+ name="uri"
+ label={t('form.secrets.vault.uri')}
+ />
+ <FormItemTextInput
+ control={control}
+ name="prefix"
+ label={t('form.secrets.vault.prefix')}
+ />
+ <FormItemTextInput
+ control={control}
+ name="token"
+ label={t('form.secrets.vault.token')}
+ />
+ <FormItemTextInput
+ control={control}
+ name="namespace"
+ label={t('form.secrets.vault.namespace')}
+ />
+ </>
+ );
+};
+
+const AWSSecretForm = () => {
+ const { t } = useTranslation();
+ const { control } = useFormContext<APISIXType['Secret']>();
+
+ return (
+ <>
+ <FormItemTextInput
+ control={control}
+ name="access_key_id"
+ label={t('form.secrets.aws.access_key_id')}
+ />
+ <FormItemTextInput
+ control={control}
+ name="secret_access_key"
+ label={t('form.secrets.aws.secret_access_key')}
+ />
+ <FormItemTextInput
+ control={control}
+ name="session_token"
+ label={t('form.secrets.aws.session_token')}
+ />
+
+ <FormItemTextInput
+ control={control}
+ name="region"
+ label={t('form.secrets.aws.region')}
+ />
+ <FormItemTextInput
+ control={control}
+ name="endpoint_url"
+ label={t('form.secrets.aws.endpoint_url')}
+ />
+ </>
+ );
+};
+
+const GCPSecretForm = () => {
+ const { t } = useTranslation();
+ const { control } = useFormContext<APISIXType['Secret']>();
+
+ return (
+ <>
+ <InputWrapper label={t('form.secrets.gcp.ssl_verify')}>
+ <FormItemSwitch control={control} name="ssl_verify" />
+ </InputWrapper>
+ <FormSection legend={t('form.secrets.gcp.auth')}>
+ <FormItemTextInput
+ control={control}
+ name="auth_file"
+ label={t('form.secrets.gcp.auth_file')}
+ />
+ <Divider my="xs" label={t('or')} />
+ <FormSection legend={t('form.secrets.gcp.auth_config')}>
+ <FormItemTextInput
+ control={control}
+ name="auth_config.client_email"
+ label={t('form.secrets.gcp.client_email')}
+ />
+ <FormItemTextInput
+ control={control}
+ name="auth_config.private_key"
+ label={t('form.secrets.gcp.private_key')}
+ />
+ <FormItemTextInput
+ control={control}
+ name="auth_config.project_id"
+ label={t('form.secrets.gcp.project_id')}
+ />
+ <FormItemTextInput
+ control={control}
+ name="auth_config.token_uri"
+ label={t('form.secrets.gcp.token_uri')}
+ />
+ <FormItemTagsInput
+ control={control}
+ name="auth_config.scope"
+ label={t('form.secrets.gcp.scope')}
+ />
+ <FormItemTextInput
+ control={control}
+ name="auth_config.entries_uri"
+ label={t('form.secrets.gcp.entries_uri')}
+ />
+ </FormSection>
+ </FormSection>
+ </>
+ );
+};
Review Comment:
Is it necessary to add a specialized form? I think using an editor with
syntax highlighting and jsonschema would be sufficient.
If it doesn't exist, we'll have to add the secret provider's jsonschema
export.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]