From 21dacf1ef63610a98f537fac13ecda3c5beefbbe Mon Sep 17 00:00:00 2001 From: HelaKaraa Date: Wed, 7 Aug 2024 11:02:47 +0200 Subject: [PATCH] fix#622: add placeholder for Bucket url --- .../tenants/forms/bucketForm.tsx | 122 +++++++++--------- 1 file changed, 63 insertions(+), 59 deletions(-) diff --git a/daikoku/javascript/src/components/adminbackoffice/tenants/forms/bucketForm.tsx b/daikoku/javascript/src/components/adminbackoffice/tenants/forms/bucketForm.tsx index 10e99bab5..431d05c17 100644 --- a/daikoku/javascript/src/components/adminbackoffice/tenants/forms/bucketForm.tsx +++ b/daikoku/javascript/src/components/adminbackoffice/tenants/forms/bucketForm.tsx @@ -2,68 +2,72 @@ import { Form, Schema, type } from '@maif/react-forms'; import { useContext } from 'react'; import { UseMutationResult } from '@tanstack/react-query'; - import { I18nContext } from '../../../../contexts'; import { IBucketSettings, ITenantFull } from '../../../../types'; -export const BucketForm = (props: { tenant?: ITenantFull, updateTenant: UseMutationResult }) => { - const { translate } = useContext(I18nContext) - - const schema: Schema = { - bucket: { - type: type.string, - label: translate('Bucket name'), - placeholder: 'daikoku-tenant-1', - help: translate('The name of the S3 bucket'), +export const BucketForm = (props: { + tenant?: ITenantFull; + updateTenant: UseMutationResult; +}) => { + const { translate } = useContext(I18nContext); - }, - endpoint: { - type: type.string, - label: translate('Bucket url'), - help: translate('The url of the bucket'), + const schema: Schema = { + bucket: { + type: type.string, + label: translate('Bucket name'), + placeholder: 'daikoku-tenant-1', + help: translate('The name of the S3 bucket'), + }, + endpoint: { + type: type.string, + label: translate('Bucket url'), + placeholder: 'https://.example-s3.io', + help: translate('The url of the bucket'), + }, + region: { + type: type.string, + label: translate('S3 region'), + placeholder: 'us-west-2', + help: translate('The region of the bucket'), + }, + access: { + type: type.string, + label: translate('Bucket access key'), + help: translate('The access key to access bucket'), + }, + secret: { + type: type.string, + label: translate('Bucket secret'), + help: translate('The secret to access the bucket'), + }, + chunkSize: { + type: type.number, + label: translate('Chunk size'), + defaultValue: 1024 * 1024 * 8, + help: translate('The size of each chunk sent'), + }, + v4auth: { + type: type.bool, + label: translate('Use V4 auth.'), + defaultValue: true, + }, + }; + return ( + + schema={schema} + onSubmit={(r) => + props.updateTenant.mutateAsync({ + ...props.tenant, + bucketSettings: r, + } as ITenantFull) + } + value={props.tenant?.bucketSettings} + options={{ + actions: { + submit: { label: translate('Save') }, }, - region: { - type: type.string, - label: translate('S3 region'), - placeholder: 'us-west-2', - help: translate('The region of the bucket'), - }, - access: { - type: type.string, - label: translate('Bucket access key'), - help: translate('The access key to access bucket'), - }, - secret: { - type: type.string, - label: translate('Bucket secret'), - help: translate('The secret to access the bucket'), - }, - chunkSize: { - type: type.number, - label: translate('Chunk size'), - defaultValue: 1024 * 1024 * 8, - help: translate('The size of each chunk sent'), - }, - v4auth: { - type: type.bool, - label: translate('Use V4 auth.'), - defaultValue: true - }, - } - - - return ( - - schema={schema} - onSubmit={(r) => props.updateTenant.mutateAsync({ ...props.tenant, bucketSettings: r } as ITenantFull)} - value={props.tenant?.bucketSettings} - options={{ - actions: { - submit: { label: translate('Save') } - } - }} - /> - ) - -} \ No newline at end of file + }} + /> + ); +};