Added possibility of hiding/showing body for full control in in HTTP requests
This commit is contained in:
@@ -49,6 +49,7 @@ const useStyles = makeStyles({
|
||||
// },
|
||||
//)
|
||||
|
||||
const openApiFieldDesc = "Generated by OpenAPI body example"
|
||||
const ParsedAction = (props) => {
|
||||
const {workflow, setWorkflow, setAction, setSelectedAction, setUpdate, appActionArguments, selectedApp, workflowExecutions, setSelectedResult, selectedAction, setSelectedApp, setSelectedTrigger, setSelectedEdge, setCurrentView, cy, setAuthenticationModalOpen,setVariablesModalOpen, setCodeModalOpen, selectedNameChange, rightsidebarStyle, showEnvironment, selectedActionEnvironment, environments, setNewSelectedAction, appApiViewStyle, globalUrl, setSelectedActionEnvironment, requiresAuthentication, hideExtraTypes, scrollConfig, setScrollConfig, authenticationType, appAuthentication, getAppAuthentication } = props
|
||||
|
||||
@@ -56,6 +57,8 @@ const ParsedAction = (props) => {
|
||||
const classes = useStyles()
|
||||
|
||||
const [expansionModalOpen, setExpansionModalOpen] = React.useState(false);
|
||||
const [hideBody, setHideBody] = React.useState(false)
|
||||
const [activateHidingBody, setActivateHidingBody] = React.useState(false)
|
||||
|
||||
const keywords = ["len(", "lower(", "upper(", "trim(", "split(", "length(", "number(", "parse(", "join("]
|
||||
const getParents = (action) => {
|
||||
@@ -258,7 +261,8 @@ const ParsedAction = (props) => {
|
||||
|
||||
if (actionlist.length === 0) {
|
||||
// FIXME: Have previous execution values in here
|
||||
actionlist.push({"type": "Execution Argument", "name": "Execution Argument", "value": "$exec", "highlight": "exec", "autocomplete": "exec", "example": "hello"})
|
||||
actionlist.push({"type": "Execution Argument", "name": "Execution Argument", "value": "$exec", "highlight": "exec", "autocomplete": "exec", "example": ""})
|
||||
actionlist.push({"type": "Shuffle DB", "name": "Shuffle DB", "value": "$shuffle_cache", "highlight": "shuffle", "autocomplete": "shuffle", "example": ""})
|
||||
if (workflow.workflow_variables !== null && workflow.workflow_variables !== undefined && workflow.workflow_variables.length > 0) {
|
||||
for (var key in workflow.workflow_variables) {
|
||||
const item = workflow.workflow_variables[key]
|
||||
@@ -788,12 +792,52 @@ const ParsedAction = (props) => {
|
||||
//setSelectedActionParameters(selectedActionParameters)
|
||||
}
|
||||
|
||||
var hideBodyButton = ""
|
||||
const hideBodyButtonValue =
|
||||
<div style={{marginTop: 25, border:"1px solid rgba(255,255,255,0.7)",borderTop: "1px solid rgba(255,255,255,0.7)", borderRadius: theme.palette.borderRadius, alignItems: "center", textAlign: "center",}}>
|
||||
<Tooltip color="secondary" title={"Automatically change body"} placement="top">
|
||||
<FormControlLabel
|
||||
control={
|
||||
<Checkbox
|
||||
tabIndex="-1"
|
||||
checked={hideBody}
|
||||
style={{
|
||||
color: theme.palette.primary.secondary,
|
||||
}}
|
||||
onChange={(event) => {
|
||||
setHideBody(!hideBody)
|
||||
|
||||
for (var key in selectedActionParameters) {
|
||||
var currentItem = selectedActionParameters[key]
|
||||
|
||||
if (currentItem.description === openApiFieldDesc) {
|
||||
currentItem.field_active = !hideBody
|
||||
console.log("Changing", currentItem)
|
||||
}
|
||||
}
|
||||
}}
|
||||
name="requires_unique"
|
||||
/>
|
||||
}
|
||||
label={"Automatically fix body"}
|
||||
/>
|
||||
</Tooltip>
|
||||
</div>
|
||||
|
||||
if (selectedApp.generated && data.name === "body") {
|
||||
const regex = /\${(\w+)}/g
|
||||
const found = placeholder.match(regex)
|
||||
if (found === null) {
|
||||
|
||||
hideBodyButton = hideBodyButtonValue
|
||||
if (found === null || !hideBody) {
|
||||
//setExtraBodyFields([])
|
||||
//
|
||||
if (found === null) {
|
||||
setActivateHidingBody(true)
|
||||
}
|
||||
} else {
|
||||
console.log("SHOW BUTTON")
|
||||
|
||||
rows = "1"
|
||||
disabled = true
|
||||
openApiHelperText = "OpenAPI spec: fill the following fields."
|
||||
@@ -818,7 +862,7 @@ const ParsedAction = (props) => {
|
||||
selectedActionParameters.push({
|
||||
action_field: "",
|
||||
configuration: false,
|
||||
description: "Generated by OpenAPI body example",
|
||||
description: openApiFieldDesc,
|
||||
example: "",
|
||||
id: "",
|
||||
multiline: false,
|
||||
@@ -830,6 +874,7 @@ const ParsedAction = (props) => {
|
||||
tags: null,
|
||||
value: "",
|
||||
variant: "STATIC_VALUE",
|
||||
field_active: true,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -837,10 +882,14 @@ const ParsedAction = (props) => {
|
||||
setSelectedActionParameters(selectedActionParameters)
|
||||
}
|
||||
|
||||
return <Divider key={Math.random()} />
|
||||
return hideBodyButton
|
||||
}
|
||||
}
|
||||
|
||||
if (activateHidingBody === true) {
|
||||
hideBodyButton = ""
|
||||
}
|
||||
|
||||
const clickedFieldId = "rightside_field_"+count
|
||||
//<TextareaAutosize
|
||||
// <CodeMirror
|
||||
@@ -1000,7 +1049,8 @@ const ParsedAction = (props) => {
|
||||
}
|
||||
*/
|
||||
} else if (selectedActionParameters[count].options !== undefined && selectedActionParameters[count].options !== null && selectedActionParameters[count].options.length > 0) {
|
||||
if (selectedActionParameters[count].value === "" && selectedActionParameters[count].required) {
|
||||
if (selectedActionParameters[count].value === "") {
|
||||
// && selectedActionParameters[count].required) {
|
||||
// Rofl, dirty workaround :)
|
||||
const e = {
|
||||
target: {
|
||||
@@ -1009,7 +1059,7 @@ const ParsedAction = (props) => {
|
||||
}
|
||||
|
||||
changeActionParameter(e, count, data)
|
||||
}
|
||||
}
|
||||
|
||||
datafield =
|
||||
<Select
|
||||
@@ -1046,6 +1096,10 @@ const ParsedAction = (props) => {
|
||||
staticcolor = "#f85a3e"
|
||||
}
|
||||
|
||||
if (data.field_active === false) {
|
||||
return null
|
||||
}
|
||||
|
||||
// Shows nested list of nodes > their JSON lists
|
||||
const ActionlistWrapper = (props) => {
|
||||
|
||||
@@ -1296,6 +1350,7 @@ const ParsedAction = (props) => {
|
||||
{/*<div style={{width: 17, height: 17, borderRadius: 17 / 2, backgroundColor: itemColor, marginRight: 10, marginTop: 2, marginTop: "auto", marginBottom: "auto",}}/>*/}
|
||||
return (
|
||||
<div key={data.name}>
|
||||
{hideBodyButton}
|
||||
<div style={{marginTop: 20, marginBottom: 0, display: "flex"}}>
|
||||
{data.configuration === true ?
|
||||
<Tooltip color="primary" title={`Authenticate ${selectedApp.name}`} placement="top">
|
||||
@@ -1306,10 +1361,11 @@ const ParsedAction = (props) => {
|
||||
:
|
||||
null
|
||||
}
|
||||
|
||||
<div style={{flex: "10", marginTop: "auto", marginBottom: "auto",}}>
|
||||
<Tooltip title={tooltipDescription} placement="top">
|
||||
<b>{tmpitem} </b>
|
||||
</Tooltip>
|
||||
</Tooltip>
|
||||
</div>
|
||||
|
||||
{/*selectedActionParameters[count].options !== undefined && selectedActionParameters[count].options !== null && selectedActionParameters[count].options.length > 0 ? null :
|
||||
@@ -1355,7 +1411,7 @@ const ParsedAction = (props) => {
|
||||
onChange={(event) => {
|
||||
//console.log("CHECKED!: ", selectedActionParameters[count])
|
||||
selectedActionParameters[count].unique_toggled = !selectedActionParameters[count].unique_toggled
|
||||
selectedAction.parameters[count].unique_toggled = selectedActionParameters[count].unique_toggled
|
||||
selectedAction.parameters[count].unique_toggled = selectedActionParameters[count].unique_toggled
|
||||
setSelectedActionParameters(selectedActionParameters)
|
||||
setSelectedAction(selectedAction)
|
||||
setUpdate(Math.random())
|
||||
@@ -1610,7 +1666,9 @@ const ParsedAction = (props) => {
|
||||
: null}
|
||||
{selectedAction.authentication !== undefined && selectedAction.authentication !== null && selectedAction.authentication.length > 0 ?
|
||||
<div style={{marginTop: 15, }}>
|
||||
Authentication
|
||||
<Typography>
|
||||
Authentication
|
||||
</Typography>
|
||||
<div style={{display: "flex"}}>
|
||||
<Select
|
||||
labelId="select-app-auth"
|
||||
|
||||
Reference in New Issue
Block a user