Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🪟 🧹 Round credits values on credit consumption page #21873

Merged
merged 3 commits into from
Jan 26, 2023
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
8 changes: 7 additions & 1 deletion airbyte-webapp/src/components/ui/BarChart/BarChart.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useMemo } from "react";
import { FormattedNumber } from "react-intl";
import {
Bar,
BarChart as BasicBarChart,
Expand Down Expand Up @@ -63,7 +64,12 @@ export const BarChart: React.FC<BarChartProps> = React.memo(({ data, legendLabel
>
<Label value={yLabel} fontSize={11} fill={chartTicksColor} fontWeight={600} position="top" offset={10} />
</YAxis>
<Tooltip cursor={{ fill: chartHoverFill }} />
<Tooltip
cursor={{ fill: chartHoverFill }}
formatter={(value: number) => {
return [<FormattedNumber value={value} maximumFractionDigits={2} minimumFractionDigits={2} />, yLabel];
}}
/>
{legendLabels.map((barName, key) => (
<Bar key={barName} dataKey={barName} fill={barChartColors[key]} />
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,11 @@ const RemainingCredits: React.FC<Props> = ({ selfServiceCheckoutEnabled }) => {
<CreditView>
<FormattedMessage id="credits.remainingCredits" />
<Count>
<FormattedNumber value={cloudWorkspace.remainingCredits} />
<FormattedNumber
value={cloudWorkspace.remainingCredits}
maximumFractionDigits={2}
minimumFractionDigits={2}
/>
</Count>
</CreditView>
<Actions>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@use "scss/variables";

.content {
padding: 0 variables.$spacing-2xl 0 variables.$spacing-lg;
}

.usageValue {
padding-right: 10px;
min-width: 53px;
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import queryString from "query-string";
import React, { useCallback } from "react";
import { FormattedMessage } from "react-intl";
import { FormattedMessage, FormattedNumber } from "react-intl";
import { useNavigate } from "react-router-dom";
import { CellProps } from "react-table";
import styled from "styled-components";

import { SortOrderEnum } from "components/EntityTable/types";
import { Table, SortableTableHeader } from "components/ui/Table";
import { Text } from "components/ui/Text";

import { useQuery } from "hooks/useQuery";
import { CreditConsumptionByConnector } from "packages/cloud/lib/domain/cloudWorkspaces/types";
Expand All @@ -15,18 +15,7 @@ import { useSourceDefinitionList } from "services/connector/SourceDefinitionServ

import ConnectionCell from "./ConnectionCell";
import UsageCell from "./UsageCell";

const Content = styled.div`
padding: 0 60px 0 15px;
`;

const UsageValue = styled.div`
font-weight: 500;
font-size: 14px;
line-height: 17px;
padding-right: 10px;
min-width: 53px;
`;
import styles from "./UsagePerConnectionTable.module.scss";

interface UsagePerConnectionTableProps {
creditConsumption: CreditConsumptionByConnector[];
Expand Down Expand Up @@ -142,7 +131,11 @@ const UsagePerConnectionTable: React.FC<UsagePerConnectionTableProps> = ({ credi
accessor: "creditsConsumed",
collapse: true,
customPadding: { right: 0 },
Cell: ({ cell }: CellProps<FullTableProps>) => <UsageValue>{cell.value}</UsageValue>,
Cell: ({ cell }: CellProps<FullTableProps>) => (
<Text className={styles.usageValue} size="lg">
<FormattedNumber value={cell.value} maximumFractionDigits={2} minimumFractionDigits={2} />
</Text>
),
},
{
Header: "",
Expand All @@ -162,9 +155,9 @@ const UsagePerConnectionTable: React.FC<UsagePerConnectionTableProps> = ({ credi
);

return (
<Content>
<div className={styles.content}>
<Table columns={columns} data={sortingData} light />
</Content>
</div>
);
};

Expand Down