Skip to content

Commit

Permalink
Adjust skip datasource data type to fit convention
Browse files Browse the repository at this point in the history
Signed-off-by: Wei-Chun, Chang <[email protected]>
  • Loading branch information
wcchang1115 committed Sep 27, 2023
1 parent c0b0a75 commit d64f0d3
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 39 deletions.
59 changes: 29 additions & 30 deletions static_report/src/components/Reports/ReportContextBar.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
import {
Box,
Flex,
FlexProps,
Icon,
Link,
Text,
Tooltip,
} from '@chakra-ui/react';
import { Box, Flex, FlexProps, Link, Text, Tooltip } from '@chakra-ui/react';
import { ReactNode } from 'react';
import { BiPlug } from 'react-icons/bi';
import { BsGearWideConnected } from 'react-icons/bs';
Expand Down Expand Up @@ -42,7 +34,8 @@ export function ReportContextBar({
let gitBranch: string | undefined = undefined;
let githubPr: string | undefined = undefined;
let githubPrUrl: string | undefined = undefined;
let reportFrom: string | undefined = undefined;
let baseFrom: string | undefined = undefined;
let targetFrom: string | undefined = undefined;
let skipDataSource: boolean | undefined = false;

if (data) {
Expand All @@ -52,9 +45,9 @@ export function ReportContextBar({
version = report.version;
gitBranch = report.datasource?.git_branch;
skipDataSource = report.datasource?.skip_datasource;
reportFrom = report.datasource?.skip_datasource
? 'Manifest File'
: report.datasource.type;
baseFrom = report.datasource?.skip_datasource
? 'Manifest file'
: `${report.datasource.type} connection`;
} else {
const report = data as ComparisonReportSchema;
const fallback = report.input ?? report.base;
Expand Down Expand Up @@ -82,18 +75,12 @@ export function ReportContextBar({
report.base?.datasource.skip_datasource ||
report.input?.datasource.skip_datasource;

const baseFrom = report.base?.datasource.skip_datasource
? 'Manifest File'
: report.base?.datasource.type;
const targetFrom = report.input?.datasource.skip_datasource
? 'Manifest File'
: report.input?.datasource.type;

if (baseFrom !== targetFrom) {
reportFrom = `${baseFrom}${targetFrom}`;
} else {
reportFrom = baseFrom;
}
baseFrom = report.base?.datasource.skip_datasource
? 'Manifest file'
: `${report.base?.datasource.type} connection`;
targetFrom = report.input?.datasource.skip_datasource
? 'Manifest file'
: `${report.input?.datasource.type} connection`;
}
}

Expand All @@ -104,17 +91,29 @@ export function ReportContextBar({
label="Connect PipeRider to your datasource for full schema info"
placement="top-start"
>
<Icon as={FiInfo} />
<FiInfo />
</Tooltip>
) : (
<Icon as={TbBuildingWarehouse} />
<TbBuildingWarehouse />
);
};

const showReportSource = (
reportFrom: string | undefined,
singleOnly: boolean | undefined,
baseFrom: string | undefined,
targetFrom: string | undefined,
skipDataSource: boolean | undefined,
) => {
let source: string | undefined = undefined;
if (singleOnly) {
source = baseFrom;
} else {
if (baseFrom !== targetFrom) {
source = `${baseFrom}${targetFrom}`;
} else {
source = baseFrom;
}
}
return (
<Flex alignItems={'center'} gap={2} flex="1" overflow="hidden">
{showIcon(skipDataSource)}
Expand All @@ -125,7 +124,7 @@ export function ReportContextBar({
textOverflow="ellipsis"
overflow="hidden"
>
source: {reportFrom}
source: {source}
</Text>
</Flex>
);
Expand Down Expand Up @@ -206,7 +205,7 @@ export function ReportContextBar({
</Text>
</Flex>
)}
{showReportSource(reportFrom, skipDataSource)}
{showReportSource(singleOnly, baseFrom, targetFrom, skipDataSource)}
</Flex>
{actionArea && <Box flex="0 0 auto">{actionArea}</Box>}
</Flex>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ import { CompColEntryItem } from '../../../lib';
interface Props extends Comparable {
columns?: CompColEntryItem[];
visibleDetail?: boolean; //for reuse in other pages
skipDataSource?: boolean;
}
export function TableColumnSchemaList({
columns,
singleOnly,
visibleDetail = false,
skipDataSource,
}: Props) {
const isNotSingle = !singleOnly;

Expand Down Expand Up @@ -101,7 +103,9 @@ export function TableColumnSchemaList({
borderRight={isNotSingle ? '1px solid lightgray' : ''}
>
<Text as={'span'} fontSize={'xs'}>
{baseColumn?.schema_type ?? NO_VALUE}
{skipDataSource
? '-'
: baseColumn?.schema_type ?? NO_VALUE}
</Text>
</Td>
{isNotSingle ? (
Expand All @@ -128,7 +132,9 @@ export function TableColumnSchemaList({
}
>
<Text as={'span'} fontSize={'xs'}>
{targetColumn?.schema_type ?? NO_VALUE}
{skipDataSource
? '-'
: targetColumn?.schema_type ?? NO_VALUE}
</Text>
</Td>
</>
Expand Down
16 changes: 11 additions & 5 deletions static_report/src/pages/CRTableDetailPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,11 @@ export default function CRTableDetailPage() {
<VStack spacing={10}>
<SeparateView title="Table Statistics" Comp={TableGeneralStats} />
<MergedView title="Schema">
<TableColumnSchemaCompList tableEntry={currentTableEntry} />
<TableColumnSchemaCompList
tableEntry={currentTableEntry}
skipBase={reportDataSource?.base?.skip_datasource}
skipTarget={reportDataSource?.target?.skip_datasource}
/>
</MergedView>
<SeparateView title="Duplicate Rows" Comp={DupedTableRowsWidget} />
</VStack>
Expand Down Expand Up @@ -247,7 +251,7 @@ function ComparableGridHeader() {
);
}

function TableColumnSchemaCompList({ tableEntry }) {
function TableColumnSchemaCompList({ tableEntry, skipBase, skipTarget }) {
const [
,
{ base: baseTableColEntry, target: targetTableColEntry },
Expand Down Expand Up @@ -300,7 +304,7 @@ function TableColumnSchemaCompList({ tableEntry }) {
borderRightColor="gray.200"
>
<Text as={'span'} fontSize={'xs'}>
{baseColumn?.schema_type ?? NO_VALUE}
{skipBase ? '-' : baseColumn?.schema_type ?? NO_VALUE}
</Text>
</Td>

Expand All @@ -320,7 +324,9 @@ function TableColumnSchemaCompList({ tableEntry }) {
</Td>
<Td color={metadata?.mismatched ? 'red.500' : 'inherit'}>
<Text as={'span'} fontSize={'xs'}>
{targetColumn?.schema_type ?? NO_VALUE}
{skipTarget
? '-'
: targetColumn?.schema_type ?? NO_VALUE}
</Text>
</Td>
</Tr>
Expand Down Expand Up @@ -369,7 +375,7 @@ function TableColumnSchemaCompList({ tableEntry }) {
</Td>
<Td>
<Text as={'span'} fontSize={'xs'}>
{column?.schema_type ?? NO_VALUE}
{skipBase ? '-' : column?.schema_type ?? NO_VALUE}
</Text>
</Td>
</Tr>
Expand Down
7 changes: 5 additions & 2 deletions static_report/src/pages/SRTableDetailPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { TableColumnHeader } from '../components/Tables/TableColumnHeader';
import { useReportStore } from '../utils/store';
import { useTableRoute } from '../utils/routes';
import { SkipDataSource } from '../components/Common/SkipDataSource';
import { sk } from 'date-fns/locale';

export default function SRTableDetailPage() {
let { tableName, uniqueId } = useTableRoute();
Expand Down Expand Up @@ -88,7 +87,11 @@ export default function SRTableDetailPage() {
</VStack>

<Divider orientation="vertical" />
<TableColumnSchemaList columns={columns} singleOnly />
<TableColumnSchemaList
columns={columns}
singleOnly
skipDataSource={skipDataSource}
/>
</Grid>
</>
);
Expand Down

0 comments on commit d64f0d3

Please sign in to comment.