in s3-artifact-storage-ui/src/App/S3/AwsS3.tsx [34:107]
export default function AwsS3() {
const config = useAppContext();
const methods = useFormContext<IFormInput>();
const { watch, setValue } = useFormContext<IFormInput>();
const currentConnectionKey = watch(FormFields.AWS_CONNECTION_ID)?.key;
const defaultProviderChain =
watch(FormFields.USE_DEFAULT_CREDENTIAL_PROVIDER_CHAIN) ?? false;
const connectionsFilter = config.showDefaultCredentialsChain
? undefined
: (type: string) => type !== AwsConnectionCredentialsType.DEFAULT_PROVIDER;
const shouldConvert =
(config.secretAcessKeyValue || config.accessKeyIdValue) &&
!currentConnectionKey;
const awsConnectionSelector = React.useMemo(
() => (
<AvailableAwsConnectionsWithButtons
ctx={methods}
connectionsData={toConnectionsData(
currentConnectionKey,
config,
methods,
(conn: Option) => setValue(FormFields.AWS_CONNECTION_ID, conn),
defaultProviderChain,
connectionsFilter
)}
formFieldName={FormFields.AWS_CONNECTION_ID}
awsConnectionsStyle={styles.awsConnections}
/>
),
[currentConnectionKey]
);
return (
<>
<section>
<SectionHeader>{'AWS S3'}</SectionHeader>
{awsConnectionSelector}
{shouldConvert && (
<>
<DefaultProviderChain />
{!defaultProviderChain && (
<>
<AccessKeyId />
<SecretAccessKey />
</>
)}
<IAMRole />
<AwsConnectionsConversionFeature
data={toConnectionsData(
'',
config,
methods,
(conn: Option) => {
setValue(FormFields.AWS_CONNECTION_ID, {
key: conn.key,
label: conn.label,
});
setValue(FormFields.ACCESS_KEY_ID, '');
setValue(FormFields.SECRET_ACCESS_KEY, '');
},
defaultProviderChain,
connectionsFilter
)}
/>
</>
)}
<Bucket />
<BucketPrefix />
</section>
<TransferSpeedUp />
</>
);
}