diff --git a/superset-frontend/src/components/GridTable/Header.tsx b/superset-frontend/src/components/GridTable/Header.tsx index a50677970707b..c613f9b5d2eda 100644 --- a/superset-frontend/src/components/GridTable/Header.tsx +++ b/superset-frontend/src/components/GridTable/Header.tsx @@ -57,14 +57,13 @@ const SortSeqLabel = styled.span` const HeaderAction = styled.div` display: none; position: absolute; - right: ${({ theme }) => theme.gridUnit * 3}px; + right: 0; &.main { - margin: 0 auto; - left: 0; - right: 0; - width: 20px; + flex-direction: row; + justify-content: center; + width: 100%; } - & .ant-dropdown-trigger { + & .antd5-dropdown-trigger { cursor: context-menu; padding: ${({ theme }) => theme.gridUnit * 2}px; background-color: var(--ag-background-color); diff --git a/superset-frontend/src/components/GridTable/HeaderMenu.test.tsx b/superset-frontend/src/components/GridTable/HeaderMenu.test.tsx index 1776aee36878e..d0124f4dd975e 100644 --- a/superset-frontend/src/components/GridTable/HeaderMenu.test.tsx +++ b/superset-frontend/src/components/GridTable/HeaderMenu.test.tsx @@ -70,7 +70,7 @@ jest.mock('src/components/Icons', () => ({ })); jest.mock('src/components/Dropdown', () => ({ - Dropdown: ({ overlay }: { overlay: React.ReactChild }) => ( + MenuDotsDropdown: ({ overlay }: { overlay: React.ReactChild }) => (
{overlay}
), })); diff --git a/superset-frontend/src/components/GridTable/HeaderMenu.tsx b/superset-frontend/src/components/GridTable/HeaderMenu.tsx index 648c5e213872a..5d327104b5c56 100644 --- a/superset-frontend/src/components/GridTable/HeaderMenu.tsx +++ b/superset-frontend/src/components/GridTable/HeaderMenu.tsx @@ -21,17 +21,13 @@ import { styled, t } from '@superset-ui/core'; import type { Column, ColumnPinnedType, GridApi } from 'ag-grid-community'; import Icons from 'src/components/Icons'; -import { Dropdown, DropdownProps } from 'src/components/Dropdown'; +import { MenuDotsDropdown, DropdownProps } from 'src/components/Dropdown'; import { Menu } from 'src/components/Menu'; import copyTextToClipboard from 'src/utils/copy'; import { PIVOT_COL_ID } from './constants'; -const IconMenuItem = styled(Menu.Item)` - display: flex; - align-items: center; -`; const IconEmpty = styled.span` - width: 20px; + width: 14px; `; type Params = { @@ -42,7 +38,7 @@ type Params = { pinnedRight?: boolean; invisibleColumns: Column[]; isMain?: boolean; - onVisibleChange: DropdownProps['onVisibleChange']; + onVisibleChange: DropdownProps['onOpenChange']; }; const HeaderMenu: React.FC = ({ @@ -62,14 +58,7 @@ const HeaderMenu: React.FC = ({ ); const unHideAction = invisibleColumns.length > 0 && ( - - - {t('Unhide')} - - } - > + }> {invisibleColumns.length > 1 && ( { @@ -94,13 +83,13 @@ const HeaderMenu: React.FC = ({ if (isMain) { return ( - - { copyTextToClipboard( () => @@ -121,10 +110,11 @@ const HeaderMenu: React.FC = ({ }), ); }} + icon={} > - {t('Copy the current data')} - - + { api.exportDataAsCsv({ columnKeys: api @@ -133,21 +123,22 @@ const HeaderMenu: React.FC = ({ .filter(id => id !== colId), }); }} + icon={} > - {t('Download to CSV')} - + {t('Download to CSV')} + - { api.autoSizeAllColumns(); }} + icon={} > - {t('Autosize all columns')} - + {unHideAction} - { api.setColumnsVisible(invisibleColumns, true); const columns = api.getColumns(); @@ -165,10 +156,10 @@ const HeaderMenu: React.FC = ({ } } }} + icon={} > - {t('Reset columns')} - + } /> @@ -176,13 +167,13 @@ const HeaderMenu: React.FC = ({ } return ( - - { copyTextToClipboard( () => @@ -199,44 +190,52 @@ const HeaderMenu: React.FC = ({ }), ); }} + icon={} > - {t('Copy')} - + {t('Copy')} + {(pinnedLeft || pinnedRight) && ( - pinColumn(null)}> - {t('Unpin')} - + pinColumn(null)} + icon={} + > + {t('Unpin')} + )} {!pinnedLeft && ( - pinColumn('left')}> - + pinColumn('left')} + icon={} + > {t('Pin Left')} - + )} {!pinnedRight && ( - pinColumn('right')}> - + pinColumn('right')} + icon={} + > {t('Pin Right')} - + )} - { api.autoSizeColumns([colId]); }} + icon={} > - {t('Autosize Column')} - - + { api.setColumnsVisible([colId], false); }} disabled={api.getColumns()?.length === invisibleColumns.length + 1} + icon={} > - {t('Hide Column')} - + {unHideAction} } diff --git a/superset-frontend/src/components/GridTable/index.tsx b/superset-frontend/src/components/GridTable/index.tsx index aab529fa5690c..ad3130840f4f0 100644 --- a/superset-frontend/src/components/GridTable/index.tsx +++ b/superset-frontend/src/components/GridTable/index.tsx @@ -132,7 +132,7 @@ function GridTable({ field: PIVOT_COL_ID, valueGetter: 'node.rowIndex+1', cellClass: 'locked-col', - width: 20 + rowIndexLength * 6, + width: 30 + rowIndexLength * 6, suppressNavigable: true, resizable: false, pinned: 'left' as const, @@ -218,7 +218,7 @@ function GridTable({ overflow: hidden; } & [role='columnheader']:hover .customHeaderAction { - display: block; + display: flex; } `} /> diff --git a/superset-frontend/src/components/Menu/index.tsx b/superset-frontend/src/components/Menu/index.tsx index 5d0f6e0dcccb5..81374c82975e1 100644 --- a/superset-frontend/src/components/Menu/index.tsx +++ b/superset-frontend/src/components/Menu/index.tsx @@ -118,6 +118,9 @@ const StyledSubMenu = styled(AntdMenu.SubMenu)` } } } + .antd5-dropdown-menu-submenu-title { + align-items: center; + } .antd5-menu-submenu-title { display: flex; flex-direction: row-reverse;