Skip to content

Commit

Permalink
simplify icon compoent mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
justinpark committed Nov 15, 2022
1 parent d4bb426 commit b8be2b7
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions superset-frontend/src/SqlLab/components/TabStatusIcon/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
import React from 'react';
import { QueryState, styled } from '@superset-ui/core';
import Icons from 'src/components/Icons';
import Icons, { IconType } from 'src/components/Icons';

const IconContainer = styled.span`
position: absolute;
Expand All @@ -30,13 +30,18 @@ interface TabStatusIconProps {
tabState: QueryState;
}

const STATE_ICONS: Record<string, React.FC<IconType>> = {
success: Icons.Check,
failed: Icons.CancelX,
};

export default function TabStatusIcon({ tabState }: TabStatusIconProps) {
const StatusIcon = STATE_ICONS[tabState];
return (
<div className={`circle ${tabState}`}>
{['success', 'failed'].includes(tabState) && (
{StatusIcon && (
<IconContainer>
{tabState === 'success' && <Icons.Check iconSize="xs" />}
{tabState === 'failed' && <Icons.CancelX iconSize="xs" />}
<StatusIcon iconSize="xs" />
</IconContainer>
)}
</div>
Expand Down

0 comments on commit b8be2b7

Please sign in to comment.