Added basic string replacement when a node changes name
This commit is contained in:
@@ -2257,7 +2257,7 @@ const ParsedAction = (props) => {
|
|||||||
//}
|
//}
|
||||||
//console.log("env: ", selectedActionEnvironment)
|
//console.log("env: ", selectedActionEnvironment)
|
||||||
|
|
||||||
const baselabel = selectedAction.label;
|
var baselabel = selectedAction.label;
|
||||||
return (
|
return (
|
||||||
<div style={appApiViewStyle} id="parsed_action_view">
|
<div style={appApiViewStyle} id="parsed_action_view">
|
||||||
|
|
||||||
@@ -2490,23 +2490,86 @@ const ParsedAction = (props) => {
|
|||||||
const name = e.target.value;
|
const name = e.target.value;
|
||||||
console.log("CHANGED FROM2: ", baselabel);
|
console.log("CHANGED FROM2: ", baselabel);
|
||||||
console.log("CHANGED TO: ", name);
|
console.log("CHANGED TO: ", name);
|
||||||
|
|
||||||
|
const parsedBaseLabel = "$"+baselabel.toLowerCase().replaceAll(" ", "_")
|
||||||
|
const newname = "$"+name.toLowerCase().replaceAll(" ", "_")
|
||||||
|
|
||||||
|
// Change in actions, triggers & conditions
|
||||||
|
// Highlight the changes somehow with a glow?
|
||||||
|
|
||||||
for (var key in workflow.actions) {
|
for (var key in workflow.actions) {
|
||||||
|
if (workflow.actions[key].id === selectedAction.id) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
for (var subkey in workflow.actions[key].parameters) {
|
for (var subkey in workflow.actions[key].parameters) {
|
||||||
const param = workflow.actions[key].parameters[subkey];
|
const param = workflow.actions[key].parameters[subkey];
|
||||||
if (param.value.includes(baselabel)) {
|
if (!param.value.includes("$")) {
|
||||||
//if (param.value.toLowerCase().includes(baselabel)) {
|
continue
|
||||||
console.log("FOUND: ", param);
|
}
|
||||||
|
|
||||||
workflow.actions[key].parameters[subkey].value.replaceAll(
|
console.log("PARAM: ", param)
|
||||||
baselabel,
|
|
||||||
e.target.value
|
// Should have a smarter way of discovering node names
|
||||||
);
|
// Do regex?
|
||||||
|
// Finding index(es) and replacing at the location
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
var cnt = -1
|
||||||
|
var previous = 0
|
||||||
|
while (true) {
|
||||||
|
cnt += 1
|
||||||
|
// Need to make sure e.g. changing the first here doesn't change the 2nd
|
||||||
|
// $change_me
|
||||||
|
// $change_me_2
|
||||||
|
|
||||||
|
const foundindex = param.value.toLowerCase().indexOf(parsedBaseLabel, previous)
|
||||||
|
if (foundindex === previous && foundindex !== 0) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
if (foundindex >= 0) {
|
||||||
|
previous = foundindex+newname.length
|
||||||
|
// Need to add diff of length to word
|
||||||
|
|
||||||
|
// Check location:
|
||||||
|
// If it's a-zA-Z_ then don't replace
|
||||||
|
if (param.value.length > foundindex+parsedBaseLabel.length) {
|
||||||
|
console.log("Validate length if valid key if it's valid - don't replace if it is: ", param.value[foundindex+parsedBaseLabel.length])
|
||||||
|
const regex = /[a-zA-Z0-9_]/g;
|
||||||
|
const match = param.value[foundindex+parsedBaseLabel.length].match(regex);
|
||||||
|
if (match !== null) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("Matching: ", match)
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("Found: ", foundindex)
|
||||||
|
console.log("Old found: ", workflow.actions[key].parameters[subkey].value)
|
||||||
|
const extralength = newname.length-parsedBaseLabel.length
|
||||||
|
param.value = param.value.substring(0, foundindex) + newname + param.value.substring(foundindex-extralength+newname.length, param.value.length)
|
||||||
|
console.log("New: ", workflow.actions[key].parameters[subkey].value)
|
||||||
|
} else {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
// Break no matter what after 5 replaces. May need to increase
|
||||||
|
if (cnt >= 5) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.log("Failed value replacement based on index: ", e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("DID REPLACE ACTUALLY WORK?? - Something is buggy.");
|
console.log("DID REPLACE ACTUALLY WORK?? - Something is buggy.");
|
||||||
setWorkflow(workflow);
|
setWorkflow(workflow);
|
||||||
|
baselabel = name
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -75,7 +75,6 @@ const CodeEditor = (props) => {
|
|||||||
allVariable.push('$'+actionlist[i].autocomplete.toLowerCase())
|
allVariable.push('$'+actionlist[i].autocomplete.toLowerCase())
|
||||||
mainVariables.push('$'+actionlist[i].autocomplete.toLowerCase())
|
mainVariables.push('$'+actionlist[i].autocomplete.toLowerCase())
|
||||||
// console.log(actionlist[i])
|
// console.log(actionlist[i])
|
||||||
console.log(actionlist[i].example.length)
|
|
||||||
// for(var j=0; j<actionlist[i].example.length; j++){
|
// for(var j=0; j<actionlist[i].example.length; j++){
|
||||||
// console.log(j)
|
// console.log(j)
|
||||||
// allVariable.push('$'+actionlist[i].example[j].toLowerCase().substring(0, 25))
|
// allVariable.push('$'+actionlist[i].example[j].toLowerCase().substring(0, 25))
|
||||||
@@ -177,7 +176,10 @@ const CodeEditor = (props) => {
|
|||||||
for(var occ_len = 0; occ_len < dollar_occurences_len[occ]; occ_len++){
|
for(var occ_len = 0; occ_len < dollar_occurences_len[occ]; occ_len++){
|
||||||
temp_arr.push(dollar_occurences[occ]+occ_len+1)
|
temp_arr.push(dollar_occurences[occ]+occ_len+1)
|
||||||
}
|
}
|
||||||
if(temp_arr.length==1){temp_arr.push(temp_arr[temp_arr.length-1]+1)}
|
|
||||||
|
if(temp_arr.length==1) {
|
||||||
|
temp_arr.push(temp_arr[temp_arr.length-1]+1)
|
||||||
|
}
|
||||||
variable_ranges.push(temp_arr)
|
variable_ranges.push(temp_arr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1839,15 +1839,13 @@ const AngularWorkflow = (defaultprops) => {
|
|||||||
// Wait for new node to possibly be selected
|
// Wait for new node to possibly be selected
|
||||||
//setTimeout(() => {
|
//setTimeout(() => {
|
||||||
const typeIds = cy.elements('node:selected').jsons();
|
const typeIds = cy.elements('node:selected').jsons();
|
||||||
console.log("Found: ", typeIds)
|
|
||||||
for (var idkey in typeIds) {
|
for (var idkey in typeIds) {
|
||||||
const item = typeIds[idkey]
|
const item = typeIds[idkey]
|
||||||
console.log("items: ", item)
|
|
||||||
if (item.data.isButton === true) {
|
if (item.data.isButton === true) {
|
||||||
console.log("Reselect old node & return - or just return?")
|
//console.log("Reselect old node & return - or just return?")
|
||||||
|
|
||||||
if (item.data.buttonType === "delete" && item.data.attachedTo === nodedata.id) {
|
if (item.data.buttonType === "delete" && item.data.attachedTo === nodedata.id) {
|
||||||
console.log("delete of same node!")
|
//console.log("delete of same node!")
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -3699,7 +3697,6 @@ const AngularWorkflow = (defaultprops) => {
|
|||||||
for (var idkey in typeIds) {
|
for (var idkey in typeIds) {
|
||||||
const item = typeIds[idkey]
|
const item = typeIds[idkey]
|
||||||
if (item.data.id === nodedata.id) {
|
if (item.data.id === nodedata.id) {
|
||||||
console.log("items: ", item.data.id, nodedata.id)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user