From 92d5f193531a299d96efd2c34ebd1697417cc2b0 Mon Sep 17 00:00:00 2001 From: EugeneTorap Date: Sun, 23 Jan 2022 16:07:00 +0300 Subject: [PATCH 1/3] Remove redundant propTypes --- .../SqlLab/components/ColumnElement/index.tsx | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/superset-frontend/src/SqlLab/components/ColumnElement/index.tsx b/superset-frontend/src/SqlLab/components/ColumnElement/index.tsx index d2433c8944ab0..c4f4a88dba820 100644 --- a/superset-frontend/src/SqlLab/components/ColumnElement/index.tsx +++ b/superset-frontend/src/SqlLab/components/ColumnElement/index.tsx @@ -16,17 +16,11 @@ * specific language governing permissions and limitations * under the License. */ -import React from 'react'; -import PropTypes from 'prop-types'; +import React, { FC } from 'react'; import { ClassNames } from '@emotion/react'; import { styled, useTheme } from '@superset-ui/core'; - import { Tooltip } from 'src/components/Tooltip'; -const propTypes = { - column: PropTypes.object.isRequired, -}; - const StyledTooltip = (props: any) => { const theme = useTheme(); return ( @@ -64,6 +58,7 @@ const iconMap = { fk: 'fa-link', index: 'fa-bookmark', }; + const tooltipTitleMap = { pk: 'Primary key', fk: 'Foreign key', @@ -74,14 +69,14 @@ export type ColumnKeyTypeType = keyof typeof tooltipTitleMap; interface ColumnElementProps { column: { - name: string; + name: React.ReactNode; keys?: { type: ColumnKeyTypeType }[]; type: string; }; } -export default function ColumnElement({ column }: ColumnElementProps) { - let columnName: React.ReactNode = column.name; +const ColumnElement: FC = ({ column }) => { + let columnName = column.name; let icons; if (column.keys && column.keys.length > 0) { columnName = {column.name}; @@ -115,5 +110,6 @@ export default function ColumnElement({ column }: ColumnElementProps) { ); -} -ColumnElement.propTypes = propTypes; +}; + +export default ColumnElement; From 4bd655addc6036c38112d94e1ddcaa5d7a1eed28 Mon Sep 17 00:00:00 2001 From: EugeneTorap Date: Mon, 24 Jan 2022 21:43:17 +0300 Subject: [PATCH 2/3] Refactoring --- .../src/SqlLab/components/ColumnElement/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/superset-frontend/src/SqlLab/components/ColumnElement/index.tsx b/superset-frontend/src/SqlLab/components/ColumnElement/index.tsx index c4f4a88dba820..7709cd55e6113 100644 --- a/superset-frontend/src/SqlLab/components/ColumnElement/index.tsx +++ b/superset-frontend/src/SqlLab/components/ColumnElement/index.tsx @@ -69,14 +69,14 @@ export type ColumnKeyTypeType = keyof typeof tooltipTitleMap; interface ColumnElementProps { column: { - name: React.ReactNode; + name: string; keys?: { type: ColumnKeyTypeType }[]; type: string; }; } const ColumnElement: FC = ({ column }) => { - let columnName = column.name; + let columnName: React.ReactNode = column.name; let icons; if (column.keys && column.keys.length > 0) { columnName = {column.name}; From 7576bb22e2a8c720ed89c0bb0f8902d780179523 Mon Sep 17 00:00:00 2001 From: EugeneTorap Date: Fri, 28 Jan 2022 10:51:38 +0300 Subject: [PATCH 3/3] Refactoring --- .../src/SqlLab/components/ColumnElement/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/superset-frontend/src/SqlLab/components/ColumnElement/index.tsx b/superset-frontend/src/SqlLab/components/ColumnElement/index.tsx index 7709cd55e6113..9dc0583b423de 100644 --- a/superset-frontend/src/SqlLab/components/ColumnElement/index.tsx +++ b/superset-frontend/src/SqlLab/components/ColumnElement/index.tsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import React, { FC } from 'react'; +import React from 'react'; import { ClassNames } from '@emotion/react'; import { styled, useTheme } from '@superset-ui/core'; import { Tooltip } from 'src/components/Tooltip'; @@ -75,7 +75,7 @@ interface ColumnElementProps { }; } -const ColumnElement: FC = ({ column }) => { +const ColumnElement = ({ column }: ColumnElementProps) => { let columnName: React.ReactNode = column.name; let icons; if (column.keys && column.keys.length > 0) {