Updated text field with popping code editor

This commit is contained in:
gohil-jay
2021-11-13 17:22:31 +05:30
parent 2cce2bffd8
commit de7d079267
4 changed files with 164 additions and 47 deletions
+1 -1
View File
@@ -66,7 +66,7 @@ services:
- CLEANUP=${SHUFFLE_CONTAINER_AUTO_CLEANUP} - CLEANUP=${SHUFFLE_CONTAINER_AUTO_CLEANUP}
restart: unless-stopped restart: unless-stopped
opensearch: opensearch:
image: opensearchproject/opensearch:1.1.0 image: opensearchproject/opensearch:1.0.0
hostname: shuffle-opensearch hostname: shuffle-opensearch
container_name: shuffle-opensearch container_name: shuffle-opensearch
environment: environment:
+38 -15
View File
@@ -58,6 +58,7 @@ const ParsedAction = (props) => {
const classes = useStyles() const classes = useStyles()
const [expansionModalOpen, setExpansionModalOpen] = React.useState(false); const [expansionModalOpen, setExpansionModalOpen] = React.useState(false);
const [fieldCount, setFieldCount] = React.useState(0);
const keywords = ["len(", "lower(", "upper(", "trim(", "split(", "length(", "number(", "parse(", "join("] const keywords = ["len(", "lower(", "upper(", "trim(", "split(", "length(", "number(", "parse(", "join("]
const getParents = (action) => { const getParents = (action) => {
@@ -490,9 +491,12 @@ const ParsedAction = (props) => {
//setUpdate(event.target.value) //setUpdate(event.target.value)
} }
const changeActionParameterCodemirror = (event, count, data) => { const changeActionParameterCodeMirror = (event, count, data) => {
console.log(event) // console.log(event)
if (data.name.startsWith("${") && data.name.endsWith("}")) { // if (data.name.startsWith("${") && data.name.endsWith("}")) {
// console.log(data)
// console.log(count)
if (data.startsWith("${") && data.endsWith("}")) {
// PARAM FIX - Gonna use the ID field, even though it's a hack // PARAM FIX - Gonna use the ID field, even though it's a hack
const paramcheck = selectedAction.parameters.find(param => param.name === "body") const paramcheck = selectedAction.parameters.find(param => param.name === "body")
if (paramcheck !== undefined) { if (paramcheck !== undefined) {
@@ -542,7 +546,7 @@ const ParsedAction = (props) => {
} }
} }
if (event.display.maxLine.text[event.display.maxLine.text.length-1] === "$") { if (event.target.value[event.target.value.length-1] === "$") {
if (!showDropdown) { if (!showDropdown) {
setShowAutocomplete(false) setShowAutocomplete(false)
setShowDropdown(true) setShowDropdown(true)
@@ -555,7 +559,7 @@ const ParsedAction = (props) => {
} }
// bad detection mechanism probably // bad detection mechanism probably
if (event.display.maxLine.text[event.display.maxLine.text.length-1] === "." && actionlist.length > 0) { if (event.target.value[event.target.value.length-1] === "." && actionlist.length > 0) {
console.log("GET THE LAST ARGUMENT FOR NODE!") console.log("GET THE LAST ARGUMENT FOR NODE!")
// THIS IS AN EXAMPLE OF SHOWING IT // THIS IS AN EXAMPLE OF SHOWING IT
/* /*
@@ -627,8 +631,8 @@ const ParsedAction = (props) => {
} }
} }
selectedActionParameters[count].value = event.display.maxLine.text selectedActionParameters[count].value = data
selectedAction.parameters[count].value = event.display.maxLine.text selectedAction.parameters[count].value = data
setSelectedAction(selectedAction) setSelectedAction(selectedAction)
//setUpdate(Math.random()) //setUpdate(Math.random())
//setUpdate(event.target.value) //setUpdate(event.target.value)
@@ -841,7 +845,21 @@ const ParsedAction = (props) => {
const clickedFieldId = "rightside_field_"+count const clickedFieldId = "rightside_field_"+count
//<TextareaAutosize //<TextareaAutosize
// <CodeMirror // <CodeMirror
var datafield =
const shufflecode = <ShuffleCodeEditor
fieldCount = {fieldCount}
setFieldCount = {setFieldCount}
// editorData = {data.value.valueOf()}
changeActionParameterCodeMirror = {changeActionParameterCodeMirror}
codedata={codedata}
setcodedata={setcodedata}
setExpansionModalOpen={setExpansionModalOpen}
expansionModalOpen={expansionModalOpen}
// codelang={codelang}
// setcodelang={setcodelang}
/>
var datafield =
<TextField <TextField
disabled={disabled} disabled={disabled}
style={{backgroundColor: theme.palette.inputColor, borderRadius: theme.palette.borderRadius, border: selectedActionParameters[count].required || selectedActionParameters[count].configuration ? "2px solid #f85a3e" : "", color: "white", width: "100%", fontSize: "1em", }} style={{backgroundColor: theme.palette.inputColor, borderRadius: theme.palette.borderRadius, border: selectedActionParameters[count].required || selectedActionParameters[count].configuration ? "2px solid #f85a3e" : "", color: "white", width: "100%", fontSize: "1em", }}
@@ -858,6 +876,8 @@ const ParsedAction = (props) => {
multiline={multiline} multiline={multiline}
onClick={() => { onClick={() => {
console.log("Clicked field: ", clickedFieldId) console.log("Clicked field: ", clickedFieldId)
setFieldCount(count)
setcodedata(data.value)
setExpansionModalOpen(true) setExpansionModalOpen(true)
if (setScrollConfig !== undefined && scrollConfig !== null && scrollConfig !== undefined && scrollConfig.selected !== clickedFieldId) { if (setScrollConfig !== undefined && scrollConfig !== null && scrollConfig !== undefined && scrollConfig.selected !== clickedFieldId) {
scrollConfig.selected = clickedFieldId scrollConfig.selected = clickedFieldId
@@ -868,17 +888,17 @@ const ParsedAction = (props) => {
id={clickedFieldId} id={clickedFieldId}
rows={rows} rows={rows}
color="primary" color="primary"
value={codedata} // value={codedata}
//defaultValue={data.value} defaultValue={data.value}
//height={multiline ? 50 : 150} // height={multiline ? 50 : 150}
type={placeholder.includes("***") || (data.configuration && (data.name.toLowerCase().includes("api") || data.name.toLowerCase().includes("key") || data.name.toLowerCase().includes("pass"))) ? "password" : "text"} type={placeholder.includes("***") || (data.configuration && (data.name.toLowerCase().includes("api") || data.name.toLowerCase().includes("key") || data.name.toLowerCase().includes("pass"))) ? "password" : "text"}
placeholder={placeholder} placeholder={placeholder}
onChange={(event) => { onChange={(event) => {
changeActionParameter(event, count, data) // changeActionParameter(event, count, data)
}} }}
helperText={selectedApp.generated && selectedApp.activated && data.name === "body" ? helperText={selectedApp.generated && selectedApp.activated && data.name === "body" ?
<span style={{color:"white", marginBottom: 5, marginleft: 5,}}> <span style={{color:"white", marginBottom: 5, marginleft: 5,}}>
{openApiHelperText} {openApiHelperText}
@@ -1335,6 +1355,7 @@ const ParsedAction = (props) => {
*/} */}
</div> </div>
{datafield} {datafield}
{shufflecode}
{showDropdown && showDropdownNumber === count && data.variant === "STATIC_VALUE" && jsonList.length > 0 ? {showDropdown && showDropdownNumber === count && data.variant === "STATIC_VALUE" && jsonList.length > 0 ?
<FormControl fullWidth style={{marginTop: 0}}> <FormControl fullWidth style={{marginTop: 0}}>
<InputLabel id="action-autocompleter" style={{marginLeft: 10, color: "white"}}>Autocomplete</InputLabel> <InputLabel id="action-autocompleter" style={{marginLeft: 10, color: "white"}}>Autocomplete</InputLabel>
@@ -1411,14 +1432,16 @@ const ParsedAction = (props) => {
const baselabel = selectedAction.label const baselabel = selectedAction.label
return ( return (
<div style={appApiViewStyle} id="parsed_action_view"> <div style={appApiViewStyle} id="parsed_action_view">
{<ShuffleCodeEditor {/* {<ShuffleCodeEditor
count = {count}
changeActionParameter = {changeActionParameter}
codedata={codedata} codedata={codedata}
setcodedata={setcodedata} setcodedata={setcodedata}
setExpansionModalOpen={setExpansionModalOpen} setExpansionModalOpen={setExpansionModalOpen}
expansionModalOpen={expansionModalOpen} expansionModalOpen={expansionModalOpen}
// codelang={codelang} // codelang={codelang}
// setcodelang={setcodelang} // setcodelang={setcodelang}
/>} />} */}
{hideExtraTypes === true ? null : {hideExtraTypes === true ? null :
<span> <span>
<div style={{display: "flex", minHeight: 40, marginBottom: 30}}> <div style={{display: "flex", minHeight: 40, marginBottom: 30}}>
+101 -31
View File
@@ -7,10 +7,12 @@ import 'codemirror/keymap/sublime';
import 'codemirror/theme/gruvbox-dark.css'; import 'codemirror/theme/gruvbox-dark.css';
const Textfield = (props) => { const Textfield = (props) => {
const {fieldCount, setFieldCount} = props
// const {editorData} = props
const {changeActionParameterCodeMirror} = props
const {expansionModalOpen, setExpansionModalOpen} = props const {expansionModalOpen, setExpansionModalOpen} = props
const {codedata, setcodedata} = props const {codedata, setcodedata} = props
const [localcodedata, setlocalcodedata] = React.useState("print('Hello')"); const [localcodedata, setlocalcodedata] = React.useState(codedata === undefined || codedata === null || codedata.length === 0 ? "" : codedata);
// const {codelang, setcodelang} = props // const {codelang, setcodelang} = props
const theme = useTheme(); const theme = useTheme();
@@ -32,30 +34,64 @@ const Textfield = (props) => {
<div <div
style={{ style={{
display: 'flex', display: 'flex',
justifyContent: 'right',
}} }}
> >
<button <DialogTitle
style={{ style={{
color: "white", paddingBottom:20,
background: "#27292d",
border: "2px solid white",
borderRadius: '50%',
fontSize: 15,
width: 40,
height: 40,
cursor: "pointer"
}}
onClick={() => {
setExpansionModalOpen(false)
}} }}
> >
<span
</button> style={{
color: "white"
}}
>
Code Editor
</span>
<span
style={{
backgroundColor: "#f85a3e",
padding: 6,
paddingBottom: 6,
marginLeft: 20,
marginBottom: 50,
borderRadius: 10,
color: "white",
fontSize: "75%"
}}
>
Python
</span>
</DialogTitle>
<div
style={{
width: 60,
marginLeft: 320,
display: 'flex',
justifyContent: 'right',
}}
>
<button
style={{
color: "white",
background: "#27292d",
border: "2px solid white",
borderRadius: '50%',
fontSize: 15,
width: 40,
height: 40,
cursor: "pointer"
}}
onClick={() => {
setExpansionModalOpen(false)
}}
>
</button>
</div>
</div> </div>
<DialogTitle><span style={{color: "white"}}>Code Editor</span></DialogTitle>
<CodeMirror <CodeMirror
value = {codedata} value = {localcodedata}
height="200px" height="200px"
onChange={(value) => { onChange={(value) => {
// setcodedata(value.getValue()) // setcodedata(value.getValue())
@@ -68,21 +104,55 @@ const Textfield = (props) => {
// mode: {codelang}, // mode: {codelang},
}} }}
/> />
<button <div
style={{ style={{
color: "white", display: 'flex',
background: "#f85a3e", // justifyContent: 'left',
border: "none",
height: 35,
cursor: "pointer"
}}
onClick={() => {
setcodedata(localcodedata)
setExpansionModalOpen(false)
}} }}
> >
DONE <div>
</button> <button
style={{
color: "white",
background: "#383b49",
border: "none",
height: 35,
width: 290,
marginLeft: 5,
marginTop: 20,
cursor: "pointer"
}}
onClick={() => {
setExpansionModalOpen(false)
}}
>
CANCEL
</button>
</div>
<div>
<button
style={{
color: "white",
background: "#f85a3e",
border: "none",
height: 35,
width: 290,
marginLeft: 10,
marginTop: 20,
cursor: "pointer"
}}
onClick={(event) => {
console.log(codedata)
console.log(fieldCount)
changeActionParameterCodeMirror(event, fieldCount, localcodedata)
setExpansionModalOpen(false)
setcodedata(localcodedata)
}}
>
DONE
</button>
</div>
</div>
</Dialog>) </Dialog>)
} }
+24
View File
@@ -1,6 +1,7 @@
import React, {useRef, useState, useEffect, useLayoutEffect} from 'react'; import React, {useRef, useState, useEffect, useLayoutEffect} from 'react';
import { useInterval } from 'react-powerhooks'; import { useInterval } from 'react-powerhooks';
import { useTheme } from '@material-ui/core/styles'; import { useTheme } from '@material-ui/core/styles';
import ShuffleCodeEditor from "../components/ShuffleCodeEditor.jsx";
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
import {Link} from 'react-router-dom'; import {Link} from 'react-router-dom';
@@ -169,6 +170,9 @@ const AngularWorkflow = (props) => {
selected: "", selected: "",
}) })
const [codedata, setcodedata] = React.useState("print('Hello')");
const [expansionModalOpen, setExpansionModalOpen] = React.useState(false);
const [history, setHistory] = React.useState([]) const [history, setHistory] = React.useState([])
const [historyIndex, setHistoryIndex] = React.useState(history.length) const [historyIndex, setHistoryIndex] = React.useState(history.length)
@@ -7828,6 +7832,12 @@ const AngularWorkflow = (props) => {
globalUrl={globalUrl} globalUrl={globalUrl}
setSelectedActionEnvironment={setSelectedActionEnvironment} setSelectedActionEnvironment={setSelectedActionEnvironment}
requiresAuthentication={requiresAuthentication} requiresAuthentication={requiresAuthentication}
// onClick={() => {
// // console.log("Clicked field: ", clickedFieldId)
// setExpansionModalOpen(true)
// }
// }
/> />
</div> </div>
) )
@@ -9439,6 +9449,20 @@ const AngularWorkflow = (props) => {
</ScrollElement> </ScrollElement>
</div> </div>
) )
// const baselabel = selectedAction.label
// return (
// <div style={appApiViewStyle} id="parsed_action_view">
// {<ShuffleCodeEditor
// codedata={codedata}
// setcodedata={setcodedata}
// setExpansionModalOpen={setExpansionModalOpen}
// expansionModalOpen={expansionModalOpen}
// // codelang={codelang}
// // setcodelang={setcodelang}
// />}
// </div>
// )
} }
export default AngularWorkflow export default AngularWorkflow