mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 09:22:43 +03:00
console: fix missing props in ConnectPostgresWidget
's read replicas field
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8147 GitOrigin-RevId: 12aedbb5a7960ccdf26205eb49e0ba48d0c0d4f9
This commit is contained in:
parent
1e0fa95493
commit
0d49cf02f3
@ -34,12 +34,14 @@ export const DatabaseUrl = ({
|
|||||||
{connectionType === 'databaseUrl' ? (
|
{connectionType === 'databaseUrl' ? (
|
||||||
<InputField
|
<InputField
|
||||||
name={`${name}.url`}
|
name={`${name}.url`}
|
||||||
|
key={`${name}.url`}
|
||||||
label="Database URL"
|
label="Database URL"
|
||||||
placeholder="postgresql://username:password@hostname:port/postgres"
|
placeholder="postgresql://username:password@hostname:port/postgres"
|
||||||
/>
|
/>
|
||||||
) : connectionType === 'envVar' ? (
|
) : connectionType === 'envVar' ? (
|
||||||
<InputField
|
<InputField
|
||||||
name={`${name}.envVar`}
|
name={`${name}.envVar`}
|
||||||
|
key={`${name}.envVar`}
|
||||||
label="Environment variable"
|
label="Environment variable"
|
||||||
placeholder="HASURA_GRAPHQL_DB_URL_FROM_ENV"
|
placeholder="HASURA_GRAPHQL_DB_URL_FROM_ENV"
|
||||||
/>
|
/>
|
||||||
|
@ -3,7 +3,7 @@ import { InputField } from '../../../../../new-components/Form';
|
|||||||
export const ExtensionSchema = ({ name }: { name: string }) => {
|
export const ExtensionSchema = ({ name }: { name: string }) => {
|
||||||
return (
|
return (
|
||||||
<InputField
|
<InputField
|
||||||
name={`${name}.extensionSchema`}
|
name={name}
|
||||||
label="Extension Schema"
|
label="Extension Schema"
|
||||||
placeholder="public"
|
placeholder="public"
|
||||||
tooltip="Name of the schema where the graphql-engine will install database extensions (default: `public`). Specified schema should be present in the search path of the database."
|
tooltip="Name of the schema where the graphql-engine will install database extensions (default: `public`). Specified schema should be present in the search path of the database."
|
||||||
|
@ -17,7 +17,7 @@ export const IsolationLevel = ({ name }: { name: string }) => {
|
|||||||
label: 'serializable',
|
label: 'serializable',
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
name={`${name}.isolationLevel`}
|
name={name}
|
||||||
label="Isolation Level"
|
label="Isolation Level"
|
||||||
tooltip="The transaction isolation level in which the queries made to the source will be run"
|
tooltip="The transaction isolation level in which the queries made to the source will be run"
|
||||||
/>
|
/>
|
||||||
|
@ -4,6 +4,7 @@ import { ComponentStory, ComponentMeta } from '@storybook/react';
|
|||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
|
|
||||||
import { ReadReplicas } from './ReadReplicas';
|
import { ReadReplicas } from './ReadReplicas';
|
||||||
|
import { connectionInfoSchema } from '../schema';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
component: ReadReplicas,
|
component: ReadReplicas,
|
||||||
@ -12,10 +13,12 @@ export default {
|
|||||||
export const Primary: ComponentStory<typeof ReadReplicas> = () => (
|
export const Primary: ComponentStory<typeof ReadReplicas> = () => (
|
||||||
<SimpleForm
|
<SimpleForm
|
||||||
onSubmit={data => console.log(data)}
|
onSubmit={data => console.log(data)}
|
||||||
schema={z.any()}
|
schema={z.object({
|
||||||
|
readReplicas: z.array(connectionInfoSchema),
|
||||||
|
})}
|
||||||
options={{}}
|
options={{}}
|
||||||
>
|
>
|
||||||
<ReadReplicas name="rr" hideOptions={[]} />
|
<ReadReplicas name="readReplicas" hideOptions={[]} />
|
||||||
<br />
|
<br />
|
||||||
<Button type="submit" className="my-2">
|
<Button type="submit" className="my-2">
|
||||||
Submit
|
Submit
|
||||||
|
@ -3,7 +3,7 @@ import { Button } from '../../../../../new-components/Button';
|
|||||||
import { CardedTable } from '../../../../../new-components/CardedTable';
|
import { CardedTable } from '../../../../../new-components/CardedTable';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { ConnectionInfoSchema } from '../schema';
|
import { ConnectionInfoSchema } from '../schema';
|
||||||
import { FaPlus, FaTrash } from 'react-icons/fa';
|
import { FaEdit, FaPlus, FaTrash } from 'react-icons/fa';
|
||||||
import { IndicatorCard } from '../../../../../new-components/IndicatorCard';
|
import { IndicatorCard } from '../../../../../new-components/IndicatorCard';
|
||||||
import {
|
import {
|
||||||
areSSLSettingsEnabled,
|
areSSLSettingsEnabled,
|
||||||
@ -32,9 +32,11 @@ export const ReadReplicas = ({
|
|||||||
const { watch, setValue } =
|
const { watch, setValue } =
|
||||||
useFormContext<Record<string, ConnectionInfoSchema[]>>();
|
useFormContext<Record<string, ConnectionInfoSchema[]>>();
|
||||||
|
|
||||||
const [mode, setMode] = useState<'idle' | 'add'>('idle');
|
const [mode, setMode] = useState<'idle' | 'add' | 'edit'>('idle');
|
||||||
const readReplicas = watch(name);
|
const readReplicas = watch(name);
|
||||||
|
|
||||||
|
const [activeRow, setActiveRow] = useState<number>();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="my-2">
|
<div className="my-2">
|
||||||
{!fields?.length ? (
|
{!fields?.length ? (
|
||||||
@ -42,20 +44,29 @@ export const ReadReplicas = ({
|
|||||||
) : (
|
) : (
|
||||||
<CardedTable
|
<CardedTable
|
||||||
columns={['No', 'Read Replica', null]}
|
columns={['No', 'Read Replica', null]}
|
||||||
data={(fields ?? []).map((field, i) => [
|
data={(readReplicas ?? []).map((field, i) => [
|
||||||
i + 1,
|
i + 1,
|
||||||
<div>{getDatabaseConnectionDisplayName(field.databaseUrl)}</div>,
|
<div>{getDatabaseConnectionDisplayName(field.databaseUrl)}</div>,
|
||||||
|
<div className="flex gap-3 justify-end">
|
||||||
|
<Button
|
||||||
|
size="sm"
|
||||||
|
icon={<FaEdit />}
|
||||||
|
onClick={() => {
|
||||||
|
setActiveRow(i);
|
||||||
|
setMode('edit');
|
||||||
|
}}
|
||||||
|
/>
|
||||||
<Button
|
<Button
|
||||||
size="sm"
|
size="sm"
|
||||||
icon={<FaTrash />}
|
icon={<FaTrash />}
|
||||||
mode="destructive"
|
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setValue(
|
setValue(
|
||||||
name,
|
name,
|
||||||
readReplicas.filter((_, index) => index !== i)
|
readReplicas.filter((_, index) => index !== i)
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
/>,
|
/>
|
||||||
|
</div>,
|
||||||
])}
|
])}
|
||||||
showActionCell
|
showActionCell
|
||||||
/>
|
/>
|
||||||
@ -69,6 +80,7 @@ export const ReadReplicas = ({
|
|||||||
append({
|
append({
|
||||||
databaseUrl: { connectionType: 'databaseUrl', url: '' },
|
databaseUrl: { connectionType: 'databaseUrl', url: '' },
|
||||||
});
|
});
|
||||||
|
setActiveRow(readReplicas?.length ?? 0);
|
||||||
}}
|
}}
|
||||||
mode="primary"
|
mode="primary"
|
||||||
icon={<FaPlus />}
|
icon={<FaPlus />}
|
||||||
@ -77,10 +89,10 @@ export const ReadReplicas = ({
|
|||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{mode === 'add' && (
|
{(mode === 'add' || mode === 'edit') && (
|
||||||
<Dialog
|
<Dialog
|
||||||
hasBackdrop
|
hasBackdrop
|
||||||
title="Add Read Replica"
|
title={mode === 'edit' ? 'Edit Read Replica' : 'Add Read Replica'}
|
||||||
onClose={() => {
|
onClose={() => {
|
||||||
setMode('idle');
|
setMode('idle');
|
||||||
}}
|
}}
|
||||||
@ -90,7 +102,7 @@ export const ReadReplicas = ({
|
|||||||
<div className="p-4">
|
<div className="p-4">
|
||||||
<div className="bg-white border border-hasGray-300 rounded-md shadow-sm overflow-hidden p-4">
|
<div className="bg-white border border-hasGray-300 rounded-md shadow-sm overflow-hidden p-4">
|
||||||
<DatabaseUrl
|
<DatabaseUrl
|
||||||
name={`${name}.${fields?.length - 1}.databaseUrl`}
|
name={`${name}.${activeRow}.databaseUrl`}
|
||||||
hideOptions={hideOptions}
|
hideOptions={hideOptions}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -103,14 +115,10 @@ export const ReadReplicas = ({
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<PoolSettings
|
<PoolSettings name={`${name}.${activeRow}.poolSettings`} />
|
||||||
name={`${name}.${fields?.length - 1}.poolSettings`}
|
<IsolationLevel name={`${name}.${activeRow}.isolationLevel`} />
|
||||||
/>
|
|
||||||
<IsolationLevel
|
|
||||||
name={`${name}.${fields?.length - 1}.isolationLevel`}
|
|
||||||
/>
|
|
||||||
<UsePreparedStatements
|
<UsePreparedStatements
|
||||||
name={`${name}.${fields?.length - 1}.usePreparedStatements`}
|
name={`${name}.${activeRow}.usePreparedStatements`}
|
||||||
/>
|
/>
|
||||||
{areSSLSettingsEnabled() && (
|
{areSSLSettingsEnabled() && (
|
||||||
<Collapsible
|
<Collapsible
|
||||||
@ -127,9 +135,7 @@ export const ReadReplicas = ({
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<SslSettings
|
<SslSettings name={`${name}.${activeRow}.sslSettings`} />
|
||||||
name={`${name}.${fields?.length - 1}.sslSettings`}
|
|
||||||
/>
|
|
||||||
</Collapsible>
|
</Collapsible>
|
||||||
)}
|
)}
|
||||||
</Collapsible>
|
</Collapsible>
|
||||||
@ -137,15 +143,12 @@ export const ReadReplicas = ({
|
|||||||
<Button
|
<Button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setMode('idle');
|
setMode('idle');
|
||||||
setValue(
|
setActiveRow(undefined);
|
||||||
`${name}.${fields?.length - 1}`,
|
|
||||||
fields[fields?.length - 1]
|
|
||||||
);
|
|
||||||
}}
|
}}
|
||||||
mode="primary"
|
mode="primary"
|
||||||
className="my-2"
|
className="my-2"
|
||||||
>
|
>
|
||||||
Add Read Replica
|
{mode === 'edit' ? 'Edit Read Replica' : 'Add Read Replica'}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
@ -3,7 +3,7 @@ import { BooleanInput } from './BooleanInput';
|
|||||||
export const UsePreparedStatements = ({ name }: { name: string }) => {
|
export const UsePreparedStatements = ({ name }: { name: string }) => {
|
||||||
return (
|
return (
|
||||||
<BooleanInput
|
<BooleanInput
|
||||||
name={`${name}.usePreparedStatements`}
|
name={name}
|
||||||
label="Use Prepared Statements"
|
label="Use Prepared Statements"
|
||||||
tooltip="Prepared statements are disabled by default"
|
tooltip="Prepared statements are disabled by default"
|
||||||
/>
|
/>
|
||||||
|
@ -1,4 +1,9 @@
|
|||||||
export * from './source';
|
export * from './source';
|
||||||
export * from './table';
|
export * from './table';
|
||||||
export * from './relationships';
|
export * from './relationships';
|
||||||
export type { PostgresConfiguration } from './configuration';
|
export {
|
||||||
|
PostgresConfiguration,
|
||||||
|
MssqlConfiguration,
|
||||||
|
BigQueryConfiguration,
|
||||||
|
CitusConfiguration,
|
||||||
|
} from './configuration';
|
||||||
|
Loading…
Reference in New Issue
Block a user