Merge branch 'master' into master

This commit is contained in:
ArpitPandey29 2023-11-01 13:14:52 +05:30 committed by GitHub
commit c54096930d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 3 deletions

View File

@ -13,8 +13,10 @@ import { hasuraToast } from '../../../../new-components/Toasts';
import { useAvailableDrivers } from '../../../ConnectDB/hooks';
import { OpenApi3Form } from '../../../OpenApi3Form';
import { useMetadata } from '../../../hasura-metadata-api';
import { Source } from '../../../hasura-metadata-types';
import { useManageDatabaseConnection } from '../../hooks/useManageDatabaseConnection';
import { DisplayToastErrorMessage } from '../Common/DisplayToastErrorMessage';
import { cleanEmpty } from '../ConnectPostgresWidget/utils/helpers';
import { GraphQLCustomization } from '../GraphQLCustomization/GraphQLCustomization';
import { adaptGraphQLCustomization } from '../GraphQLCustomization/utils/adaptResponse';
import { Template } from './components/Template';
@ -25,8 +27,6 @@ import {
useFormValidationSchema,
} from './useFormValidationSchema';
import { generateGDCRequestPayload } from './utils/generateRequest';
import { Source } from '../../../hasura-metadata-types';
import { cleanEmpty } from '../ConnectPostgresWidget/utils/helpers';
interface ConnectGDCSourceWidgetProps {
driver: string;
@ -129,6 +129,11 @@ export const ConnectGDCSourceWidget = (props: ConnectGDCSourceWidgetProps) => {
methods: { formState, reset },
} = useConsoleForm({
schema,
options: {
defaultValues: {
template_variables: [],
},
},
});
useEffect(() => {

View File

@ -108,7 +108,7 @@ export const TemplateVariables = () => {
),
}),
],
[]
[remove]
);
const table = useReactTable({

View File

@ -26,6 +26,10 @@ const createValidationSchema = (configSchemas: GDCConfigSchemas) =>
.gte(0, { message: 'Timeout must be a postive number' })
.optional(),
template: z.string().optional(),
// template variables is not marked as optional b/c it makes some pretty annoying TS issues with react-hook-form
// the field is initialized with a default value of `[]`
// with clean up empty fields, including arrays before submission, so it won't be sent to the server if the array is empty
template_variables: z
.object({
name: reqString('variable name'),