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 { setDriver } from '../../../dataSources';
|
||||
import { UPDATE_CURRENT_DATA_SOURCE } from './DataActions';
|
||||
import { getSourcesFromMetadata } from '../../../metadata/selector';
|
||||
|
||||
const makeDataRouter = (
|
||||
connect,
|
||||
@ -138,7 +139,7 @@ const makeDataRouter = (
|
||||
const dataRouterUtils = (connect, store, composeOnEnterHooks) => {
|
||||
const requireSource = (nextState, replaceState, cb) => {
|
||||
store.dispatch(exportMetadata()).then(state => {
|
||||
const sources = state?.metadata?.metadataObject?.sources || [];
|
||||
const sources = getSourcesFromMetadata(state) || [];
|
||||
const currentSource = state?.tables?.currentDataSource || '';
|
||||
|
||||
if (currentSource) {
|
||||
|
@ -7,7 +7,11 @@ import { getDatabaseTableTypeInfoForAllSources } from './DataActions';
|
||||
import { isInconsistentSource, getSourceDriver } from './utils';
|
||||
import { canReUseTableTypes } from './DataSources/utils';
|
||||
import { useDataSource } from '../../../dataSources';
|
||||
import { getDataSources } from '../../../metadata/selector';
|
||||
import {
|
||||
getDataSources,
|
||||
getSourcesFromMetadata,
|
||||
getTablesFromAllSources,
|
||||
} from '../../../metadata/selector';
|
||||
import {
|
||||
updateCurrentSchema,
|
||||
UPDATE_CURRENT_DATA_SOURCE,
|
||||
@ -309,15 +313,14 @@ const DataSubSidebar = props => {
|
||||
const mapStateToProps = state => {
|
||||
return {
|
||||
migrationMode: state.main.migrationMode,
|
||||
sources: state.metadata.metadataObject.sources,
|
||||
sources: getSourcesFromMetadata(state),
|
||||
inconsistentObjects: state.metadata.inconsistentObjects,
|
||||
tables: state.metadata.metadataObject.sources.map(s => s.tables).flat()
|
||||
.length,
|
||||
enums: state.metadata.metadataObject.sources
|
||||
tables: getTablesFromAllSources(state).flat().length,
|
||||
enums: getSourcesFromMetadata(state)
|
||||
.map(s => s.tables)
|
||||
.flat()
|
||||
.filter(item => item.hasOwnProperty('is_enum')).length,
|
||||
functions: state.metadata.metadataObject.sources
|
||||
functions: getSourcesFromMetadata(state)
|
||||
.map(s => s.functions || [])
|
||||
.flat().length,
|
||||
currentDataSource: state.tables.currentDataSource,
|
||||
|
@ -4,7 +4,7 @@ import { FixMe, ReduxState } from '../types';
|
||||
import { TableEntry, DataSource } from './types';
|
||||
import { filterInconsistentMetadataObjects } from '../components/Services/Settings/utils';
|
||||
import { parseCustomTypes } from '../shared/utils/hasuraCustomTypeUtils';
|
||||
import { Driver } from '../dataSources';
|
||||
import { Driver, drivers } from '../dataSources';
|
||||
import {
|
||||
EventTrigger,
|
||||
ScheduledTrigger,
|
||||
@ -28,7 +28,10 @@ export const getRemoteSchemaPermissions = (state: ReduxState) => {
|
||||
export const getInitDataSource = (
|
||||
state: ReduxState
|
||||
): { 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) {
|
||||
return {
|
||||
source: dataSources[0].name,
|
||||
@ -356,30 +359,38 @@ export const getAllowedQueries = (state: ReduxState) =>
|
||||
export const getInheritedRoles = (state: ReduxState) =>
|
||||
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 => {
|
||||
const sources: DataSource[] = [];
|
||||
metadata?.sources.forEach(source => {
|
||||
let url: string | { from_env: string } = '';
|
||||
if (source.kind === 'bigquery') {
|
||||
url = source.configuration?.service_account?.from_env || '';
|
||||
} else {
|
||||
url = source.configuration?.connection_info?.connection_string
|
||||
? source.configuration?.connection_info.connection_string
|
||||
: source.configuration?.connection_info?.database_url || '';
|
||||
}
|
||||
sources.push({
|
||||
name: source.name,
|
||||
url,
|
||||
connection_pool_settings: source.configuration?.connection_info
|
||||
?.pool_settings || {
|
||||
retries: 1,
|
||||
idle_timeout: 180,
|
||||
max_connections: 50,
|
||||
},
|
||||
driver: source.kind || 'postgres',
|
||||
read_replicas: source.configuration?.read_replicas ?? undefined,
|
||||
metadata?.sources
|
||||
.filter(s => (s.kind ? drivers.includes(s.kind) : true))
|
||||
.forEach(source => {
|
||||
let url: string | { from_env: string } = '';
|
||||
if (source.kind === 'bigquery') {
|
||||
url = source.configuration?.service_account?.from_env || '';
|
||||
} else {
|
||||
url = source.configuration?.connection_info?.connection_string
|
||||
? source.configuration?.connection_info.connection_string
|
||||
: source.configuration?.connection_info?.database_url || '';
|
||||
}
|
||||
sources.push({
|
||||
name: source.name,
|
||||
url,
|
||||
connection_pool_settings: source.configuration?.connection_info
|
||||
?.pool_settings || {
|
||||
retries: 1,
|
||||
idle_timeout: 180,
|
||||
max_connections: 50,
|
||||
},
|
||||
driver: source.kind || 'postgres',
|
||||
read_replicas: source.configuration?.read_replicas ?? undefined,
|
||||
});
|
||||
});
|
||||
});
|
||||
return sources;
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user