Browse Source

fix page crash if we set collection and database with the same id

Signed-off-by: ryjiang <jiangruiyi@gmail.com>
ryjiang 1 year ago
parent
commit
7047c7d1d4
2 changed files with 3 additions and 7 deletions
  1. 0 2
      client/src/components/grid/Grid.tsx
  2. 3 5
      client/src/pages/databases/tree/index.tsx

+ 0 - 2
client/src/components/grid/Grid.tsx

@@ -190,8 +190,6 @@ const AttuGrid: FC<AttuGridType> = props => {
 
       const rowCount = Math.floor(totalHeight / rowHeight);
 
-      console.log('hasToolbar', hasToolbar, showPagination);
-
       // fix loading mask
       setLoadingRowCount(rowCount);
 

+ 3 - 5
client/src/pages/databases/tree/index.tsx

@@ -88,7 +88,7 @@ const DatabaseTree: React.FC<DatabaseToolProps> = props => {
   // format tree data
   const children = collections.map(c => {
     return {
-      id: c.collection_name,
+      id: `c_${c.collection_name}`,
       name: c.collection_name,
       type: 'collection' as TreeNodeType,
     };
@@ -103,8 +103,6 @@ const DatabaseTree: React.FC<DatabaseToolProps> = props => {
     children: children,
   };
 
-  // UI data
-  const expanded = getExpanded([tree]);
   // Icons
   const DatabaseIcon = icons.database;
   const CollectionIcon = icons.navCollection;
@@ -118,7 +116,7 @@ const DatabaseTree: React.FC<DatabaseToolProps> = props => {
     navigate(
       node.type === 'db'
         ? `/databases/${database}/${params.databasePage || 'collections'}`
-        : `/databases/${database}/${node.id}/${params.collectionPage || 'data'}`
+        : `/databases/${database}/${node.name}/${params.collectionPage || 'data'}`
     );
   };
 
@@ -165,7 +163,7 @@ const DatabaseTree: React.FC<DatabaseToolProps> = props => {
 
   return (
     <TreeView
-      expanded={expanded}
+      expanded={[database]}
       multiSelect={false}
       disableSelection={false}
       selected={params.collectionName || params.databaseName}