Done with delay

This commit is contained in:
monilprajapati
2024-06-06 17:44:15 +05:30
parent 4f1bfc2313
commit 355466a9a2
2 changed files with 54 additions and 41 deletions
+23 -8
View File
@@ -177,7 +177,8 @@ const ParsedAction = (props) => {
const classes = useStyles(); const classes = useStyles();
const [hideBody, setHideBody] = React.useState(true); const [hideBody, setHideBody] = React.useState(true);
const [activateHidingBodyButton, setActivateHidingBodyButton] = React.useState(false); const [activateHidingBodyButton, setActivateHidingBodyButton] = React.useState(false);
const [appActionName, setAppActionName] = React.useState(selectedAction.label);
const [delay, setDelay] = React.useState(selectedAction?.execution_delay);
const [fieldCount, setFieldCount] = React.useState(0); const [fieldCount, setFieldCount] = React.useState(0);
const [hiddenDescription, setHiddenDescription] = React.useState(true); const [hiddenDescription, setHiddenDescription] = React.useState(true);
const [autoCompleting, setAutocompleting] = React.useState(false); const [autoCompleting, setAutocompleting] = React.useState(false);
@@ -197,6 +198,7 @@ const ParsedAction = (props) => {
} }
}, [expansionModalOpen]) }, [expansionModalOpen])
useEffect(() => { useEffect(() => {
if (selectedAction.parameters === null || selectedAction.parameters === undefined) { if (selectedAction.parameters === null || selectedAction.parameters === undefined) {
return return
@@ -383,6 +385,9 @@ const ParsedAction = (props) => {
() => { () => {
console.log("UseEffect Rendered!") console.log("UseEffect Rendered!")
console.log("Workflow", workflow) console.log("Workflow", workflow)
setAppActionName(selectedAction.label)
setDelay(selectedAction.execution_delay)
// if (selectedActionParameters !== undefined && selectedActionParameters !== null // if (selectedActionParameters !== undefined && selectedActionParameters !== null
// ) { // ) {
if (selectedAction.parameters !== undefined && selectedAction.parameters !== null && selectedAction.parameters.length > 0) { if (selectedAction.parameters !== undefined && selectedAction.parameters !== null && selectedAction.parameters.length > 0) {
@@ -618,6 +623,12 @@ const ParsedAction = (props) => {
}, },
[selectedAction,selectedApp,setNewSelectedAction] [selectedAction,selectedApp,setNewSelectedAction]
); );
useEffect(() => {
selectedNameChange(appActionName)
actionDelayChange(delay)
},[appActionName,delay])
console.log("selectedActionParameters: ", selectedActionParameters) console.log("selectedActionParameters: ", selectedActionParameters)
console.log("selectedApp:", selectedApp) console.log("selectedApp:", selectedApp)
console.log("selectedAction: ", selectedAction) console.log("selectedAction: ", selectedAction)
@@ -1628,11 +1639,17 @@ const ParsedAction = (props) => {
fullWidth fullWidth
color="primary" color="primary"
placeholder={selectedAction.label} placeholder={selectedAction.label}
defaultValue={selectedAction.label} value={appActionName}
onChange={selectedNameChange} onChange={
(event) => {
let newValue = event.target.value
newValue = newValue.replaceAll(" ", "_")
setAppActionName(newValue)
}
}
onBlur={(e) => { onBlur={(e) => {
// Copy the name value // Copy the name value
const name = e.target.value const name = appActionName
const parsedBaseLabel = "$"+baselabel.toLowerCase().replaceAll(" ", "_") const parsedBaseLabel = "$"+baselabel.toLowerCase().replaceAll(" ", "_")
const newname = "$"+name.toLowerCase().replaceAll(" ", "_") const newname = "$"+name.toLowerCase().replaceAll(" ", "_")
@@ -1848,11 +1865,9 @@ const ParsedAction = (props) => {
disableUnderline: true, disableUnderline: true,
}} }}
placeholder={selectedAction.execution_delay} placeholder={selectedAction.execution_delay}
defaultValue={selectedAction.execution_delay} value={delay}
onChange={(event) => { onChange={(event) => {
if (actionDelayChange !== undefined) { setDelay(event.target.value)
actionDelayChange(event)
}
}} }}
/> />
</span> </span>
+31 -33
View File
@@ -22,7 +22,6 @@ import { CodeHandler, Img, OuterLink, } from "../views/Docs.jsx";
import { InstantSearch, Configure, connectSearchBox, connectHits, Index } from 'react-instantsearch-dom'; import { InstantSearch, Configure, connectSearchBox, connectHits, Index } from 'react-instantsearch-dom';
import algoliasearch from 'algoliasearch/lite'; import algoliasearch from 'algoliasearch/lite';
import { import {
Zoom, Zoom,
Fade, Fade,
@@ -10067,44 +10066,43 @@ const AngularWorkflow = (defaultprops) => {
// appname & version // appname & version
// description // description
// ACTION select // ACTION select
const selectedNameChange = (event) => { const selectedNameChange = (appActionName) => {
event.target.value = event.target.value.replaceAll("(", ""); appActionName = appActionName.replaceAll("(", "");
event.target.value = event.target.value.replaceAll(")", ""); appActionName = appActionName.replaceAll(")", "");
event.target.value = event.target.value.replaceAll("]", ""); appActionName = appActionName.replaceAll("]", "");
event.target.value = event.target.value.replaceAll("[", ""); appActionName = appActionName.replaceAll("[", "");
event.target.value = event.target.value.replaceAll("{", ""); appActionName = appActionName.replaceAll("{", "");
event.target.value = event.target.value.replaceAll("}", ""); appActionName = appActionName.replaceAll("}", "");
event.target.value = event.target.value.replaceAll("*", ""); appActionName = appActionName.replaceAll("*", "");
event.target.value = event.target.value.replaceAll("!", ""); appActionName = appActionName.replaceAll("!", "");
event.target.value = event.target.value.replaceAll("@", ""); appActionName = appActionName.replaceAll("@", "");
event.target.value = event.target.value.replaceAll("#", ""); appActionName = appActionName.replaceAll("#", "");
event.target.value = event.target.value.replaceAll("$", ""); appActionName = appActionName.replaceAll("$", "");
event.target.value = event.target.value.replaceAll("%", ""); appActionName = appActionName.replaceAll("%", "");
event.target.value = event.target.value.replaceAll("&", ""); appActionName = appActionName.replaceAll("&", "");
event.target.value = event.target.value.replaceAll("#", ""); appActionName = appActionName.replaceAll("#", "");
event.target.value = event.target.value.replaceAll(".", ""); appActionName = appActionName.replaceAll(".", "");
event.target.value = event.target.value.replaceAll(",", ""); appActionName = appActionName.replaceAll(",", "");
event.target.value = event.target.value.replaceAll(" ", "_"); appActionName = appActionName.replaceAll(" ", "_");
event.target.value = event.target.value.replaceAll("^", "_"); appActionName = appActionName.replaceAll("^", "_");
event.target.value = event.target.value.replaceAll("'", "_"); appActionName = appActionName.replaceAll("'", "_");
event.target.value = event.target.value.replaceAll("\"", "_"); appActionName = appActionName.replaceAll("\"", "_");
event.target.value = event.target.value.replaceAll("\"", "_"); appActionName = appActionName.replaceAll("\"", "_");
event.target.value = event.target.value.replaceAll(":", "_"); appActionName = appActionName.replaceAll(":", "_");
event.target.value = event.target.value.replaceAll(";", "_"); appActionName = appActionName.replaceAll(";", "_");
event.target.value = event.target.value.replaceAll("=", "_"); appActionName = appActionName.replaceAll("=", "_");
event.target.value = event.target.value.replaceAll("+", "_"); appActionName = appActionName.replaceAll("+", "_");
selectedAction.label = appActionName;
selectedAction.label = event.target.value;
setSelectedAction(selectedAction); setSelectedAction(selectedAction);
}; };
const actionDelayChange = (event) => { const actionDelayChange = (delay) => {
if (isNaN(event.target.value)) { if (isNaN(delay)) {
console.log("NAN: ", event.target.value) console.log("NAN: ", delay)
return return
} }
const parsedNumber = parseInt(event.target.value) const parsedNumber = parseInt(delay)
if (parsedNumber > 86400) { if (parsedNumber > 86400) {
console.log("Max number is 1 day (86400)") console.log("Max number is 1 day (86400)")
return return