mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-14 17:02:49 +03:00
console: if GDC source is only source, sidebar is showing "no data available" [DSF-178]
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8217 GitOrigin-RevId: f046a262b5a8966ed2142c011fb4f2163baa8cb0
This commit is contained in:
parent
dc83352863
commit
d306eda79a
@ -4,6 +4,7 @@ import { Key } from 'antd/lib/table/interface';
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { useTreeData } from './hooks/useTreeData';
|
import { useTreeData } from './hooks/useTreeData';
|
||||||
import '../../../../features/RemoteRelationships/RemoteSchemaRelationships/components/RemoteSchemaTree/index.css';
|
import '../../../../features/RemoteRelationships/RemoteSchemaRelationships/components/RemoteSchemaTree/index.css';
|
||||||
|
import { GDCTreeData } from './types';
|
||||||
|
|
||||||
const checkForGDCRoute = () => window.location.pathname.includes('data/v2');
|
const checkForGDCRoute = () => window.location.pathname.includes('data/v2');
|
||||||
|
|
||||||
@ -26,20 +27,17 @@ const getCurrentActiveKeys = () => {
|
|||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
onSelect: (value: Key[]) => void;
|
onSelect: (value: Key[]) => void;
|
||||||
|
treeData: GDCTreeData;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
export const GDCTree = ({ onSelect, treeData }: Props) => {
|
||||||
This component is still very much in development and will be changed once we have an API that tells us about the hierarchy of a GDC source
|
|
||||||
Until then, this component is more or less a POC/experminatal in nature and tests for its accompaniying story have not been included for this reason.
|
|
||||||
If you wish to test out this component, go to the settings > feature flag and enable "Experimental features for GDC"
|
|
||||||
*/
|
|
||||||
|
|
||||||
export const GDCTree = (props: Props) => {
|
|
||||||
const isGDCRouteActive = checkForGDCRoute();
|
const isGDCRouteActive = checkForGDCRoute();
|
||||||
|
|
||||||
const activeKey = isGDCRouteActive ? getCurrentActiveKeys() : [];
|
const activeKey = isGDCRouteActive ? getCurrentActiveKeys() : [];
|
||||||
const { data: gdcDatabases } = useTreeData();
|
|
||||||
if (!gdcDatabases || gdcDatabases.length === 0) return null;
|
// unclear if we still need this check since this component won't be rendered
|
||||||
|
// in the parent if "treeData" is empty
|
||||||
|
if (!treeData || treeData.length === 0) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tree
|
<Tree
|
||||||
@ -48,8 +46,8 @@ export const GDCTree = (props: Props) => {
|
|||||||
showIcon
|
showIcon
|
||||||
defaultExpandedKeys={activeKey} // there are only two variations here - DB level or table level. middle level selections cannot be accessed
|
defaultExpandedKeys={activeKey} // there are only two variations here - DB level or table level. middle level selections cannot be accessed
|
||||||
defaultSelectedKeys={activeKey}
|
defaultSelectedKeys={activeKey}
|
||||||
onSelect={props.onSelect}
|
onSelect={onSelect}
|
||||||
treeData={gdcDatabases}
|
treeData={treeData}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
export { GDCTree } from './GDCTree';
|
export { GDCTree } from './GDCTree';
|
||||||
export { useGDCTreeItemClick } from './hooks/useGDCTreeItemClick';
|
export { useGDCTreeItemClick } from './hooks/useGDCTreeItemClick';
|
||||||
|
export { useTreeData } from './hooks/useTreeData';
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Table } from '../../../../features/hasura-metadata-types';
|
import { Table } from '../../../../features/hasura-metadata-types';
|
||||||
|
import { DataNode } from 'antd/lib/tree';
|
||||||
/*
|
/*
|
||||||
A GDC Source can be any user defined DB that can be added during run-time. We can only know a few properties during build time, such as name and kind
|
A GDC Source can be any user defined DB that can be added during run-time. We can only know a few properties during build time, such as name and kind
|
||||||
which will be String, but for the tables - A GDC source can have any valid JSON definition for the `tables[i].table` property. The closest we can type is
|
which will be String, but for the tables - A GDC source can have any valid JSON definition for the `tables[i].table` property. The closest we can type is
|
||||||
@ -12,3 +12,5 @@ export type GDCSource = {
|
|||||||
table: Table;
|
table: Table;
|
||||||
}[];
|
}[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type GDCTreeData = DataNode[];
|
||||||
|
@ -21,6 +21,8 @@ import {
|
|||||||
} from '../../Common/utils/routesUtils';
|
} from '../../Common/utils/routesUtils';
|
||||||
import GqlCompatibilityWarning from '../../Common/GqlCompatibilityWarning/GqlCompatibilityWarning';
|
import GqlCompatibilityWarning from '../../Common/GqlCompatibilityWarning/GqlCompatibilityWarning';
|
||||||
import { GDCTree } from './GDCTree/GDCTree';
|
import { GDCTree } from './GDCTree/GDCTree';
|
||||||
|
import { useTreeData } from './GDCTree';
|
||||||
|
import { DataNode } from 'antd/lib/tree';
|
||||||
|
|
||||||
type SourceItemsTypes =
|
type SourceItemsTypes =
|
||||||
| 'database'
|
| 'database'
|
||||||
@ -408,7 +410,11 @@ const TreeView: React.FC<TreeViewProps> = ({
|
|||||||
onDatabaseChange(dataSource);
|
onDatabaseChange(dataSource);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (items.length === 0) {
|
const { data: gdcDatabases } = useTreeData();
|
||||||
|
|
||||||
|
const allDatabases = [...items, ...(gdcDatabases ?? [])];
|
||||||
|
|
||||||
|
if (allDatabases.length === 0) {
|
||||||
return preLoadState ? (
|
return preLoadState ? (
|
||||||
<div className={styles.treeNav}>
|
<div className={styles.treeNav}>
|
||||||
<span className={`${styles.title} ${styles.padd_bottom_small}`}>
|
<span className={`${styles.title} ${styles.padd_bottom_small}`}>
|
||||||
@ -453,7 +459,7 @@ const TreeView: React.FC<TreeViewProps> = ({
|
|||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
<div id="tree-container" className="inline-block">
|
<div id="tree-container" className="inline-block">
|
||||||
<GDCTree onSelect={gdcItemClick} />
|
<GDCTree onSelect={gdcItemClick} treeData={gdcDatabases ?? []} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user