msyavuz commented on code in PR #32587:
URL: https://github.com/apache/superset/pull/32587#discussion_r2149929730


##########
superset-frontend/src/components/GridTable/HeaderMenu.tsx:
##########
@@ -41,129 +41,199 @@ type Params = {
   onVisibleChange: DropdownProps['onOpenChange'];
 };
 
-const HeaderMenu: React.FC<Params> = ({
+const HeaderMenu: React.FC<HeaderMenuProps> = ({
   colId,
   api,
   pinnedLeft,
   pinnedRight,
   invisibleColumns,
   isMain,
   onVisibleChange,
-}: Params) => {
+}: HeaderMenuProps) => {
   const pinColumn = useCallback(
     (pinLoc: ColumnPinnedType) => {
       api.setColumnsPinned([colId], pinLoc);
     },
     [api, colId],
   );
 
-  const unHideAction = invisibleColumns.length > 0 && (
-    <Menu.SubMenu title={t('Unhide')} icon={<Icons.EyeOutlined iconSize="m" 
/>}>
-      {invisibleColumns.length > 1 && (
-        <Menu.Item
-          onClick={() => {
-            api.setColumnsVisible(invisibleColumns, true);
-          }}
-        >
-          <b>{t('All %s hidden columns', invisibleColumns.length)}</b>
-        </Menu.Item>
-      )}
-      {invisibleColumns.map(c => (
-        <Menu.Item
-          key={c.getColId()}
-          onClick={() => {
-            api.setColumnsVisible([c.getColId()], true);
-          }}
-        >
-          {c.getColDef().headerName}
-        </Menu.Item>
-      ))}
-    </Menu.SubMenu>
-  );
+  const unHideAction: MenuItem = {
+    label: t('Unhide'),
+    key: 'unHideSubMenu',
+    icon: <Icons.EyeInvisibleOutlined iconSize="m" />,
+    children: [
+      invisibleColumns.length > 1 && {
+        key: 'allHidden',
+        label: <b>{t('All %s hidden columns', invisibleColumns.length)}</b>,
+        onClick: () => {
+          api.setColumnsVisible(invisibleColumns, true);
+        },
+      },
+      ...invisibleColumns.map(c => ({
+        key: c.getColId(),
+        label: c.getColDef().headerName,
+        onClick: () => {
+          api.setColumnsVisible([c.getColId()], true);
+        },
+      })),
+    ].filter(Boolean) as MenuItem[],
+  };
+
+  const mainMenuItems: MenuItem[] = [
+    {
+      key: 'copyData',
+      label: t('Copy the current data'),
+      icon: <Icons.CopyOutlined iconSize="m" />,
+      onClick: () => {
+        copyTextToClipboard(
+          () =>
+            new Promise((resolve, reject) => {
+              const data = api.getDataAsCsv({
+                columnKeys: api
+                  .getAllDisplayedColumns()
+                  .map(c => c.getColId())
+                  .filter(id => id !== colId),
+                suppressQuotes: true,
+                columnSeparator: '\t',
+              });
+              if (data) {
+                resolve(data);
+              } else {
+                reject();

Review Comment:
   I didn't touch this part of the code, these were just moved over to items 
prop.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org
For additional commands, e-mail: notifications-h...@superset.apache.org

Reply via email to