Skip to content

Commit 7592ec2

Browse files
committed
Add ES frontend component
1 parent 8ee33b3 commit 7592ec2

File tree

4 files changed

+72
-2
lines changed

4 files changed

+72
-2
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* Copyright 2020 Luis Alberto Pabón Flores
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
import React, { Component } from 'react'
19+
import { Checkbox, Dropdown, } from './controls/index'
20+
import { Form } from 'semantic-ui-react'
21+
22+
import { enumToOptions } from './semanticUiTools'
23+
24+
import { capitalize } from '../util'
25+
26+
class ElasticSearchOptions extends Component {
27+
render () {
28+
const properties = this.props.schema.properties
29+
const schemaNode = 'elasticsearchOptions'
30+
31+
if (properties === undefined) {
32+
return null
33+
}
34+
35+
const esOptions = properties[schemaNode]
36+
37+
const name = esOptions.title
38+
const enableFieldName = 'has' + capitalize(name.toLowerCase())
39+
const dbVersions = enumToOptions(esOptions.properties.version)
40+
41+
return (
42+
<fieldset>
43+
<legend>{name}</legend>
44+
<Form.Group>
45+
<Checkbox
46+
name={schemaNode + '.' + enableFieldName}
47+
label={esOptions.properties[enableFieldName].title}
48+
inputProps={{
49+
toggle: true,
50+
}}
51+
/>
52+
</Form.Group>
53+
54+
<Form.Group widths={'equal'}>
55+
<Dropdown
56+
name={schemaNode + '.version'}
57+
label={esOptions.properties.version.title}
58+
options={dbVersions}
59+
fieldProps={{
60+
required: true
61+
}}
62+
/>
63+
</Form.Group>
64+
</fieldset>
65+
)
66+
}
67+
}
68+
69+
export default ElasticSearchOptions

frontend/src/Generator/Generator.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ import { Formik } from 'formik'
2424
import ProjectOptions from './ProjectOptions'
2525
import ZeroConfigServiceOptions from './ZeroConfigServiceOptions'
2626
import MySQLCompatibleOptions from './MySQLCompatibleOptions'
27+
import ElasticSearchOptions from './ElasticSearchOptions'
2728

2829
import 'semantic-ui-css/semantic.min.css'
2930
import './generator.css'
3031

32+
3133
import { randomRange } from '../util'
3234
import PostgresOptions from './PostgresOptions'
3335

@@ -120,6 +122,7 @@ class Generator extends Component {
120122
<MySQLCompatibleOptions schema={this.state.formSchema} schemaNode={'mysqlOptions'}/>
121123
<MySQLCompatibleOptions schema={this.state.formSchema} schemaNode={'mariadbOptions'}/>
122124
<PostgresOptions schema={this.state.formSchema}/>
125+
<ElasticSearchOptions schema={this.state.formSchema}/>
123126

124127
<Button type="submit" loading={isSubmitting} primary>
125128
Submit

frontend/src/Generator/MySQLCompatibleOptions.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ class MySQLCompatibleOptions extends Component {
3737
const name = dbOptions.title
3838
const enableFieldName = 'has' + capitalize(name.toLowerCase())
3939
const dbVersions = enumToOptions(dbOptions.properties.version)
40-
console.log(dbOptions)
4140

4241
return (
4342
<fieldset>

frontend/src/Generator/PostgresOptions.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ class PostgresOptions extends Component {
3737
const name = dbOptions.title
3838
const enableFieldName = 'has' + capitalize(name.toLowerCase())
3939
const dbVersions = enumToOptions(dbOptions.properties.version)
40-
console.log(dbOptions)
4140

4241
return (
4342
<fieldset>

0 commit comments

Comments
 (0)