Skip to content

Commit

Permalink
Merge pull request #730 from MAIF/fix/#622
Browse files Browse the repository at this point in the history
fix#622: add placeholder for Bucket url
  • Loading branch information
quentinovega authored Aug 8, 2024
2 parents 83b964c + 21dacf1 commit 43c7150
Showing 1 changed file with 63 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<any, unknown, ITenantFull, unknown> }) => {
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<any, unknown, ITenantFull, unknown>;
}) => {
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://<bucket-name>.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 (
<Form<IBucketSettings>
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 (
<Form<IBucketSettings>
schema={schema}
onSubmit={(r) => props.updateTenant.mutateAsync({ ...props.tenant, bucketSettings: r } as ITenantFull)}
value={props.tenant?.bucketSettings}
options={{
actions: {
submit: { label: translate('Save') }
}
}}
/>
)

}
}}
/>
);
};

0 comments on commit 43c7150

Please sign in to comment.