Syncing usecases2

This commit is contained in:
Frikky
2024-11-20 18:59:58 +01:00
parent 8883de54d1
commit f76ebae047
4 changed files with 1422 additions and 211 deletions
+70 -121
View File
@@ -210,6 +210,7 @@ const ParsedAction = (props) => {
useEffect(() => {
// Changes the order of params to show in order:
// auth, required, optional
/*
var changed = false
if (selectedActionParameters === undefined || selectedActionParameters === null || selectedActionParameters.length === 0) {
return
@@ -221,7 +222,7 @@ const ParsedAction = (props) => {
var keyorder = []
for (let paramkey in selectedActionParameters) {
const param = selectedActionParameters[paramkey]
var param = selectedActionParameters[paramkey]
keyorder.push(param.name)
if (param.configuration) {
@@ -229,6 +230,10 @@ const ParsedAction = (props) => {
continue
}
if (param?.value?.toLowerCase().includes("secret. replace")) {
param.value = ""
}
if (param.required) {
required.push(param)
continue
@@ -250,6 +255,7 @@ const ParsedAction = (props) => {
selectedAction.parameters = newparams
setSelectedAction(selectedAction)
}
*/
}, [selectedActionParameters])
@@ -803,22 +809,21 @@ const ParsedAction = (props) => {
console.log("IN ELSE: ", paramcheck);
}
//console.log("PARAM: ", paramcheck)
//if (paramcheck.id === undefined) {
// console.log("Normal paramcheck")
//} else {
// selectedActionParameters[count]["value_replace"] = paramcheck
// selectedAction.parameters[count]["value_replace"] = paramcheck
//}
if (selectedActionParameters[count].value_replace === undefined) {
selectedActionParameters[count].value_replace = paramcheck
}
if (selectedAction.parameters[count].value_replace === undefined) {
selectedAction.parameters[count].value_replace = paramcheck
}
if (paramcheck["value_replace"] === undefined) {
selectedActionParameters[count]["value_replace"] = paramcheck;
selectedAction.parameters[count]["value_replace"] = paramcheck;
selectedActionParameters[count]["value_replace"] = paramcheck
selectedAction.parameters[count]["value_replace"] = paramcheck
} else {
selectedActionParameters[count]["value_replace"] =
paramcheck["value_replace"];
selectedAction.parameters[count]["value_replace"] =
paramcheck["value_replace"];
selectedActionParameters[count]["value_replace"] = paramcheck["value_replace"];
selectedAction.parameters[count]["value_replace"] = paramcheck["value_replace"];
}
setSelectedAction(selectedAction);
//setUpdate(Math.random())
@@ -999,8 +1004,6 @@ const ParsedAction = (props) => {
} else {
paramcheck["value_replace"][subparamindex]["value"] = toReplace
}
console.log("IN ELSE: ", paramcheck)
}
//console.log("PARAM: ", paramcheck)
//if (paramcheck.id === undefined) {
@@ -1451,9 +1454,9 @@ const ParsedAction = (props) => {
</Tooltip>
<h3 style={{ }}>
{(
selectedAction.app_name.charAt(0).toUpperCase() +
selectedAction.app_name.substring(1)
).replaceAll("_", " ")}
selectedAction?.app_name?.charAt(0).toUpperCase() +
selectedAction?.app_name?.substring(1)
)?.replaceAll("_", " ")}
</h3>
</div>
<div style={{display: "flex", marginTop: 0, }}>
@@ -2206,9 +2209,7 @@ const ParsedAction = (props) => {
</div>
) : null*/}
{workflow.execution_variables !== undefined &&
workflow.execution_variables !== null &&
workflow.execution_variables.length > 0 ? (
{workflow.execution_variables !== undefined && workflow.execution_variables !== null && workflow.execution_variables.length > 0 ? (
<div style={{ marginTop: "20px" }}>
<Typography>Execution variable (optional)</Typography>
<Select
@@ -2429,7 +2430,6 @@ const ParsedAction = (props) => {
);
}}
renderInput={(params) => {
if (params.inputProps?.value) {
const prefixes = ["Post", "Put", "Patch"];
for (let prefix of prefixes) {
@@ -2451,45 +2451,6 @@ const ParsedAction = (props) => {
const actionDescription = null
/*(
<Box
p={1.5}
borderRadius={3}
boxShadow={2}
backgroundColor={theme.palette.textFieldStyle}
display="flex"
flexDirection="column"
>
<Box display="flex" alignItems="center" justifyContent="space-between">
<Typography variant="body1" style={{ flexGrow: 1 }}>
{params.inputProps.value}
</Typography>
<IconButton size="small"
onMouseDown={(event) => {
event.preventDefault();
event.stopPropagation();
}}
onClick={() => {
setHiddenDescription(true)
const inputElement = document.getElementById(uiBox);
if (inputElement) {
inputElement.focus();
}
}}
>
<CloseIcon fontSize="small" />
</IconButton>
</Box>
<Divider sx={{ backgroundColor: theme.palette.surfaceColor, marginTop: "5px", marginBottom : "10px", height: "3px" }}/>
<Box display="flex" flexDirection="column">
<Typography variant="body2" mb={0.5}>
<strong>Description: </strong> {selectedAction?.description}
</Typography>
</Box>
</Box>
)
*/
return (
<Tooltip title={actionDescription}
@@ -3043,7 +3004,6 @@ const ParsedAction = (props) => {
//setSelectedActionParameters(selectedActionParameters)
}
var hideBodyButton = "";
const hideBodyButtonValue = (
<div
key={data.name}
@@ -3066,66 +3026,65 @@ const ParsedAction = (props) => {
}
placement="top"
>
<FormControlLabel
control={
<Checkbox
tabIndex="-1"
checked={hideBody}
style={{
color: theme.palette.primary.secondary,
}}
onChange={(event) => {
const newHideBody = !hideBody;
setHideBody(newHideBody)
<ButtonGroup fullWidth>
<Button variant={hideBody === true ? "outlined" : "contained"} color="primary" onClick={() => {
setHideBody(false)
const updatedParameters = selectedActionParameters.map((param) => {
if (param.name === "body") {
return { ...param, id: newHideBody ? "UNTOGGLED" : "TOGGLED" };
return {
...param,
id: "UNTOGGLED",
}
}
if (param.description === openApiFieldDesc) {
return { ...param, field_active: newHideBody };
return { ...param, field_active: true }
}
return param;
});
setSelectedActionParameters(updatedParameters);
return param
})
/*
setTimeout(() => {
const element = document.getElementById("hide_body_button");
if (element) {
element.scrollIntoView({
behavior: "smooth",
block: "center",
});
setSelectedActionParameters(updatedParameters)
}}>
Simple
</Button>
<Button variant={hideBody === true ? "contained" : "outlined" } color="primary" onClick={() => {
setHideBody(true)
// Make sure the body field is shown
const updatedParameters = selectedActionParameters.map((param) => {
if (param.name === "body") {
return {
...param,
id: "TOGGLED",
}
}, 100);
*/
}}
name="requires_unique"
/>
}
label={hideBody ? "Show Body" : "Hide Body"}
/>
if (param.description === openApiFieldDesc) {
return { ...param, field_active: false }
}
return param
})
setSelectedActionParameters(updatedParameters)
}}>
Advanced
</Button>
</ButtonGroup>
</Tooltip>
</div>
);
var showButtonField = false
if (selectedApp.generated && data.name === "body") {
const regex = /\${(\w+)}/g;
const found = placeholder.match(regex);
hideBodyButton = hideBodyButtonValue;
if (found === null || !hideBody) {
if (found === null) {
showButtonField = true
if (activateHidingBodyButton !== true) {
setActivateHidingBodyButton(true)
}
} else {
//console.log("In found: ", found, hideBody)
}
if (hideBody === true) {
//toast("BODYBUTTON TRUE")
} else {
rows = "1";
@@ -3200,10 +3159,9 @@ const ParsedAction = (props) => {
}
}
}
//selectedActionParameters
if (changed) {
// Sort selectedActionParameters based on selectedActionParameters.required
//selectedActionParameters.sort((a, b) => (a.required < b.required) ? 1 : -1)
// Find the "headers" and "queries" field names and put them on the first indexes anyway
var newArray = required.concat(notRequired)
@@ -3211,12 +3169,9 @@ const ParsedAction = (props) => {
setSelectedActionParameters(newArray)
}
return hideBodyButton;
}
}
if (activateHidingBodyButton === true) {
hideBodyButton = "";
//return hideBodyButtonValue
}
const clickedFieldId = "rightside_field_" + count;
@@ -3226,7 +3181,6 @@ const ParsedAction = (props) => {
baseHelperText = calculateHelpertext(data.value)
}
var tmpitem = data.name.valueOf();
if (data.name.startsWith("${") && data.name.endsWith("}")) {
tmpitem = tmpitem.slice(2, data.name.length - 1);
@@ -4178,15 +4132,6 @@ const ParsedAction = (props) => {
})}
</Menu>
);
};
//var itemColor = "#f85a3e"
//if (!data.required) {
// itemColor = "#ffeb3b"
//}
{
/*<div style={{width: 17, height: 17, borderRadius: 17 / 2, backgroundColor: itemColor, marginRight: 10, marginTop: 2, marginTop: "auto", marginBottom: "auto",}}/>*/
}
const buttonTitle = `Authenticate API ${selectedApp.name.replaceAll("_", " ")}`
@@ -4195,9 +4140,13 @@ const ParsedAction = (props) => {
data.variant = "STATIC_VALUE"
}
if (data.name === "body" && hideBody === false) {
return hideBodyButtonValue
}
return (
<div key={data.name}>
{/* {hideBodyButton} */}
{showButtonField === true ? hideBodyButtonValue : null}
<div
style={{ marginTop: 20, marginBottom: 0, display: "flex" }}
>
+2 -2
View File
@@ -4960,7 +4960,7 @@ If you're interested, please let me know a time that works for you, or set up a
<div style={{ marginTop: 50, marginBottom: 20 }}>
<h2 style={{ display: "inline" }}>Webhooks</h2>
<span style={{ marginLeft: 25 }}>
Webhooks used in Shuffle workflows.&nbsp;
Current HTTP Webhook endpoints in your organization.&nbsp;
<a
target="_blank"
rel="noopener noreferrer"
@@ -5114,7 +5114,7 @@ If you're interested, please let me know a time that works for you, or set up a
<div style={{ marginTop: 50, marginBottom: 20 }}>
<h2 style={{ display: "inline" }}>Pipelines</h2>
<span style={{ marginLeft: 25 }}>
Controls a pipeline to run things.{" "}
Controls a pipeline to e.g. connect to Kafka queues or search in the Tenzir storage.{" "}
<a
target="_blank"
rel="noopener noreferrer"
+60 -51
View File
@@ -3967,7 +3967,7 @@ const releaseToConnectLabel = "Release to Connect"
};
const onNodeDragStop = (event, selectedAction) => {
const nodedata = event.target.data();
const nodedata = event.target.data()
if (nodedata.id === selectedAction.id) {
//console.log("Same node, return")
return
@@ -4759,9 +4759,9 @@ const releaseToConnectLabel = "Release to Connect"
// Forces all states to update at the same time,
// Otherwise everything is SUPER slow
//const data = JSON.parse(JSON.stringify(event.target.data()))
// FIXME: Do absolutely NOT use JSON.stringify on the event.target.data()
// This causes memory referencing to become a nightmare
const data = event.target.data()
if (data.app_name === "Shuffle Workflow") {
if ((data.parameters !== undefined) && (data.parameters.length > 0)) {
getWorkflowApps(data.parameters[0].value)
@@ -5161,25 +5161,29 @@ const releaseToConnectLabel = "Release to Connect"
if (data.type === "ACTION") {
setSelectedComment({})
//var curaction = JSON.parse(JSON.stringify(data))
// FIXME: Trust it to just work?
//event.target.data()
// FIXME: is this what is mapping it an actual action in the workflow? wtf?
var curaction = workflow.actions.find((a) => a.id === data.id)
if (!curaction || curaction === undefined) {
if (data.id !== undefined && data.app_name !== undefined) {
workflow.actions.push(data)
setWorkflow(workflow)
curaction = data
// FIXME: Is this necessary?
//curaction = JSON.parse(JSON.stringify(data))
} else {
if (workflow.public !== true) {
toast("Action not found. Please remake it.");
}
event.target.remove();
return;
event.target.remove()
return
}
}
// FIXME: This change may cause... something
curaction = data
//var newapps = JSON.parse(JSON.stringify(apps))
var newapps = apps
if (apps === null || apps === undefined || apps.length === 0) {
@@ -5410,6 +5414,7 @@ const releaseToConnectLabel = "Release to Connect"
curaction.parameters[curActionParamKey].value = curaction.parameters[curActionParamKey].options[0];
}
}
} else {
console.log("Should check APP if it has the same params as ACTION")
for (let actionKey in curapp.actions) {
@@ -5422,6 +5427,7 @@ const releaseToConnectLabel = "Release to Connect"
break
}
}
}
// Fix authentication fields that may be missing in the UI
@@ -5466,7 +5472,7 @@ const releaseToConnectLabel = "Release to Connect"
}
setSelectedApp(curapp)
setSelectedAction(curaction);
setSelectedAction(curaction)
cy.removeListener("drag");
cy.removeListener("free");
@@ -5971,7 +5977,6 @@ const releaseToConnectLabel = "Release to Connect"
}
}
}
// Check agains every param
}
}
@@ -6208,29 +6213,29 @@ const releaseToConnectLabel = "Release to Connect"
const onNodeAdded = (event) => {
const node = event.target;
const nodedata = event.target.data();
const nodedata = JSON.parse(JSON.stringify(event.target.data()))
if (nodedata.finished === false || (nodedata.id !== undefined && nodedata.is_valid === undefined)
) {
return;
if (nodedata.finished === false || (nodedata.id !== undefined && nodedata.is_valid === undefined)) {
return
}
// DONT MOVE THIS LINE RIGHT HERE v
setLastSaved(false)
if (node.isNode() && cy.nodes().size() === 1) {
workflow.start = node.data("id");
nodedata.isStartNode = true;
workflow.start = node.data("id")
nodedata.isStartNode = true
} else {
if (workflow.actions === null) {
console.log("Returning because node has no value")
return;
return
}
// Remove bad startnode
for (let actionkey in workflow.actions) {
const action = workflow.actions[actionkey];
if (action.isStartNode && workflow.start !== action.id) {
action.isStartNode = false;
action.isStartNode = false
}
}
}
@@ -6289,25 +6294,23 @@ const releaseToConnectLabel = "Release to Connect"
}
if (nodedata.parameters !== undefined && nodedata.parameters !== null && !nodedata.label.endsWith("_copy")) {
if (nodedata.parameters !== undefined && nodedata.parameters !== null && !nodedata?.label?.endsWith("_copy")) {
var newparameters = [];
for (let [subkey,subkeyval] in Object.entries(nodedata.parameters)) {
var newparam = JSON.parse(
JSON.stringify(nodedata.parameters[subkey])
);
newparam.id = uuidv4();
var newparam = JSON.parse(JSON.stringify(nodedata.parameters[subkey]))
newparam.id = uuidv4()
if (newparam.value === undefined || newparam.value === null) {
newparam.value = "";
newparam.value = ""
} else {
newparam.value = newparam.value;
newparam.value = newparam.value
}
newparameters.push(newparam);
}
nodedata.parameters = newparameters;
nodedata.parameters = newparameters
}
if (workflow.actions === undefined || workflow.actions === null) {
@@ -7514,7 +7517,7 @@ const releaseToConnectLabel = "Release to Connect"
};
const onNodeHover = (event) => {
const nodedata = event.target.data();
const nodedata = JSON.parse(JSON.stringify(event.target.data()))
const cytoscapeElement = document.getElementById("cytoscape_view")
if (cytoscapeElement !== undefined && cytoscapeElement !== null) {
@@ -7528,7 +7531,7 @@ const releaseToConnectLabel = "Release to Connect"
})
if (nodedata.finished === false) {
console.log("NODE UNFINISHED (hover in): ", nodedata)
console.log("NODE UNFINISHED (hover in): ", JSON.parse(JSON.stringify(nodedata)))
// Should just be 1, so this should be fast enough :3
const incomingEdges = event.target.incomers("edge").jsons()
@@ -9635,7 +9638,6 @@ const releaseToConnectLabel = "Release to Connect"
newNodeId = uuidv4();
const actionType = "ACTION";
const actionLabel = getNextActionName(app.name);
//console.log("Next action name: ", actionLabel)
var parameters = null;
var example = "";
var description = ""
@@ -9653,12 +9655,9 @@ const releaseToConnectLabel = "Release to Connect"
}
// Make the first action the most relevant one for them based on previous use
if (
app.actions[actionIndex].parameters !== undefined &&
app.actions[actionIndex].parameters !== null &&
app.actions[actionIndex].parameters.length > 0
) {
parameters = app.actions[actionIndex].parameters;
if (app.actions[actionIndex].parameters !== undefined && app.actions[actionIndex].parameters !== null && app.actions[actionIndex].parameters.length > 0) {
parameters = JSON.parse(JSON.stringify(app.actions[actionIndex].parameters))
for (let paramkey in parameters) {
// Check if parameter.name == "headers" and if it includes "=undefined". If it does, set the value to example if it exists, otherwise empty
if (parameters[paramkey].name === "headers" && parameters[paramkey].value.includes("=undefined")) {
@@ -9669,8 +9668,6 @@ const releaseToConnectLabel = "Release to Connect"
}
}
}
//parameters = app.actions[0].parameters;
}
if (
@@ -9763,23 +9760,20 @@ const releaseToConnectLabel = "Release to Connect"
authentication_id: authId,
finished: false,
template: app.template === true ? true : false,
};
// FIXME: overwrite category if the ACTION chosen has a different category
//
}
// FIXME: Something is going wrong with params
if (!isCloud && (!app.is_valid || (!app.activated && app.generated))) {
console.log("NOT VALID: Activate!")
activateApp(app.id, false)
}
// const image = "url("+app.large_image+")"
// FIXME - find the cytoscape offset position
// find the cytoscape offset position
// Can this be done with zoom calculations?
const nodeToBeAdded = {
group: "nodes",
data: newAppData,
data: JSON.parse(JSON.stringify(newAppData)),
renderedPosition: {
x: e.pageX - cycontainer.offsetLeft,
y: e.pageY - cycontainer.offsetTop,
@@ -10559,7 +10553,6 @@ const releaseToConnectLabel = "Release to Connect"
continue
}
//newSelectedAction.parameters[newParamIndex].value = param.value
}
if (newSelectedAction.parameters === undefined || newSelectedAction.parameters === null) {
@@ -10584,6 +10577,13 @@ const releaseToConnectLabel = "Release to Connect"
}
}
/*
console.log("PARAM CHANGE: ", param, newSelectedAction.parameters[newParamIndex])
if (param?.value?.includes("Secret. Replaced") && (param.configuration !== true || newSelectedAction.parameters[newParamIndex].configuration !== true)) {
continue
}
*/
newSelectedAction.parameters[newParamIndex].value = param.value
newSelectedAction.parameters[newParamIndex].autocompleted = true
if (param.options !== undefined && param.options !== null && param.options.length > 0) {
@@ -10615,6 +10615,16 @@ const releaseToConnectLabel = "Release to Connect"
}
}
for (var preparamindex in newSelectedAction.parameters) {
const param = newSelectedAction.parameters[preparamindex]
if (param.configuration === true) {
continue
}
if (param?.value?.toLowerCase().includes("secret. replace")) {
newSelectedAction.parameters[preparamindex].value = ""
}
}
// Takes an action as input, then runs through and updates the relevant parameters based on previous actions' results (parent nodes)
// Further checks if those fields are already set in a previously used action
@@ -11087,7 +11097,7 @@ const releaseToConnectLabel = "Release to Connect"
type: "action",
id: item.id,
name: item.label,
autocomplete: `${item.label.split(" ").join("_")}`,
autocomplete: `${item?.label?.split(" ")?.join("_")}`,
example: item.example === undefined ? "" : item.example,
};
actionlist.push(actionvalue);
@@ -16171,8 +16181,9 @@ const releaseToConnectLabel = "Release to Connect"
for (let actionkey in workflow.actions) {
workflow.actions[actionkey].environment = env.Name
}
setWorkflow(workflow)
toast.success("Set execution location for ALL actions to " + env.Name)
//toast.success("Set execution location for ALL actions to " + env.Name)
}}
style={{
pointerEvents: "auto",
@@ -20913,9 +20924,7 @@ const releaseToConnectLabel = "Release to Connect"
}
color="primary"
defaultValue={
data.value !== undefined && data.value !== null && !data.value.includes("Secret. Replace")
? data.value
: ""
data.value !== undefined && data.value !== null && !data.value.includes("Secret. Replace") ? data.value : ""
}
placeholder={data.example}
onChange={(event) => {
File diff suppressed because it is too large Load Diff