/* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ import React, { useState, useEffect } from "react"; import ArrowDropDownIcon from "@material-ui/icons/ArrowDropDown"; import FormItem from "components/FormItem"; import TextInput from "components/TextInput"; import { useTranslation } from "react-i18next"; import Select from "components/Select"; import { COMPRESS_TYPE, S3_BUFFER_PREFIX, S3_STORAGE_CLASS_LINK, } from "assets/js/const"; import { ApplicationLogType } from "../../dataInjection/applicationLog/create/CreatePipeline"; import AutoComplete from "components/AutoComplete"; import { appSyncRequestQuery } from "assets/js/request"; import { listResources } from "graphql/queries"; import { Resource, ResourceType } from "API"; import { SelectItem } from "components/Select/select"; import { OptionType } from "components/AutoComplete/autoComplete"; import ExtLink from "components/ExtLink"; import { S3_STORAGE_CLASS_OPTIONS } from "types"; interface BufferS3Props { applicationLog: ApplicationLogType; s3BucketEmptyError: boolean; s3PrefixError: boolean; bufferSizeError: boolean; bufferIntervalError: boolean; changeS3BufferBucket: (bucket: OptionType | null) => void; changeS3BufferPrefix: (prefix: string) => void; changeS3BufferBufferSize: (size: string) => void; changeS3BufferTimeout: (timeout: string) => void; changeS3CompressionType: (type: string) => void; changeS3StorageClass: (storage: string) => void; } const BufferS3: React.FC = (props: BufferS3Props) => { const { t } = useTranslation(); const { applicationLog, s3BucketEmptyError, s3PrefixError, bufferSizeError, bufferIntervalError, changeS3BufferBucket, changeS3BufferPrefix, changeS3BufferBufferSize, changeS3BufferTimeout, changeS3CompressionType, changeS3StorageClass, } = props; const [showAdvanceSetting, setShowAdvanceSetting] = useState(false); const [loadingS3List, setLoadingS3List] = useState(false); const [s3BucketOptionList, setS3BucketOptionList] = useState( [] ); const getS3List = async () => { try { setLoadingS3List(true); const resData: any = await appSyncRequestQuery(listResources, { type: ResourceType.S3Bucket, accountId: "", }); const dataList: Resource[] = resData.data.listResources; const tmpOptionList: SelectItem[] = []; dataList.forEach((element) => { tmpOptionList.push({ name: `${element.name}`, value: element.id, }); }); setS3BucketOptionList(tmpOptionList); setLoadingS3List(false); } catch (error) { console.error(error); } }; useEffect(() => { getS3List(); }, []); return (
, data) => { changeS3BufferBucket(data); }} />
{ setShowAdvanceSetting(!showAdvanceSetting); }} > {showAdvanceSetting && } {!showAdvanceSetting && ( )} {t("servicelog:cluster.additionalSetting")}
{ changeS3BufferPrefix(event.target.value); }} />
{ changeS3BufferBufferSize(event.target.value); }} />
MiB
{ changeS3BufferTimeout(event.target.value); }} />
{t("seconds")}
{t("applog:create.ingestSetting.s3StorageClassDesc")} {t("learnMore")}
} > { changeS3CompressionType(event.target.value); }} />
); }; export default BufferS3;