Skip to content

Commit

Permalink
Merge pull request #466 from ImanMahmoudinasab/feature/migrate-to-mui…
Browse files Browse the repository at this point in the history
…-run-list-view

feat: Migrate run list view to MUI
  • Loading branch information
agoldis committed Oct 12, 2021
2 parents 5b08551 + 320bbe9 commit 0a257e3
Show file tree
Hide file tree
Showing 45 changed files with 1,213 additions and 550 deletions.
56 changes: 38 additions & 18 deletions packages/dashboard/src/components/common/ci.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { PrecisionManufacturing as PrecisionManufacturingIcon } from '@mui/icons-material';
import { Grid, Link, Tooltip, Typography } from '@mui/material';
import { environment } from '@sorry-cypress/dashboard/state/environment';
import { Icon, Tooltip } from 'bold-ui';
import React from 'react';
import React, { FunctionComponent } from 'react';

type CiLinkProps = {
ciBuildId: string | null | undefined;
projectId: string | null | undefined;
};
export const CiUrl = ({ ciBuildId, projectId }: CiLinkProps) => {
export const CiUrl: CiUrlComponent = (props) => {
const { ciBuildId, projectId, disableLink } = props;
if (typeof environment.CI_URL !== 'string') {
return null;
}
Expand All @@ -28,16 +26,38 @@ export const CiUrl = ({ ciBuildId, projectId }: CiLinkProps) => {
.replace('{project_id}', projectId)
.replace('{build_id}', ciBuildId);
return (
<div>
<strong>CI_URL </strong>
<Tooltip text="Generated from CI_URL env var">
<Icon size={1} icon="infoCircleOutline" />
</Tooltip>
<ul>
<li>
<a href={parsedUrl}>{name}</a>
</li>
</ul>
</div>
<Grid container>
<Grid item container alignItems="flex-start">
<Grid item mt={0.4} mr={1}>
<Tooltip title="CI URL">
<PrecisionManufacturingIcon fontSize="small" />
</Tooltip>
</Grid>
<Grid item>
<Tooltip title="CI URL (Generated from CI_URL env var)">
<Typography component="p" variant="subtitle1">
{!disableLink && (
<Link
target="_blank"
rel="noopener noreferrer"
href={parsedUrl}
underline="hover"
>
{name}
</Link>
)}
{disableLink && name}
</Typography>
</Tooltip>
</Grid>
</Grid>
</Grid>
);
};

type CiUrlProps = {
ciBuildId: string | null | undefined;
projectId: string | null | undefined;
disableLink?: boolean;
};
type CiUrlComponent = FunctionComponent<CiUrlProps>;
31 changes: 21 additions & 10 deletions packages/dashboard/src/components/common/date.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
import React from 'react';
import { Tooltip } from '@mui/material';
import { FORMAT, FORMAT_SHORTER } from '@sorry-cypress/dashboard/constants';
import { format } from 'date-fns';
import { Tooltip } from 'bold-ui';

const FORMAT = 'MMM dd yyyy, HH:mm:ss';
export const FormattedDate = ({ value }: { value: Date }) => {
return (
<Tooltip text={value.toUTCString()}>
<span>{format(value, FORMAT)}</span>
</Tooltip>
);
import React, { FunctionComponent } from 'react';

export const FormattedDate: DateComponent = (props) => {
const { value, showTooltip = true, short = false } = props;
const render = <span>{format(value, short ? FORMAT_SHORTER : FORMAT)}</span>;

if (showTooltip) {
return <Tooltip title={value.toUTCString()}>{render}</Tooltip>;
}

return render;
};

type DateProps = {
value: Date;
showTooltip?: boolean;
short?: boolean;
};

type DateComponent = FunctionComponent<DateProps>;
39 changes: 0 additions & 39 deletions packages/dashboard/src/components/common/duration.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TestState } from '@sorry-cypress/dashboard/generated/graphql';
import { isIdle } from '@sorry-cypress/dashboard/lib/time';
import { Tag } from 'bold-ui';
import React from 'react';
import { isIdle } from './duration';

type TestStateProps = {
state?: TestState | 'unknown';
Expand Down
159 changes: 91 additions & 68 deletions packages/dashboard/src/components/common/testResults.tsx
Original file line number Diff line number Diff line change
@@ -1,93 +1,116 @@
import { HFlow, Icon, Text, Tooltip } from 'bold-ui';
import React from 'react';
import {
CheckCircleOutline as CheckCircleOutlineIcon,
ErrorOutline as ErrorOutlineIcon,
Flaky as FlakyIcon,
NextPlanOutlined as NextPlanOutlinedIcon,
RadioButtonUnchecked as RadioButtonUncheckedIcon,
} from '@mui/icons-material';
import { Box, Tooltip } from '@mui/material';
import { padStart } from 'lodash';
import React, { FunctionComponent } from 'react';
import { Chip } from '..';

export const TestSuccessBadge: TestBadgeComponent = (props) => {
const { value } = props;

export const TestSuccessBadge = ({ value }: { value: number }) => {
const color = value ? 'success' : 'disabled';
return (
<Text color={color}>
<Tooltip text="Passed Tests">
<HFlow alignItems="center" hSpacing={0.5}>
<Icon icon="checkCircleOutline" size={1} />
{value}
</HFlow>
</Tooltip>
</Text>
<Tooltip title="Passed Tests" arrow>
<Chip
size="small"
color={value ? 'green' : 'grey'}
shade={!value ? 300 : undefined}
label={<Pad number={value} />}
icon={CheckCircleOutlineIcon}
/>
</Tooltip>
);
};

export const TestFailureBadge = ({ value }: { value: number }) => {
const color = value ? 'danger' : 'disabled';
export const TestFailureBadge: TestBadgeComponent = (props) => {
const { value } = props;

return (
<Text color={color}>
<Tooltip text="Failed Tests">
<HFlow alignItems="center" hSpacing={0.5}>
<Icon icon="exclamationTriangleOutline" size={1} />
{value}
</HFlow>
</Tooltip>
</Text>
<Tooltip title="Failed Tests" arrow>
<Chip
size="small"
color={value ? 'red' : 'grey'}
shade={!value ? 300 : undefined}
label={<Pad number={value} />}
icon={ErrorOutlineIcon}
/>
</Tooltip>
);
};

export const TestRetriesSkippedBadge = ({
retries,
skipped,
}: {
retries: number;
skipped: number;
}) => {
export const TestSkippedBadge: TestBadgeComponent = (props) => {
const { value } = props;

return (
<div style={{ display: 'flex' }}>
<TestRetriesBadge value={retries} />
<TestSkippedBadge value={skipped} style={{ paddingLeft: '1rem' }} />
</div>
<Tooltip title="Skipped Tests" arrow>
<Chip
size="small"
color={value ? 'orange' : 'grey'}
shade={!value ? 300 : undefined}
label={<Pad number={value} />}
icon={NextPlanOutlinedIcon}
/>
</Tooltip>
);
};

export const TestSkippedBadge = ({
value,
style,
}: {
value: number;
style?: any;
}) => {
const color = value ? 'normal' : 'disabled';
export const TestRetriesBadge: TestBadgeComponent = (props) => {
const { value } = props;

return (
<Text color={color} style={style}>
<Tooltip text="Skipped Tests">
<HFlow alignItems="center" hSpacing={0.5}>
<Icon icon="timesOutline" size={1} />
{value}
</HFlow>
</Tooltip>
</Text>
<Tooltip title="Flaky Tests" arrow>
<Chip
size="small"
color={value ? 'pink' : 'grey'}
shade={!value ? 300 : undefined}
label={<Pad number={value} />}
icon={FlakyIcon}
/>
</Tooltip>
);
};

export const TestRetriesBadge = ({ value }: { value: number }) => {
const color = value ? 'alert' : 'disabled';
export const TestOverallBadge: TestBadgeComponent = (props) => {
const { value } = props;

return (
<Text color={color}>
<Tooltip text="Retried Tests">
<HFlow alignItems="center" hSpacing={0.5}>
<Icon icon="sync" size={1} />
{value}
</HFlow>
</Tooltip>
</Text>
<Tooltip title="Total Tests" arrow>
<Chip
size="small"
color="cyan"
label={<Pad number={value} />}
icon={RadioButtonUncheckedIcon}
/>
</Tooltip>
);
};

export const TestOverallBadge = ({ value }: { value: number }) => {
const Pad: PadComponent = (props) => {
const { number } = props;

return (
<Text>
<Tooltip text="Total Tests">
<HFlow alignItems="center" hSpacing={0.5}>
<Icon icon="fileWithItensOutline" size={1} />
{value}
</HFlow>
</Tooltip>
</Text>
<Box
component="span"
whiteSpace="pre"
sx={{
opacity: !number ? 0.4 : undefined,
}}
>
{padStart(number?.toString(), 4)}
</Box>
);
};

type PadProps = {
number: number;
};
type PadComponent = FunctionComponent<PadProps>;

type TestBadgeProps = {
value: number;
};
type TestBadgeComponent = FunctionComponent<TestBadgeProps>;
2 changes: 1 addition & 1 deletion packages/dashboard/src/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from './common';
export * from './ui';
export * from './layout';
export * from './ui';

0 comments on commit 0a257e3

Please sign in to comment.