import/export

This commit is contained in:
Jan Prochazka
2020-06-07 18:14:37 +02:00
parent f63788f79b
commit 2f363f6969

View File

@@ -63,25 +63,18 @@ function DatabaseSelector() {
); );
} }
function SourceTargetConfig({ function SourceTargetConfig({ direction, storageTypeField, connectionIdField, databaseNameField, tablesField }) {
isSource = false,
isTarget = false,
storageTypeField,
connectionIdField,
databaseNameField,
tablesField,
}) {
const types = [ const types = [
{ value: 'database', label: 'Database' }, { value: 'database', label: 'Database', directions: ['source'] },
{ value: 'csv', label: 'CSV file(s)' }, { value: 'csv', label: 'CSV file(s)', directions: ['target'] },
{ value: 'json', label: 'JSON file(s)' }, { value: 'json', label: 'JSON file(s)', directions: [] },
]; ];
const { values } = useFormikContext(); const { values } = useFormikContext();
return ( return (
<Column> <Column>
{isSource && <Label>Source configuration</Label>} {direction == 'source' && <Label>Source configuration</Label>}
{isTarget && <Label>Target configuration</Label>} {direction == 'target' && <Label>Target configuration</Label>}
<FormReactSelect options={types} name={storageTypeField} /> <FormReactSelect options={types.filter((x) => x.directions.includes(direction))} name={storageTypeField} />
{values[storageTypeField] == 'database' && ( {values[storageTypeField] == 'database' && (
<> <>
<Label>Server</Label> <Label>Server</Label>
@@ -100,14 +93,14 @@ export default function ImportExportConfigurator() {
return ( return (
<Wrapper> <Wrapper>
<SourceTargetConfig <SourceTargetConfig
isSource direction="source"
storageTypeField="sourceStorageType" storageTypeField="sourceStorageType"
connectionIdField="sourceConnectionId" connectionIdField="sourceConnectionId"
databaseNameField="sourceDatabaseName" databaseNameField="sourceDatabaseName"
tablesField="sourceTables" tablesField="sourceTables"
/> />
<SourceTargetConfig <SourceTargetConfig
isTarget direction="target"
storageTypeField="targetStorageType" storageTypeField="targetStorageType"
connectionIdField="targetConnectionId" connectionIdField="targetConnectionId"
databaseNameField="targetDatabaseName" databaseNameField="targetDatabaseName"