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

Display numbers in usage per connection table #10757

Merged
merged 1 commit into from
Mar 1, 2022
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
21 changes: 18 additions & 3 deletions airbyte-webapp/src/components/Table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@ import {

import { Card } from "components";

type PaddingProps = {
left?: number;
right?: number;
};

type IHeaderProps = {
headerHighlighted?: boolean;
collapse?: boolean;
customWidth?: number;
customPadding?: PaddingProps;
} & ColumnInstance;

type ICellProps = {
Expand All @@ -25,6 +31,7 @@ type IThProps = {
highlighted?: boolean;
collapse?: boolean;
customWidth?: number;
customPadding?: PaddingProps;
light?: boolean;
} & React.ThHTMLAttributes<HTMLTableHeaderCellElement>;

Expand All @@ -47,8 +54,13 @@ const Tr = styled.tr<{
cursor: ${({ hasClick }) => (hasClick ? "pointer" : "auto")};
`;

const Td = styled.td<{ collapse?: boolean; customWidth?: number }>`
padding: 16px 13px;
const Td = styled.td<{
collapse?: boolean;
customWidth?: number;
customPadding?: PaddingProps;
}>`
padding: ${({ customPadding }) =>
`16px ${customPadding?.right ?? 13}px 16px ${customPadding?.left ?? 13}px`};
font-size: 12px;
line-height: 15px;
font-weight: normal;
Expand All @@ -75,7 +87,8 @@ const Td = styled.td<{ collapse?: boolean; customWidth?: number }>`

const Th = styled.th<IThProps>`
background: ${({ theme, light }) => (light ? "none" : theme.textColor)};
padding: 9px 13px 10px;
padding: ${({ customPadding }) =>
`9px ${customPadding?.right ?? 13}px 10px ${customPadding?.left ?? 13}px`};
text-align: left;
font-size: ${({ light }) => (light ? 11 : 10)}px;
line-height: 12px;
Expand Down Expand Up @@ -157,6 +170,7 @@ const Table: React.FC<IProps> = ({
{...column.getHeaderProps()}
highlighted={column.headerHighlighted}
collapse={column.collapse}
customPadding={column.customPadding}
customWidth={column.customWidth}
key={`table-column-${key}-${columnKey}`}
light={light}
Expand Down Expand Up @@ -185,6 +199,7 @@ const Table: React.FC<IProps> = ({
<Td
{...cell.getCellProps()}
collapse={cell.column.collapse}
customPadding={cell.column.customPadding}
customWidth={cell.column.customWidth}
key={`table-cell-${row.id}-${key}`}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,13 @@ import React from "react";
import styled from "styled-components";

type ConnectionCellProps = {
value: number;
percent: number;
};

const Content = styled.div`
display: flex;
flex-direction: row;
align-items: center;
`;

const Value = styled.div`
padding-right: 10px;
font-weight: 500;
font-size: 14px;
line-height: 17px;
flex: 1 0 0;
min-width: 50px;
`;

const Bar = styled.div`
height: 10px;
width: 100%;
min-width: 150px;
background: ${({ theme }) => theme.greyColor20};
flex: 10 0 0;
overflow: hidden;
Expand All @@ -37,15 +22,10 @@ const Full = styled.div<{ percent: number }>`
opacity: 0.5;
`;

const UsageCell: React.FC<ConnectionCellProps> = ({ value, percent }) => {
return (
<Content>
<Value>{value}</Value>
<Bar>
<Full percent={percent} />
</Bar>
</Content>
);
};
const UsageCell: React.FC<ConnectionCellProps> = ({ percent }) => (
<Bar>
<Full percent={percent} />
</Bar>
);

export default UsageCell;
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ 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;
`;

type UsagePerConnectionTableProps = {
creditConsumption: CreditConsumptionByConnector[];
};
Expand Down Expand Up @@ -144,11 +152,18 @@ const UsagePerConnectionTable: React.FC<UsagePerConnectionTableProps> = ({
</>
),
accessor: "creditsConsumed",
Cell: ({ cell, row }: CellProps<FullTableProps>) => (
<UsageCell
value={cell.value}
percent={row.original.creditsConsumedPercent}
/>
collapse: true,
customPadding: { right: 0 },
Cell: ({ cell }: CellProps<FullTableProps>) => (
<UsageValue>{cell.value}</UsageValue>
),
},
{
Header: "",
accessor: "creditsConsumedPercent",
customPadding: { left: 0 },
Cell: ({ cell }: CellProps<FullTableProps>) => (
<UsageCell percent={cell.value} />
),
},
// TODO: Replace to Grow column
Expand Down