Fixed further user input issues

This commit is contained in:
Frikky
2024-03-19 23:56:16 +01:00
parent 06494a0093
commit 54b3687eef
9 changed files with 148 additions and 38 deletions
+1 -3
View File
@@ -457,7 +457,7 @@ const CacheView = (props) => {
const validate = validateJson(data.value);
return (
<ListItem key={index} style={{ backgroundColor: bgColor, maxHeight: 300, overflow: "hidden", }}>
<ListItem key={index} style={{ backgroundColor: bgColor, maxHeight: 300, overflow: "auto", }}>
<ListItemText
style={{
maxWidth: 250,
@@ -470,8 +470,6 @@ const CacheView = (props) => {
style={{
minWidth: 400,
maxWidth: 400,
overflowX: "auto",
overflowY: "hidden",
}}
primary={validate.valid ?
<ReactJson
+1 -1
View File
@@ -59,7 +59,7 @@ const Files = (props) => {
const [downloadFolder, setDownloadFolder] = React.useState("translation_standards");
//const alert = useAlert();
const allowedFileTypes = ["txt", "py", "yaml", "yml","json", "html", "js", "csv", "log"]
const allowedFileTypes = ["txt", "py", "yaml", "yml","json", "html", "js", "csv", "log", "eml", "msg", "md", "xml", "sh", "bat", "ps1", "psm1", "psd1", "ps1xml", "pssc", "psc1"]
var upload = "";
const handleKeyDown = (event) => {
+15 -8
View File
@@ -1155,7 +1155,7 @@ If you're interested, please let me know a time that works for you, or set up a
})
.then((responseJson) => {
if (responseJson.success === false) {
toast("Failed getting your org. If this persists, please contact support.");
//toast("Failed getting your org. If this persists, please contact support.");
} else {
const { subOrgs, parentOrg } = responseJson;
setSubOrgs(subOrgs);
@@ -1164,7 +1164,7 @@ If you're interested, please let me know a time that works for you, or set up a
})
.catch((error) => {
console.log("Error getting sub orgs: ", error);
toast("Error getting sub organizations");
//toast("Error getting sub organizations");
});
};
@@ -2846,13 +2846,20 @@ If you're interested, please let me know a time that works for you, or set up a
: null}
{isCloud ?
<Tooltip
title={`Organization is in ${regiontag}. Click to change!`}
style={{}}
title={`Your organization is in ${regiontag}. Click to change!`}
style={{
}}
>
<Avatar
style={{ top: -10, right: 50, position: "absolute", }}
style={{ cursor: "pointer", top: -10, right: 50, position: "absolute", }}
onClick={() => {
toast("Region change is not implemented yet for users. Please contact support.")
toast("Region change is not directly implemented yet, and requires support help.")
if (window.drift !== undefined) {
window.drift.api.startInteraction({
interactionId: 386411,
})
}
}}
>
{regiontag}
@@ -3924,7 +3931,7 @@ If you're interested, please let me know a time that works for you, or set up a
Schedules used in Workflows. Makes locating and control easier.{" "}
<a
target="_blank"
rel="noopener noreferrer"
rel="noopener noreferrer"
href="/docs/organizations#schedules"
style={{ textDecoration: "none", color: "#f85a3e" }}
>
@@ -4528,7 +4535,7 @@ If you're interested, please let me know a time that works for you, or set up a
style={{ minWidth: 150, maxWidth: 150 }}
/>
<ListItemText
primary="Orborus label"
primary="Status"
style={{ minWidth: 150, maxWidth: 150 }}
/>
<ListItemText
+82 -3
View File
@@ -117,6 +117,7 @@ import {
Polyline as PolylineIcon,
QueryStats as QueryStatsIcon,
AutoAwesome as AutoAwesomeIcon,
Add as AddIcon,
} from "@mui/icons-material";
import * as cytoscape from "cytoscape";
@@ -13026,6 +13027,35 @@ const AngularWorkflow = (defaultprops) => {
});
};
// POST to /api/v1/workflows
const createWorkflow = (workflow, trigger_index) => {
fetch(globalUrl + "/api/v1/workflows", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(workflow),
credentials: "include",
})
.then((response) => {
if (response.status === 200) {
getAvailableWorkflows(trigger_index)
}
return response.json();
})
.then((responseJson) => {
if (responseJson.id !== undefined && responseJson.id !== null && responseJson.id.length > 0) {
toast("Successfully created workflow");
handleWorkflowSelectionUpdate({ target: { value: responseJson } }, true)
}
})
.catch((error) => {
console.log("Create workflow error: ", error.toString())
})
}
const UserinputSidebar = () => {
if (Object.getOwnPropertyNames(selectedTrigger).length > 0 && workflow.triggers[selectedTriggerIndex] !== undefined) {
if (
@@ -13229,7 +13259,7 @@ const AngularWorkflow = (defaultprops) => {
/>
</FormGroup>
{workflow.triggers[selectedTriggerIndex].parameters[2] !== undefined && workflow.triggers[selectedTriggerIndex].parameters[2].value.includes("subflow") ? (
<div style={{ }}>
<div style={{ }}>
{workflows === undefined ||
workflows === null ||
workflows.length === 0 ? null : (
@@ -13316,7 +13346,29 @@ const AngularWorkflow = (defaultprops) => {
}}
/>
)}
</div>
{/* Button for making a new workflow to attach */}
<Button
variant="outlined"
style={{ marginTop: 10, }}
disabled={!(subworkflow === null || subworkflow === undefined || Object.getOwnPropertyNames(subworkflow).length === 0)}
onClick={() => {
toast("Setting up new workflow")
const newworkflow = {
name: "User Input subflow",
description: "",
}
createWorkflow(newworkflow, selectedTriggerIndex)
}}
color="primary"
>
<AddIcon /> New Subflow
</Button>
</div>
) : null}
{workflow.triggers[selectedTriggerIndex].parameters[2] !==
undefined &&
@@ -16202,11 +16254,13 @@ const AngularWorkflow = (defaultprops) => {
<Typography variant="body1">
<b>Env &nbsp;&nbsp;&nbsp;&nbsp;</b>
</Typography>
<Typography variant="body1" color="textSecondary" style={{color: "#f85a3e", cursor: "pointer", }} onClick={() => {
window.open("/admin?tab=environments", "_blank")
}}>
{executionData.workflow.actions[0].environment}
</Typography>
</div>
: null}
{executionData.status !== undefined &&
@@ -16877,6 +16931,30 @@ const AngularWorkflow = (defaultprops) => {
return ""
}
// Check if array with json inside to handle one item at a time~
if (typeof result === "object" && result.length !== undefined) {
if (result.length > 0) {
// Check type inside
if (typeof result[0] === "object") {
result = result[0]
}
}
}
if (result.success === true && result.status === 200) {
if (result.body !== undefined && result.body !== null) {
const stringbody = result.body.toString()
if ((stringbody.startsWith("{") && stringbody.endsWith("}")) || (stringbody.startsWith("[") && stringbody.endsWith("]"))) {
return ""
}
if (stringbody.length > 1000) {
return "Body looks to be big in a standard format. Consider using the 'To File' parameter to automatically make it into a file."
}
} else {
}
}
// Validate and check for newlines
if (result.success !== false) {
@@ -16894,7 +16972,8 @@ const AngularWorkflow = (defaultprops) => {
}
return ""
}
}
try {
stringjson = JSON.stringify(result)
+30 -18
View File
@@ -1018,9 +1018,9 @@ const Workflows = (props) => {
data.default_return_value,
data,
false,
[],
"",
data.status
[],
"",
data.status
).then((response) => {
if (response !== undefined) {
toast(`Successfully imported ${data.name}`);
@@ -1483,17 +1483,9 @@ const Workflows = (props) => {
const sanitizeWorkflow = (data) => {
data = JSON.parse(JSON.stringify(data));
data["owner"] = "";
console.log("Sanitize start: ", data);
data = deduplicateIds(data);
data["org"] = [];
data["org_id"] = "";
data["execution_org"] = {};
// These are backwards.. True = saved before. Very confuse.
data["previously_saved"] = false;
data["first_save"] = false;
console.log("Sanitize end: ", data);
return data;
@@ -1508,14 +1500,24 @@ const Workflows = (props) => {
let exportFileDefaultName = data.name + ".json";
data["owner"] = "";
data["org"] = [];
data["org_id"] = "";
data["execution_org"] = {};
// These are backwards.. True = saved before. Very confuse.
data["previously_saved"] = false;
data["first_save"] = false;
if (sanitize === true) {
data = sanitizeWorkflow(data);
if (data.subflows !== null && data.subflows !== undefined) {
toast(
"Not exporting with subflows when sanitizing. Please manually export them."
);
data.subflows = [];
)
data.subflows = []
}
// for (var key in data.subflows) {
@@ -1527,7 +1529,7 @@ const Workflows = (props) => {
// Add correct ID's for triggers
// Add mag
data.status = "test"
data.status = "test"
let dataStr = JSON.stringify(data);
let dataUri =
"data:application/json;charset=utf-8," + encodeURIComponent(dataStr);
@@ -2220,6 +2222,7 @@ const Workflows = (props) => {
inputblogpost,
inputstatus,
) => {
var method = "POST";
var extraData = "";
var workflowdata = {};
@@ -2232,6 +2235,10 @@ const Workflows = (props) => {
console.log("REMOVING OWNER");
workflowdata["owner"] = "";
workflowdata["org"] = [];
workflowdata["org_id"] = "";
workflowdata["execution_org"] = {};
workflowdata["previously_saved"] = false;
// FIXME: Loop triggers and turn them off?
}
@@ -2240,8 +2247,9 @@ const Workflows = (props) => {
if (tags !== undefined) {
workflowdata["tags"] = tags;
}
workflowdata["blogpost"] = inputblogpost
workflowdata["status"] = inputstatus
workflowdata["blogpost"] = inputblogpost
workflowdata["status"] = inputstatus
if (defaultReturnValue !== undefined) {
workflowdata["default_return_value"] = defaultReturnValue;
@@ -2320,7 +2328,7 @@ const Workflows = (props) => {
if (file.type !== "application/json") {
if (file.type !== undefined) {
toast("File has to contain valid json");
setSubmitLoading(false)
setSubmitLoading(false)
}
continue;
@@ -2338,7 +2346,7 @@ const Workflows = (props) => {
return;
}
console.log("File being loaded: ", data.name);
console.log("File being loaded: ", data.name);
// Initialize the workflow itself
setNewWorkflow(
@@ -2359,6 +2367,10 @@ const Workflows = (props) => {
data.first_save = false;
data.previously_saved = false;
data.is_valid = false;
data.org_id = userdata.active_org.id
data.org = []
data.execution_org = {}
// Actually create it
setNewWorkflow(