Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { Box, Stack } from "@mui/material";
import { useFormContext } from "react-hook-form";
import { FormattedMessage, useIntl } from "react-intl";
import ButtonLoader from "components/ButtonLoader";
import Input from "components/Input";
import QuestionMark from "components/QuestionMark";
import { DEFAULT_MAX_INPUT_LENGTH } from "utils/constants";
import type { AwsBillingBucketProps } from "../types";

export const FIELD_NAMES = Object.freeze({
BUCKET_NAME: "bucketName",
Expand All @@ -16,7 +14,7 @@ export const FIELD_NAMES = Object.freeze({

const DEFAULT_PATH_PREFIX = "reports";

const AwsBillingBucket = ({ showRoleButton }: AwsBillingBucketProps) => {
const AwsBillingBucket = () => {
const intl = useIntl();

const {
Expand Down Expand Up @@ -74,19 +72,6 @@ const AwsBillingBucket = ({ showRoleButton }: AwsBillingBucketProps) => {
})}
/>
</Box>
{showRoleButton && (
<Box sx={{ display: "flex", alignItems: "center" }}>
<ButtonLoader
sx={{ height: 40, position: "relative", top: 2 }}
messageId="showRole"
size="medium"
color="primary"
disabled={showRoleButton.isDisabled}
isLoading={showRoleButton.isLoading}
onClick={showRoleButton.onClick}
/>
</Box>
)}
</Stack>
<Input
required
Expand All @@ -113,25 +98,6 @@ const AwsBillingBucket = ({ showRoleButton }: AwsBillingBucketProps) => {
}
})}
/>
<Input
dataTestId="input_region_name"
key={FIELD_NAMES.REGION_NAME}
error={!!errors[FIELD_NAMES.REGION_NAME]}
helperText={errors[FIELD_NAMES.REGION_NAME] && errors[FIELD_NAMES.REGION_NAME].message}
InputProps={{
endAdornment: <QuestionMark messageId="exportRegionNameTooltip" dataTestId="qmark_region_name" />
}}
label={<FormattedMessage id="exportRegionName" />}
{...register(FIELD_NAMES.REGION_NAME, {
maxLength: {
value: DEFAULT_MAX_INPUT_LENGTH,
message: intl.formatMessage(
{ id: "maxLength" },
{ inputName: intl.formatMessage({ id: "exportRegionName" }), max: DEFAULT_MAX_INPUT_LENGTH }
)
}
})}
/>
</>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const AwsProperties = ({ accountId, config, createdAt }: AwsPropertiesProps) =>
}}
/>
<KeyValueLabel
variant="property"
keyMessageId="awsAuthenticationType"
value={<FormattedMessage id={getAwsAuthenticationTypeMessageId()} />}
dataTestIds={{ key: "p_authentication_type_key", value: "p_authentication_type_value" }}
Expand Down Expand Up @@ -121,6 +122,7 @@ const AwsProperties = ({ accountId, config, createdAt }: AwsPropertiesProps) =>
/>
{!!regionName && (
<KeyValueLabel
variant="property"
keyMessageId="exportRegionName"
value={regionName}
dataTestIds={{ key: "p_region_name_key", value: "p_region_name_value" }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ import {
getAwsConnectionTypeDescriptions,
useAuthenticationType,
AUTHENTICATION_TYPES,
AWS_ROOT_INPUTS_FIELD_NAMES,
AuthenticationType
} from "./FormElements/AwsConnectionForm";
import { FIELD_NAME as DATA_SOURCE_NAME_FIELD_NAME } from "./FormElements/DataSourceNameField";
Expand Down Expand Up @@ -158,7 +157,7 @@ const getAwsRootParameters = (formData: FieldValues, connectionType: string) =>
bucket_prefix: formData[AWS_BILLING_BUCKET_FIELD_NAMES.BUCKET_PREFIX],
report_name: formData[AWS_BILLING_BUCKET_FIELD_NAMES.EXPORT_NAME],
region_name: formData[AWS_BILLING_BUCKET_FIELD_NAMES.REGION_NAME] || undefined,
config_scheme: formData[AWS_ROOT_INPUTS_FIELD_NAMES.CONFIG_SCHEME]
config_scheme: AWS_ROOT_CONNECT_CONFIG_SCHEMES.BUCKET_ONLY
};

const extraParams = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,67 +7,24 @@ import {
AwsRootCredentials,
AwsUseAwsEdpDiscount
} from "components/DataSourceCredentialFields";
import { RadioGroup, Switch } from "components/forms/common/fields";
import QuestionMark from "components/QuestionMark";
import { AWS_ROOT_CONNECT_CONFIG_SCHEMES } from "utils/constants";
import { AWS_ROOT_INPUTS_FIELD_NAMES } from "./constants";

export const AwsConnectionAccessKeyInputs = ({ showAdvancesOptions = true }) => (
<ConnectForm>
{({ watch }) => {
const isFindReportWatch = watch(AWS_ROOT_INPUTS_FIELD_NAMES.IS_FIND_REPORT, true);
const configScheme =
watch(AWS_ROOT_INPUTS_FIELD_NAMES.CONFIG_SCHEME, AWS_ROOT_CONNECT_CONFIG_SCHEMES.CREATE_REPORT) ||
AWS_ROOT_CONNECT_CONFIG_SCHEMES.CREATE_REPORT;
const isFindReportWatch = watch(AWS_ROOT_INPUTS_FIELD_NAMES.IS_FIND_REPORT, false);

return (
<>
<AwsRootCredentials />
{showAdvancesOptions && (
<>
<AwsUseAwsEdpDiscount />
<Typography gutterBottom data-test-id="p_cost_and_usage_report_parameters_description">
<FormattedMessage id="costAndUsageReportParametersDescription" />
</Typography>
<AwsExportType />
<Switch
name={AWS_ROOT_INPUTS_FIELD_NAMES.IS_FIND_REPORT}
label={<FormattedMessage id="dataExportDetection" />}
defaultValue={isFindReportWatch}
adornment={
<QuestionMark
messageId="dataExportDetectionTooltip"
messageValues={{
break: <br />
}}
dataTestId="qmark_data_export_detection"
/>
}
/>
{!isFindReportWatch && (
<>
<RadioGroup
name={AWS_ROOT_INPUTS_FIELD_NAMES.CONFIG_SCHEME}
defaultValue={configScheme}
radioButtons={[
{
value: AWS_ROOT_CONNECT_CONFIG_SCHEMES.CREATE_REPORT,
label: <FormattedMessage id="createNewCostUsageReport" />
},
{
value: AWS_ROOT_CONNECT_CONFIG_SCHEMES.BUCKET_ONLY,
label: <FormattedMessage id="connectOnlyToDataInBucket" />
}
]}
/>
<Typography gutterBottom data-test-id="p_data_export_detection_description">
<FormattedMessage
id={
configScheme === AWS_ROOT_CONNECT_CONFIG_SCHEMES.CREATE_REPORT
? "dataExportDetectionDescription1"
: "dataExportDetectionDescription2"
}
/>
</Typography>
<AwsBillingBucket />
</>
)}
{!isFindReportWatch && <AwsBillingBucket />}
</>
)}
</>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useState } from "react";
import { Typography } from "@mui/material";
import { useFormContext } from "react-hook-form";
import { FormattedMessage } from "react-intl";
import {
AwsAssumedRoleInputs,
Expand All @@ -11,39 +10,21 @@ import {
AwsUseAwsEdpDiscount,
AWS_ROLE_CREDENTIALS_FIELD_NAMES
} from "components/DataSourceCredentialFields";
import { Switch } from "components/forms/common/fields";
import {
AUTHENTICATION_TYPES,
AuthenticationTypeSelector
} from "components/forms/ConnectCloudAccountForm/FormElements/AwsConnectionForm";
import AwsDescription from "./AwsDescription";
export const AWS_POOL_UPDATE_DATA_EXPORT_PARAMETERS = "updateDataExportParameters";

const CostAndUsageReport = () => {
const { watch } = useFormContext();

const checked = watch(AWS_POOL_UPDATE_DATA_EXPORT_PARAMETERS);

return (
<>
<Switch
name={AWS_POOL_UPDATE_DATA_EXPORT_PARAMETERS}
label={
<Typography>
<FormattedMessage id="updateDataExportParameters" />
</Typography>
}
/>
{checked && (
<>
<AwsExportType />
<AwsBillingBucket />
</>
)}
</>
);
};

const CostAndUsageReport = () => (
<>
<Typography gutterBottom data-test-id="p_cost_and_usage_report_parameters_description">
<FormattedMessage id="costAndUsageReportParametersDescription" />
</Typography>
<AwsExportType />
<AwsBillingBucket />
</>
);
const getAwsAuthType = (config) => {
if (config.assume_role_account_id && config.assume_role_name) {
return AUTHENTICATION_TYPES.ASSUMED_ROLE;
Expand Down
2 changes: 2 additions & 0 deletions ngui/ui/src/translations/en-US/appOverride.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"abandonedInstancesTitle": "Abandoned instances",
"abandonedKinesisStreams": "Abandoned kinesis Streams",
"acceptInvitationTitle": "User <strong>{ownerName}</strong> ({ownerEmail}) has invited you to join the organization",
"accessKey": "Access key",
"accountManagementTitle": "Account management",
"accountType": "Account type",
"addArtifactTitle": "Add artifact",
Expand Down Expand Up @@ -118,6 +119,7 @@
"assignmentRulesPageDescription": "Allocate your resources easily — FinOps for Cloud will assign newly detected resources automatically according to the rules listed above. Rules are evaluated according to the priority. You can also force re-apply them for the whole organization or a specific pool if you need to reflect allocation policies changes immediately.",
"assignmentRulesTabDescription": "Here you can see assignment rules that have this pool as a target. <assignmentRulesLink>See all assignment rules.</assignmentRulesLink>",
"assignmentRulesTitle": "Assignment rules",
"assumedRole": "Assumed role",
"atLeastOneBreakdownMustBeSelected": "At least one breakdown must be selected",
"atLeastOneBucketMustBeSelected": "At least one bucket must be selected",
"atLeastOneConditionMustBeMet": "At least <strong>one condition</strong> must be met",
Expand Down