The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
import { createContext, useContext } from "react";
import type { ConcreteTableId } from "metabase-types/api";
type SchemaViewerContextValue = {
visibleTableIds: Set<ConcreteTableId>;
/**
* IDs of tables whose fetch was triggered by an FK-field expansion and has
* not yet resolved. Field rows use this to show a loader in place of the
* database type while the new table is being loaded.
*/
expandingTableIds: Set<ConcreteTableId>;
expandToTable: (
tableId: ConcreteTableId,
/**
* Edge IDs to try selecting once the new table arrives in the graph.
* Pass both possible orderings (source-first and target-first) since
* the backend's source/target convention isn't fixed.
*/
candidateEdgeIdsToSelect?: readonly string[],
) => void;
selectedNodeId: string | null;
selectNode: (nodeId: string | null) => void;
zoomToNode: (nodeId: string) => void;
};
export const SchemaViewerContext = createContext<SchemaViewerContextValue>({
visibleTableIds: new Set(),
expandingTableIds: new Set(),
expandToTable: () => {},
selectedNodeId: null,
selectNode: () => {},
zoomToNode: () => {},
});
export function useSchemaViewerContext() {
return useContext(SchemaViewerContext);
}