Skip to content

Commit 4dd8d30

Browse files
teallarsonJoey Marshment-Howell
authored andcommitted
🪟 🧹 Credits page component cleanup (airbytehq#21870)
* update styling on connectionCell * cleanup the component and get rid of custom styles where possible * convert CreditsUsage page to scss module * cleanup * add connection status and connection name to endpoint data types * use variable * remove unused line * align icon and name center * adjust styling for arrow cell --------- Co-authored-by: Joey Marshment-Howell <[email protected]>
1 parent bf1420a commit 4dd8d30

File tree

6 files changed

+64
-63
lines changed

6 files changed

+64
-63
lines changed

airbyte-webapp/src/packages/cloud/lib/domain/cloudWorkspaces/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { ConnectionStatus } from "core/request/AirbyteClient";
2+
13
export enum CreditStatus {
24
"POSITIVE" = "positive",
35
"NEGATIVE_WITHIN_GRACE_PERIOD" = "negative_within_grace_period",
@@ -17,6 +19,8 @@ export interface CloudWorkspace {
1719

1820
export interface CreditConsumptionByConnector {
1921
connectionId: string;
22+
connectionName: string;
23+
status: ConnectionStatus;
2024
creditsConsumed: number;
2125
destinationConnectionName: string;
2226
destinationDefinitionId: string;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.connectorItem {
2+
width: calc(100% - 30px / 2);
3+
}
4+
5+
.arrowItem {
6+
flex: 0 0 30px;
7+
display: flex;
8+
align-items: center;
9+
justify-content: center;
10+
}

airbyte-webapp/src/packages/cloud/views/credits/CreditsPage/components/ConnectionCell.tsx

Lines changed: 22 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
import { faArrowRight } from "@fortawesome/free-solid-svg-icons";
2-
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
31
import React from "react";
4-
import styled from "styled-components";
52

63
import { ConnectorIcon } from "components/common/ConnectorIcon";
4+
import { ArrowRightIcon } from "components/icons/ArrowRightIcon";
5+
import { FlexContainer, FlexItem } from "components/ui/Flex";
6+
import { Text } from "components/ui/Text";
7+
8+
import styles from "./ConnectionCell.module.scss";
79

810
interface ConnectionCellProps {
911
sourceDefinitionName: string;
@@ -12,43 +14,30 @@ interface ConnectionCellProps {
1214
destinationIcon?: string;
1315
}
1416

15-
const Icon = styled(ConnectorIcon)`
16-
margin-right: 12px;
17-
display: inline-block;
18-
vertical-align: middle;
19-
height: 20px;
20-
width: 20px;
21-
`;
22-
23-
const Connector = styled.div`
24-
font-weight: 500;
25-
font-size: 14px;
26-
line-height: 25px;
27-
`;
28-
29-
const Arrow = styled(FontAwesomeIcon)`
30-
margin: 0 17px 0 9px;
31-
font-size: 9px;
32-
`;
33-
3417
const ConnectionCell: React.FC<ConnectionCellProps> = ({
3518
sourceDefinitionName,
3619
destinationDefinitionName,
3720
sourceIcon,
3821
destinationIcon,
3922
}) => {
4023
return (
41-
<>
42-
<Connector>
43-
<Icon icon={sourceIcon} />
44-
{sourceDefinitionName}
45-
</Connector>
46-
<Connector>
47-
<Arrow icon={faArrowRight} />
48-
<Icon icon={destinationIcon} />
49-
{destinationDefinitionName}
50-
</Connector>
51-
</>
24+
<FlexContainer justifyContent="space-between">
25+
<FlexItem className={styles.connectorItem}>
26+
<FlexContainer direction="row" alignItems="center">
27+
<ConnectorIcon icon={sourceIcon} />
28+
<Text size="lg">{sourceDefinitionName}</Text>
29+
</FlexContainer>
30+
</FlexItem>
31+
<FlexItem className={styles.arrowItem}>
32+
<ArrowRightIcon />
33+
</FlexItem>
34+
<FlexItem className={styles.connectorItem}>
35+
<FlexContainer direction="row" alignItems="center">
36+
<ConnectorIcon icon={destinationIcon} />
37+
<Text size="lg">{destinationDefinitionName}</Text>
38+
</FlexContainer>
39+
</FlexItem>
40+
</FlexContainer>
5241
);
5342
};
5443

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@use "scss/variables";
2+
3+
.empty {
4+
height: 100%;
5+
padding-bottom: variables.$spacing-xl;
6+
}
7+
8+
.chartWrapper {
9+
width: 100%;
10+
height: 260px;
11+
padding: 0 variables.$spacing-2xl variables.$spacing-xl 0;
12+
}
13+
14+
.cardBlock {
15+
margin: variables.$spacing-md 0 variables.$spacing-xl;
16+
}

airbyte-webapp/src/packages/cloud/views/credits/CreditsPage/components/CreditsUsage.tsx

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,16 @@
11
import React, { useMemo } from "react";
22
import { FormattedMessage, useIntl } from "react-intl";
3-
import styled from "styled-components";
43

54
import { BarChart } from "components/ui/BarChart";
65
import { Card } from "components/ui/Card";
6+
import { FlexContainer } from "components/ui/Flex";
77

88
import { useCurrentWorkspace } from "hooks/services/useWorkspace";
99
import { useGetCloudWorkspaceUsage } from "packages/cloud/services/workspaces/CloudWorkspacesService";
1010

11+
import styles from "./CreditsUsage.module.scss";
1112
import UsagePerConnectionTable from "./UsagePerConnectionTable";
1213

13-
export const ChartWrapper = styled.div`
14-
width: 100%;
15-
height: 260px;
16-
padding: 0 50px 24px 0;
17-
`;
18-
19-
const CardBlock = styled(Card)`
20-
margin: 10px 0 20px;
21-
`;
22-
23-
const Empty = styled.div`
24-
height: 100%;
25-
display: flex;
26-
justify-content: center;
27-
align-items: center;
28-
font-weight: 600;
29-
padding-bottom: 20px;
30-
`;
31-
3214
const LegendLabels = ["value"];
3315

3416
const CreditsUsage: React.FC = () => {
@@ -52,7 +34,7 @@ const CreditsUsage: React.FC = () => {
5234
return (
5335
<>
5436
<Card title={<FormattedMessage id="credits.totalUsage" />} lightPadding>
55-
<ChartWrapper>
37+
<div className={styles.chartWrapper}>
5638
{data?.creditConsumptionByDay?.length ? (
5739
<BarChart
5840
data={chartData}
@@ -65,22 +47,22 @@ const CreditsUsage: React.FC = () => {
6547
})}
6648
/>
6749
) : (
68-
<Empty>
50+
<FlexContainer alignItems="center" justifyContent="center" className={styles.empty}>
6951
<FormattedMessage id="credits.noData" />
70-
</Empty>
52+
</FlexContainer>
7153
)}
72-
</ChartWrapper>
54+
</div>
7355
</Card>
7456

75-
<CardBlock title={<FormattedMessage id="credits.usagePerConnection" />} lightPadding>
57+
<Card title={<FormattedMessage id="credits.usagePerConnection" />} lightPadding className={styles.cardBlock}>
7658
{data?.creditConsumptionByConnector?.length ? (
7759
<UsagePerConnectionTable creditConsumption={data.creditConsumptionByConnector} />
7860
) : (
79-
<Empty>
61+
<FlexContainer alignItems="center" justifyContent="center" className={styles.empty}>
8062
<FormattedMessage id="credits.noData" />
81-
</Empty>
63+
</FlexContainer>
8264
)}
83-
</CardBlock>
65+
</Card>
8466
</>
8567
);
8668
};

airbyte-webapp/src/packages/cloud/views/credits/CreditsPage/components/UsagePerConnectionTable.module.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
@use "scss/colors";
33

44
.content {
5-
padding: 0 variables.$spacing-2xl 0 variables.$spacing-lg;
5+
padding: 0 variables.$spacing-lg;
66
}
77

88
.usageValue {
9-
padding-right: 10px;
9+
padding-right: variables.$spacing-md;
1010
min-width: 53px;
1111
}
1212

0 commit comments

Comments
 (0)