Skip to content

Commit

Permalink
DRY up ternary statements
Browse files Browse the repository at this point in the history
  • Loading branch information
nytai committed Sep 2, 2020
1 parent 84e2c0b commit f99e7f2
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions superset-frontend/src/views/CRUD/data/database/DatabaseList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ const IconBlack = styled(Icon)`
color: ${({ theme }) => theme.colors.grayscale.dark1};
`;

function BooleanDisplay(value: any) {
return value ? <IconBlack name="check" /> : <IconBlack name="cancel-x" />;
}

function DatabaseList({ addDangerToast, addSuccessToast }: DatabaseListProps) {
const {
state: {
Expand Down Expand Up @@ -129,12 +133,7 @@ function DatabaseList({ addDangerToast, addSuccessToast }: DatabaseListProps) {
row: {
original: { allow_run_async: allowRunAsync },
},
}: any) =>
allowRunAsync ? (
<IconBlack name="check" />
) : (
<IconBlack name="cancel-x" />
),
}: any) => <BooleanDisplay value={allowRunAsync} />,
size: 'md',
},
{
Expand All @@ -152,8 +151,7 @@ function DatabaseList({ addDangerToast, addSuccessToast }: DatabaseListProps) {
row: {
original: { allow_dml: allowDML },
},
}: any) =>
allowDML ? <IconBlack name="check" /> : <IconBlack name="cancel-x" />,
}: any) => <BooleanDisplay value={allowDML} />,
size: 'md',
},
{
Expand All @@ -163,12 +161,7 @@ function DatabaseList({ addDangerToast, addSuccessToast }: DatabaseListProps) {
row: {
original: { allow_csv_upload: allowCSVUpload },
},
}: any) =>
allowCSVUpload ? (
<IconBlack name="check" />
) : (
<IconBlack name="cancel-x" />
),
}: any) => <BooleanDisplay value={allowCSVUpload} />,
size: 'xl',
},
{
Expand All @@ -178,12 +171,7 @@ function DatabaseList({ addDangerToast, addSuccessToast }: DatabaseListProps) {
row: {
original: { expose_in_sqllab: exposeInSqllab },
},
}: any) =>
exposeInSqllab ? (
<IconBlack name="check" />
) : (
<IconBlack name="cancel-x" />
),
}: any) => <BooleanDisplay value={exposeInSqllab} />,
size: 'xxl',
},
{
Expand Down

0 comments on commit f99e7f2

Please sign in to comment.