Skip to content

Commit

Permalink
New UI support
Browse files Browse the repository at this point in the history
  • Loading branch information
bengotow committed Apr 16, 2024
1 parent 4077253 commit dd385af
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {
AssetCheckSeverity,
} from '../../graphql/types';
import {linkToRunEvent} from '../../runs/RunUtils';
import {TagActionsPopover} from '../../ui/TagActions';
import {TagAction, TagActionsPopover} from '../../ui/TagActions';
import {AssetCheckLiveFragment} from '../../asset-data/types/AssetLiveDataProvider.types';

export const AssetCheckStatusTag = ({
execution,
Expand Down Expand Up @@ -94,3 +95,33 @@ export const AssetCheckStatusTag = ({
</TagActionsPopover>
);
};

export const AssetCheckErrorsTag = ({
checks,
severity,
}: {
checks: AssetCheckLiveFragment[];
severity: AssetCheckSeverity;
}) => {
const actions: TagAction[] = [];
const execution = checks[0]?.executionForLatestMaterialization;
if (execution) {
actions.push({
label: 'View in run logs',
to: linkToRunEvent(
{id: execution.runId},
{stepKey: execution.stepKey, timestamp: execution.timestamp},
),
});
}
return (
<TagActionsPopover data={{key: '', value: ''}} actions={actions}>
<Tag
icon={severity === AssetCheckSeverity.ERROR ? 'cancel' : 'warning_outline'}
intent={severity === AssetCheckSeverity.ERROR ? 'danger' : 'warning'}
>
{checks.length === 1 ? checks[0]!.name : `${checks.length} failed`}
</Tag>
</TagActionsPopover>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ export function useAssetCatalogFiltering(
return {
searchPath,
activeFiltersJsx: components.activeFiltersJsx,
filterValues: filters,
filterButton: components.button,
filterInput,
isFiltered,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,79 +1,34 @@
import {Box, Colors, Icon, IconWrapper} from '@dagster-io/ui-components';
import {Box, Colors, Icon} from '@dagster-io/ui-components';
import * as React from 'react';
import styled from 'styled-components';

import {TableSectionHeader, TableSectionHeaderProps} from '../workspace/TableSectionHeader';
import {DUNDER_REPO_NAME} from '../workspace/buildRepoAddress';

export const SECTION_HEADER_HEIGHT = 32;

interface Props {
expanded: boolean;
onClick: (e: React.MouseEvent) => void;
interface Props extends TableSectionHeaderProps {
repoName: string;
repoLocation: string;
showLocation: boolean;
rightElement?: React.ReactNode;
}

export const RepoSectionHeader = (props: Props) => {
const {expanded, onClick, repoName, repoLocation, showLocation, rightElement} = props;
const {repoName, repoLocation, showLocation, ...rest} = props;
const isDunderRepoName = repoName === DUNDER_REPO_NAME;
return (
<SectionHeaderButton $open={expanded} onClick={onClick}>
<Box
flex={{alignItems: 'center', justifyContent: 'space-between'}}
padding={{horizontal: 24}}
>
<Box flex={{alignItems: 'center', gap: 8}}>
<Icon name="folder" color={Colors.accentGray()} />
<div>
<RepoName>{isDunderRepoName ? repoLocation : repoName}</RepoName>
{showLocation && !isDunderRepoName ? (
<RepoLocation>{`@${repoLocation}`}</RepoLocation>
) : null}
</div>
</Box>
<Box flex={{alignItems: 'center', gap: 8}}>
{rightElement}
<Box margin={{top: 2}}>
<Icon name="arrow_drop_down" />
</Box>
</Box>
<TableSectionHeader {...rest}>
<Box flex={{alignItems: 'center', gap: 8}}>
<Icon name="folder" color={Colors.accentGray()} />
<div>
<RepoName>{isDunderRepoName ? repoLocation : repoName}</RepoName>
{showLocation && !isDunderRepoName ? (
<RepoLocation>{`@${repoLocation}`}</RepoLocation>
) : null}
</div>
</Box>
</SectionHeaderButton>
</TableSectionHeader>
);
};

const SectionHeaderButton = styled.button<{$open: boolean}>`
background-color: ${Colors.backgroundLight()};
border: 0;
box-shadow:
inset 0px -1px 0 ${Colors.keylineDefault()},
inset 0px 1px 0 ${Colors.keylineDefault()};
color: ${Colors.textLight()};
cursor: pointer;
display: block;
padding: 0;
width: 100%;
margin: 0;
height: ${SECTION_HEADER_HEIGHT}px;
text-align: left;
:focus,
:active {
outline: none;
}
:hover {
background-color: ${Colors.backgroundLightHover()};
}
${IconWrapper}[aria-label="arrow_drop_down"] {
transition: transform 100ms linear;
${({$open}) => ($open ? null : `transform: rotate(-90deg);`)}
}
`;

const RepoName = styled.span`
font-weight: 600;
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export const useRepoExpansionState = (collapsedKey: string, allKeys: string[]) =
);

const onToggle = useCallback(
(repoAddress: RepoAddress) => {
const key = repoAddressAsHumanString(repoAddress);
(_key: string | RepoAddress) => {
const key = typeof _key === 'object' ? repoAddressAsHumanString(_key) : _key;
setCollapsedKeys((current) => {
const nextCollapsedKeys = new Set(current || []);
if (nextCollapsedKeys.has(key)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import {Box, Colors, Icon, IconWrapper} from '@dagster-io/ui-components';
import styled from 'styled-components';

export const SECTION_HEADER_HEIGHT = 32;

export interface TableSectionHeaderProps {
expanded: boolean;
onClick: (e: React.MouseEvent) => void;
children?: React.ReactNode;
rightElement?: React.ReactNode;
}

export const TableSectionHeader = (props: TableSectionHeaderProps) => {
const {expanded, onClick, children, rightElement} = props;
return (
<SectionHeaderButton $open={expanded} onClick={onClick}>
<Box
flex={{alignItems: 'center', justifyContent: 'space-between'}}
padding={{horizontal: 24}}
>
{children}
<Box flex={{alignItems: 'center', gap: 8}}>
{rightElement}
<Box margin={{top: 2}}>
<Icon name="arrow_drop_down" />
</Box>
</Box>
</Box>
</SectionHeaderButton>
);
};

const SectionHeaderButton = styled.button<{$open: boolean}>`
background-color: ${Colors.backgroundLight()};
border: 0;
box-shadow:
inset 0px -1px 0 ${Colors.keylineDefault()},
inset 0px 1px 0 ${Colors.keylineDefault()};
color: ${Colors.textLight()};
cursor: pointer;
display: block;
padding: 0;
width: 100%;
margin: 0;
height: ${SECTION_HEADER_HEIGHT}px;
text-align: left;
:focus,
:active {
outline: none;
}
:hover {
background-color: ${Colors.backgroundLightHover()};
}
${IconWrapper}[aria-label="arrow_drop_down"] {
transition: transform 100ms linear;
${({$open}) => ($open ? null : `transform: rotate(-90deg);`)}
}
`;

0 comments on commit dd385af

Please sign in to comment.