From 225c905bd52105479a374e270c9bb97aaa46db1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CA=88=E1=B5=83=E1=B5=A2?= Date: Wed, 21 Oct 2020 09:27:48 -0700 Subject: [PATCH] fix(listview): hide actions column if no actions are allowed (#11337) --- superset-frontend/src/SqlLab/components/QuerySearch.jsx | 4 ++++ .../src/components/dataViewCommon/TableCollection.tsx | 1 + superset-frontend/src/views/CRUD/chart/ChartList.tsx | 4 +--- .../src/views/CRUD/csstemplates/CssTemplatesList.tsx | 5 +---- superset-frontend/src/views/CRUD/dashboard/DashboardList.tsx | 5 ++--- .../src/views/CRUD/data/database/DatabaseList.tsx | 5 ++--- .../src/views/CRUD/data/dataset/DatasetList.tsx | 5 ++--- 7 files changed, 13 insertions(+), 16 deletions(-) diff --git a/superset-frontend/src/SqlLab/components/QuerySearch.jsx b/superset-frontend/src/SqlLab/components/QuerySearch.jsx index b35524d2a0..c730651dbc 100644 --- a/superset-frontend/src/SqlLab/components/QuerySearch.jsx +++ b/superset-frontend/src/SqlLab/components/QuerySearch.jsx @@ -47,6 +47,10 @@ const TableWrapper = styled.div` `; const TableStyles = styled.div` + table { + background-color: ${({ theme }) => theme.colors.grayscale.light4}; + } + .table > thead > tr > th { border-bottom: ${({ theme }) => theme.gridUnit / 2}px solid ${({ theme }) => theme.colors.grayscale.light2}; diff --git a/superset-frontend/src/components/dataViewCommon/TableCollection.tsx b/superset-frontend/src/components/dataViewCommon/TableCollection.tsx index 866801f60f..c0a857c053 100644 --- a/superset-frontend/src/components/dataViewCommon/TableCollection.tsx +++ b/superset-frontend/src/components/dataViewCommon/TableCollection.tsx @@ -34,6 +34,7 @@ interface TableCollectionProps { } export const Table = styled.table` + background-color: ${({ theme }) => theme.colors.grayscale.light5}; border-collapse: separate; border-radius: ${({ theme }) => theme.borderRadius}px; diff --git a/superset-frontend/src/views/CRUD/chart/ChartList.tsx b/superset-frontend/src/views/CRUD/chart/ChartList.tsx index 3e4b6dbdb0..4323f4694c 100644 --- a/superset-frontend/src/views/CRUD/chart/ChartList.tsx +++ b/superset-frontend/src/views/CRUD/chart/ChartList.tsx @@ -268,9 +268,6 @@ function ChartList(props: ChartListProps) { Cell: ({ row: { original } }: any) => { const handleDelete = () => handleChartDelete(original); const openEditModal = () => openChartEditModal(original); - if (!canEdit && !canDelete) { - return null; - } return ( @@ -325,6 +322,7 @@ function ChartList(props: ChartListProps) { Header: t('Actions'), id: 'actions', disableSortBy: true, + hidden: !canEdit && !canDelete, }, ], [canEdit, canDelete], diff --git a/superset-frontend/src/views/CRUD/csstemplates/CssTemplatesList.tsx b/superset-frontend/src/views/CRUD/csstemplates/CssTemplatesList.tsx index 2604b5827f..cd7e90d938 100644 --- a/superset-frontend/src/views/CRUD/csstemplates/CssTemplatesList.tsx +++ b/superset-frontend/src/views/CRUD/csstemplates/CssTemplatesList.tsx @@ -152,15 +152,12 @@ function CssTemplatesList({ : null, ].filter(item => !!item); - if (!canEdit && !canDelete) { - return null; - } - return ; }, Header: t('Actions'), id: 'actions', disableSortBy: true, + hidden: !canEdit && !canDelete, size: 'xl', }, ], diff --git a/superset-frontend/src/views/CRUD/dashboard/DashboardList.tsx b/superset-frontend/src/views/CRUD/dashboard/DashboardList.tsx index e08fb7c506..ac4d747419 100644 --- a/superset-frontend/src/views/CRUD/dashboard/DashboardList.tsx +++ b/superset-frontend/src/views/CRUD/dashboard/DashboardList.tsx @@ -258,9 +258,7 @@ function DashboardList(props: DashboardListProps) { const handleDelete = () => handleDashboardDelete(original); const handleEdit = () => openDashboardEditModal(original); const handleExport = () => handleBulkDashboardExport([original]); - if (!canEdit && !canDelete && !canExport) { - return null; - } + return ( {canDelete && ( @@ -332,6 +330,7 @@ function DashboardList(props: DashboardListProps) { }, Header: t('Actions'), id: 'actions', + hidden: !canEdit && !canDelete && !canExport, disableSortBy: true, }, ], diff --git a/superset-frontend/src/views/CRUD/data/database/DatabaseList.tsx b/superset-frontend/src/views/CRUD/data/database/DatabaseList.tsx index 81c633c28c..962de6ead2 100644 --- a/superset-frontend/src/views/CRUD/data/database/DatabaseList.tsx +++ b/superset-frontend/src/views/CRUD/data/database/DatabaseList.tsx @@ -238,9 +238,7 @@ function DatabaseList({ addDangerToast, addSuccessToast }: DatabaseListProps) { Cell: ({ row: { original } }: any) => { const handleEdit = () => handleDatabaseEdit(original); const handleDelete = () => openDatabaseDeleteModal(original); - if (!canEdit && !canDelete) { - return null; - } + return ( {canEdit && ( @@ -281,6 +279,7 @@ function DatabaseList({ addDangerToast, addSuccessToast }: DatabaseListProps) { }, Header: t('Actions'), id: 'actions', + hidden: !canEdit && !canDelete, disableSortBy: true, }, ], diff --git a/superset-frontend/src/views/CRUD/data/dataset/DatasetList.tsx b/superset-frontend/src/views/CRUD/data/dataset/DatasetList.tsx index 37567d0218..419fe5add9 100644 --- a/superset-frontend/src/views/CRUD/data/dataset/DatasetList.tsx +++ b/superset-frontend/src/views/CRUD/data/dataset/DatasetList.tsx @@ -250,9 +250,7 @@ const DatasetList: FunctionComponent = ({ Cell: ({ row: { original } }: any) => { const handleEdit = () => openDatasetEditModal(original); const handleDelete = () => openDatasetDeleteModal(original); - if (!canEdit && !canDelete) { - return null; - } + return ( {canDelete && ( @@ -293,6 +291,7 @@ const DatasetList: FunctionComponent = ({ }, Header: t('Actions'), id: 'actions', + hidden: !canEdit && !canDelete, disableSortBy: true, }, ],