mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 01:12:56 +03:00
console: filter out nonsupported databases
GitOrigin-RevId: 151cde9843310e069d81d1690666100bfa77c37f
This commit is contained in:
parent
dfbdfca144
commit
ad0ecc7363
@ -32,6 +32,7 @@ import ConnectedDataSourceContainer from './DataSourceContainer';
|
|||||||
import ConnectDatabase from './DataSources/ConnectDatabase';
|
import ConnectDatabase from './DataSources/ConnectDatabase';
|
||||||
import { setDriver } from '../../../dataSources';
|
import { setDriver } from '../../../dataSources';
|
||||||
import { UPDATE_CURRENT_DATA_SOURCE } from './DataActions';
|
import { UPDATE_CURRENT_DATA_SOURCE } from './DataActions';
|
||||||
|
import { getSourcesFromMetadata } from '../../../metadata/selector';
|
||||||
|
|
||||||
const makeDataRouter = (
|
const makeDataRouter = (
|
||||||
connect,
|
connect,
|
||||||
@ -138,7 +139,7 @@ const makeDataRouter = (
|
|||||||
const dataRouterUtils = (connect, store, composeOnEnterHooks) => {
|
const dataRouterUtils = (connect, store, composeOnEnterHooks) => {
|
||||||
const requireSource = (nextState, replaceState, cb) => {
|
const requireSource = (nextState, replaceState, cb) => {
|
||||||
store.dispatch(exportMetadata()).then(state => {
|
store.dispatch(exportMetadata()).then(state => {
|
||||||
const sources = state?.metadata?.metadataObject?.sources || [];
|
const sources = getSourcesFromMetadata(state) || [];
|
||||||
const currentSource = state?.tables?.currentDataSource || '';
|
const currentSource = state?.tables?.currentDataSource || '';
|
||||||
|
|
||||||
if (currentSource) {
|
if (currentSource) {
|
||||||
|
@ -7,7 +7,11 @@ import { getDatabaseTableTypeInfoForAllSources } from './DataActions';
|
|||||||
import { isInconsistentSource, getSourceDriver } from './utils';
|
import { isInconsistentSource, getSourceDriver } from './utils';
|
||||||
import { canReUseTableTypes } from './DataSources/utils';
|
import { canReUseTableTypes } from './DataSources/utils';
|
||||||
import { useDataSource } from '../../../dataSources';
|
import { useDataSource } from '../../../dataSources';
|
||||||
import { getDataSources } from '../../../metadata/selector';
|
import {
|
||||||
|
getDataSources,
|
||||||
|
getSourcesFromMetadata,
|
||||||
|
getTablesFromAllSources,
|
||||||
|
} from '../../../metadata/selector';
|
||||||
import {
|
import {
|
||||||
updateCurrentSchema,
|
updateCurrentSchema,
|
||||||
UPDATE_CURRENT_DATA_SOURCE,
|
UPDATE_CURRENT_DATA_SOURCE,
|
||||||
@ -309,15 +313,14 @@ const DataSubSidebar = props => {
|
|||||||
const mapStateToProps = state => {
|
const mapStateToProps = state => {
|
||||||
return {
|
return {
|
||||||
migrationMode: state.main.migrationMode,
|
migrationMode: state.main.migrationMode,
|
||||||
sources: state.metadata.metadataObject.sources,
|
sources: getSourcesFromMetadata(state),
|
||||||
inconsistentObjects: state.metadata.inconsistentObjects,
|
inconsistentObjects: state.metadata.inconsistentObjects,
|
||||||
tables: state.metadata.metadataObject.sources.map(s => s.tables).flat()
|
tables: getTablesFromAllSources(state).flat().length,
|
||||||
.length,
|
enums: getSourcesFromMetadata(state)
|
||||||
enums: state.metadata.metadataObject.sources
|
|
||||||
.map(s => s.tables)
|
.map(s => s.tables)
|
||||||
.flat()
|
.flat()
|
||||||
.filter(item => item.hasOwnProperty('is_enum')).length,
|
.filter(item => item.hasOwnProperty('is_enum')).length,
|
||||||
functions: state.metadata.metadataObject.sources
|
functions: getSourcesFromMetadata(state)
|
||||||
.map(s => s.functions || [])
|
.map(s => s.functions || [])
|
||||||
.flat().length,
|
.flat().length,
|
||||||
currentDataSource: state.tables.currentDataSource,
|
currentDataSource: state.tables.currentDataSource,
|
||||||
|
@ -4,7 +4,7 @@ import { FixMe, ReduxState } from '../types';
|
|||||||
import { TableEntry, DataSource } from './types';
|
import { TableEntry, DataSource } from './types';
|
||||||
import { filterInconsistentMetadataObjects } from '../components/Services/Settings/utils';
|
import { filterInconsistentMetadataObjects } from '../components/Services/Settings/utils';
|
||||||
import { parseCustomTypes } from '../shared/utils/hasuraCustomTypeUtils';
|
import { parseCustomTypes } from '../shared/utils/hasuraCustomTypeUtils';
|
||||||
import { Driver } from '../dataSources';
|
import { Driver, drivers } from '../dataSources';
|
||||||
import {
|
import {
|
||||||
EventTrigger,
|
EventTrigger,
|
||||||
ScheduledTrigger,
|
ScheduledTrigger,
|
||||||
@ -28,7 +28,10 @@ export const getRemoteSchemaPermissions = (state: ReduxState) => {
|
|||||||
export const getInitDataSource = (
|
export const getInitDataSource = (
|
||||||
state: ReduxState
|
state: ReduxState
|
||||||
): { source: string; driver: Driver } => {
|
): { source: string; driver: Driver } => {
|
||||||
const dataSources = state.metadata.metadataObject?.sources || [];
|
const dataSources =
|
||||||
|
state.metadata.metadataObject?.sources.filter(s =>
|
||||||
|
s.kind ? drivers.includes(s.kind) : true
|
||||||
|
) || [];
|
||||||
if (dataSources.length) {
|
if (dataSources.length) {
|
||||||
return {
|
return {
|
||||||
source: dataSources[0].name,
|
source: dataSources[0].name,
|
||||||
@ -356,30 +359,38 @@ export const getAllowedQueries = (state: ReduxState) =>
|
|||||||
export const getInheritedRoles = (state: ReduxState) =>
|
export const getInheritedRoles = (state: ReduxState) =>
|
||||||
state.metadata.inheritedRoles || [];
|
state.metadata.inheritedRoles || [];
|
||||||
|
|
||||||
|
export const getSourcesFromMetadata = createSelector(getMetadata, metadata => {
|
||||||
|
return metadata?.sources.filter(s =>
|
||||||
|
s.kind ? drivers.includes(s.kind) : true
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
export const getDataSources = createSelector(getMetadata, metadata => {
|
export const getDataSources = createSelector(getMetadata, metadata => {
|
||||||
const sources: DataSource[] = [];
|
const sources: DataSource[] = [];
|
||||||
metadata?.sources.forEach(source => {
|
metadata?.sources
|
||||||
let url: string | { from_env: string } = '';
|
.filter(s => (s.kind ? drivers.includes(s.kind) : true))
|
||||||
if (source.kind === 'bigquery') {
|
.forEach(source => {
|
||||||
url = source.configuration?.service_account?.from_env || '';
|
let url: string | { from_env: string } = '';
|
||||||
} else {
|
if (source.kind === 'bigquery') {
|
||||||
url = source.configuration?.connection_info?.connection_string
|
url = source.configuration?.service_account?.from_env || '';
|
||||||
? source.configuration?.connection_info.connection_string
|
} else {
|
||||||
: source.configuration?.connection_info?.database_url || '';
|
url = source.configuration?.connection_info?.connection_string
|
||||||
}
|
? source.configuration?.connection_info.connection_string
|
||||||
sources.push({
|
: source.configuration?.connection_info?.database_url || '';
|
||||||
name: source.name,
|
}
|
||||||
url,
|
sources.push({
|
||||||
connection_pool_settings: source.configuration?.connection_info
|
name: source.name,
|
||||||
?.pool_settings || {
|
url,
|
||||||
retries: 1,
|
connection_pool_settings: source.configuration?.connection_info
|
||||||
idle_timeout: 180,
|
?.pool_settings || {
|
||||||
max_connections: 50,
|
retries: 1,
|
||||||
},
|
idle_timeout: 180,
|
||||||
driver: source.kind || 'postgres',
|
max_connections: 50,
|
||||||
read_replicas: source.configuration?.read_replicas ?? undefined,
|
},
|
||||||
|
driver: source.kind || 'postgres',
|
||||||
|
read_replicas: source.configuration?.read_replicas ?? undefined,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
return sources;
|
return sources;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user