Skip to content

Commit

Permalink
feat(admin-ui): added support for pure java scripts #242
Browse files Browse the repository at this point in the history
  • Loading branch information
syntrydy committed May 31, 2022
1 parent e7ec2f0 commit 0047c2a
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 67 deletions.
67 changes: 34 additions & 33 deletions admin-ui/app/routes/Apps/Gluu/GluuInputEditor.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import React from 'react'
import { Col, FormGroup, Input } from 'Components'
import GluuTooltip from '../Gluu/GluuTooltip'
import { Col, FormGroup } from 'Components'
import GluuLabel from '../Gluu/GluuLabel'
import AceEditor from 'react-ace'
import AceEditor from "react-ace";
//import 'ace-builds/src-noconflict/mode-jython'
//import 'ace-builds/src-noconflict/theme-xcode'
//import 'ace-builds/src-noconflict/ext-language_tools'

function GluuInputEditor({
label,
name,
language,
value,
formik,
required,
Expand All @@ -15,35 +17,34 @@ function GluuInputEditor({
doc_category,
}) {
return (
<GluuTooltip doc_category={doc_category} doc_entry={name}>
<FormGroup row>
<GluuLabel label={label} size={lsize} required={required} />
{formik.errors.script && formik.touched.script ? (
<div style={{ color: 'red' }}>{formik.errors.script}</div>
) : null}
<Col sm={rsize}>
<AceEditor
mode="python"
theme="xcode"
placeholder="Write your custom script here"
fontSize={20}
width='95%'
height='400px'
onChange={() => {}}
name={name}
defaultValue={value}
editorProps={{ $blockScrolling: true }}
setOptions={{
enableBasicAutocompletion: false,
enableLiveAutocompletion: true,
enableSnippets: false,
showLineNumbers: true,
tabSize: 4,
}}
/>
</Col>
</FormGroup>
</GluuTooltip>
<FormGroup row>
<GluuLabel
doc_category={doc_category}
doc_entry={name}
label={name}
size={lsize}
required={required}
/>
{formik.errors.script && formik.touched.script ? (
<div style={{ color: 'red' }}>{formik.errors.script}</div>
) : null}
<Col sm={rsize}>
<AceEditor
mode={language}
theme="xcode"
placeholder="Write your custom script here"
fontSize={20}
width="95%"
height="300px"
onChange={() => {
formik.onChange
}}
name={name}
defaultValue={value}
editorProps={{ $blockScrolling: true }}
/>
</Col>
</FormGroup>
)
}

Expand Down
4 changes: 2 additions & 2 deletions admin-ui/build/webpack.config.client.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module.exports = {
publicPath: BASE_PATH,
},
resolve: {
fallback: { "querystring": false },
fallback: { querystring: false },
modules: ['node_modules', config.srcDir],
alias: {
path: require.resolve('path-browserify'),
Expand Down Expand Up @@ -79,7 +79,7 @@ module.exports = {
},
{
test: /\.css$/i,
use: ["style-loader", "css-loader", "postcss-loader"],
use: ['style-loader', 'css-loader', 'postcss-loader'],
},
{
test: /\.scss$/,
Expand Down
2 changes: 1 addition & 1 deletion admin-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
"@material-ui/icons": "^4.11.2",
"@material-ui/lab": "^4.0.0-alpha.60",
"@miltonbo/dashboard-style-airframe": "^0.2.0",
"ace-builds": "^1.5.2",
"ace-builds": "^1.5.3",
"ag-grid-community": "^21.0.1",
"ag-grid-react": "^21.0.1",
"axios": "^0.24.0",
Expand Down
44 changes: 13 additions & 31 deletions admin-ui/plugins/admin/components/CustomScripts/CustomScriptForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ function CustomScriptForm({ item, scripts, handleSubmit }) {
<option value="">{t('Choose')}...</option>
<option>PYTHON</option>
<option>JAVASCRIPT</option>
<option>JAVA</option>
</CustomInput>
</InputGroup>
{formik.errors.programmingLanguage &&
Expand Down Expand Up @@ -439,7 +440,7 @@ function CustomScriptForm({ item, scripts, handleSubmit }) {
)}
<GluuTooltip doc_category={SCRIPT} doc_entry="level">
<FormGroup row>
<GluuLabel label="fields.level" />
<GluuLabel doc_category={SCRIPT} label="fields.level" />
<Col sm={9}>
<Counter
counter={item.level}
Expand All @@ -457,37 +458,18 @@ function CustomScriptForm({ item, scripts, handleSubmit }) {
valuePlaceholder={t('placeholders.enter_property_value')}
options={getPropertiesConfig(item)}
></GluuProperties>
<GluuInputEditor
name="name"
label="fields.script"
lsize={2}
rsize={10}
formik={formik}
value={item.script}
required
></GluuInputEditor>

{!scriptPath && (
<GluuTooltip doc_category={SCRIPT} doc_entry="script">
<FormGroup row>
<GluuLabel label={t('Script')} size={2} required />
{formik.errors.script && formik.touched.script ? (
<div style={{ color: 'red' }}>{formik.errors.script}</div>
) : null}
<Col sm={10}>
<Input
placeholder={t('Script')}
valid={!formik.errors.script && !formik.touched.script && init}
type="textarea"
rows={20}
id="script"
name="script"
defaultValue={item.script}
onChange={formik.handleChange}
/>
</Col>
</FormGroup>
</GluuTooltip>
<GluuInputEditor
doc_category={SCRIPT}
name="script"
language={item.programmingLanguage.toLowerCase()}
label="script"
lsize={2}
rsize={10}
formik={formik}
value={item.script}
required
></GluuInputEditor>
)}
<GluuTooltip doc_category={SCRIPT} doc_entry="enabled">
<FormGroup row>
Expand Down

0 comments on commit 0047c2a

Please sign in to comment.