mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-11-13 09:17:21 +03:00
console: fix adding database with url from env (close #457)
GitOrigin-RevId: 0a732a20556feb4d810fc20ba623a6818c2cf45d
This commit is contained in:
parent
c14dcd5792
commit
1bca160d8e
@ -6,30 +6,6 @@ import DropdownButton from '../../../Common/DropdownButton/DropdownButton';
|
|||||||
import CollapsibleToggle from '../../../Common/CollapsibleToggle/CollapsibleToggle';
|
import CollapsibleToggle from '../../../Common/CollapsibleToggle/CollapsibleToggle';
|
||||||
import { DataSource } from '../../../../metadata/types';
|
import { DataSource } from '../../../../metadata/types';
|
||||||
|
|
||||||
// const customSelectBoxStyles = {
|
|
||||||
// control: {
|
|
||||||
// height: '34px',
|
|
||||||
// minHeight: '34px !important',
|
|
||||||
// },
|
|
||||||
// container: {
|
|
||||||
// width: '156px',
|
|
||||||
// height: '34px',
|
|
||||||
// minHeight: '34px !important',
|
|
||||||
// },
|
|
||||||
// dropdownIndicator: {
|
|
||||||
// padding: '5px',
|
|
||||||
// },
|
|
||||||
// placeholder: {
|
|
||||||
// top: '50%',
|
|
||||||
// fontSize: '12px',
|
|
||||||
// },
|
|
||||||
// singleValue: {
|
|
||||||
// fontSize: '12px',
|
|
||||||
// top: '44%',
|
|
||||||
// color: '#555555',
|
|
||||||
// },
|
|
||||||
// };
|
|
||||||
|
|
||||||
type AddDataSourceProps = {
|
type AddDataSourceProps = {
|
||||||
onSubmit(data: DataSource, successCallback: () => void): void;
|
onSubmit(data: DataSource, successCallback: () => void): void;
|
||||||
};
|
};
|
||||||
@ -49,9 +25,11 @@ const AddDataSource = ({ onSubmit }: AddDataSourceProps) => {
|
|||||||
{
|
{
|
||||||
name: databaseName.trim(),
|
name: databaseName.trim(),
|
||||||
driver: 'postgres',
|
driver: 'postgres',
|
||||||
fromEnv: urlType === 'from-env',
|
|
||||||
connection_pool_settings: retryConf,
|
connection_pool_settings: retryConf,
|
||||||
url: databaseUrl.trim(),
|
url:
|
||||||
|
urlType === 'from-env'
|
||||||
|
? { from_env: databaseUrl.trim() }
|
||||||
|
: databaseUrl.trim(),
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
setDatabaseUrl('');
|
setDatabaseUrl('');
|
||||||
@ -66,19 +44,6 @@ const AddDataSource = ({ onSubmit }: AddDataSourceProps) => {
|
|||||||
const expandedContent = () => (
|
const expandedContent = () => (
|
||||||
<div style={{ width: '100%' }}>
|
<div style={{ width: '100%' }}>
|
||||||
<form className={`form-inline ${styles.display_flex}`}>
|
<form className={`form-inline ${styles.display_flex}`}>
|
||||||
{/* <span className={styles.add_mar_right_mid}>
|
|
||||||
<SearchableSelect
|
|
||||||
options={drivers}
|
|
||||||
onChange={(opt: any) =>
|
|
||||||
setDatabaseType(typeof opt === 'string' ? opt : opt.value)
|
|
||||||
}
|
|
||||||
value={databaseType || ''}
|
|
||||||
bsClass="modify_select"
|
|
||||||
styleOverrides={customSelectBoxStyles}
|
|
||||||
filterOption="prefix"
|
|
||||||
placeholder="database type"
|
|
||||||
/>
|
|
||||||
</span> */}
|
|
||||||
<input
|
<input
|
||||||
placeholder="database name"
|
placeholder="database name"
|
||||||
type="text"
|
type="text"
|
||||||
|
@ -162,7 +162,7 @@ const ManageDatabase: React.FC<ManageDatabaseProps> = ({
|
|||||||
retries: data.connection_pool_settings.retries,
|
retries: data.connection_pool_settings.retries,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
dbUrl: typeof data.url === 'string' ? data.url : data.url.from_env,
|
dbUrl: data.url,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
successCallback
|
successCallback
|
||||||
|
@ -97,7 +97,7 @@ export interface AddDataSourceRequest {
|
|||||||
driver: Driver;
|
driver: Driver;
|
||||||
payload: {
|
payload: {
|
||||||
name: string;
|
name: string;
|
||||||
dbUrl: string;
|
dbUrl: string | { from_env: string };
|
||||||
connection_pool_settings: {
|
connection_pool_settings: {
|
||||||
max_connections?: number;
|
max_connections?: number;
|
||||||
idle_timeout?: number; // in seconds
|
idle_timeout?: number; // in seconds
|
||||||
|
@ -338,10 +338,7 @@ export const getDataSources = createSelector(getMetadata, metadata => {
|
|||||||
metadata?.sources.forEach(source => {
|
metadata?.sources.forEach(source => {
|
||||||
sources.push({
|
sources.push({
|
||||||
name: source.name,
|
name: source.name,
|
||||||
url:
|
url: source.configuration?.connection_info?.database_url || '',
|
||||||
source.configuration?.connection_info?.database_url ||
|
|
||||||
'HASURA_GRAPHQL_DATABASE_URL',
|
|
||||||
fromEnv: false,
|
|
||||||
connection_pool_settings: source.configuration?.connection_info
|
connection_pool_settings: source.configuration?.connection_info
|
||||||
?.pool_settings || {
|
?.pool_settings || {
|
||||||
retries: 1,
|
retries: 1,
|
||||||
|
@ -4,7 +4,7 @@ export const addSource = (
|
|||||||
driver: Driver,
|
driver: Driver,
|
||||||
payload: {
|
payload: {
|
||||||
name: string;
|
name: string;
|
||||||
dbUrl: string;
|
dbUrl: string | { from_env: string };
|
||||||
connection_pool_settings?: {
|
connection_pool_settings?: {
|
||||||
max_connections?: number;
|
max_connections?: number;
|
||||||
idle_timeout?: number;
|
idle_timeout?: number;
|
||||||
|
@ -4,7 +4,6 @@ import { PermissionsType } from '../components/Services/RemoteSchema/Permissions
|
|||||||
export type DataSource = {
|
export type DataSource = {
|
||||||
name: string;
|
name: string;
|
||||||
url: string | { from_env: string };
|
url: string | { from_env: string };
|
||||||
fromEnv: boolean;
|
|
||||||
driver: Driver;
|
driver: Driver;
|
||||||
connection_pool_settings?: {
|
connection_pool_settings?: {
|
||||||
max_connections?: number;
|
max_connections?: number;
|
||||||
@ -856,7 +855,7 @@ export interface MetadataDataSource {
|
|||||||
kind?: 'postgres' | 'mysql';
|
kind?: 'postgres' | 'mysql';
|
||||||
configuration?: {
|
configuration?: {
|
||||||
connection_info?: {
|
connection_info?: {
|
||||||
database_url?: string;
|
database_url: string | { from_env: string };
|
||||||
pool_settings?: {
|
pool_settings?: {
|
||||||
max_connections: number;
|
max_connections: number;
|
||||||
idle_timeout: number;
|
idle_timeout: number;
|
||||||
|
Loading…
Reference in New Issue
Block a user