From 395e1bacc2a7e4ffb6cb5680d5fa02a8ceca5ab4 Mon Sep 17 00:00:00 2001 From: Frikky Date: Thu, 27 Feb 2025 15:05:48 +0100 Subject: [PATCH] Minor fixes for 2.0 --- frontend/src/components/EditOrgTab.jsx | 8 +- frontend/src/components/EditWorkflow.jsx | 2 +- frontend/src/components/EnvironmentTab.jsx | 2 +- .../src/components/OrgHeaderexpandedNew.jsx | 2 +- .../src/components/ShuffleCodeEditor1.jsx | 19 +- frontend/src/views/AngularWorkflow.jsx | 2 +- frontend/src/views/Workflows.jsx | 213 +++++++++--------- 7 files changed, 124 insertions(+), 124 deletions(-) diff --git a/frontend/src/components/EditOrgTab.jsx b/frontend/src/components/EditOrgTab.jsx index 6a5e1662..c1cd11fc 100644 --- a/frontend/src/components/EditOrgTab.jsx +++ b/frontend/src/components/EditOrgTab.jsx @@ -1,8 +1,8 @@ import React, { useEffect, useState, useContext } from 'react'; -import OrgHeaderexpanded from "./OrgHeaderexpandedNew.jsx"; -import OrgHeader from './OrgHeaderNew.jsx'; +import OrgHeaderexpanded from "../components/OrgHeaderexpandedNew.jsx"; +import OrgHeader from '../components/OrgHeaderNew.jsx'; import { toast } from "react-toastify"; -import CloudSyncTab from './CloudSyncTab.jsx'; +import CloudSyncTab from '../components/CloudSyncTab.jsx'; import { FileCopy as FileCopyIcon, } from "@mui/icons-material"; @@ -443,4 +443,4 @@ If you're interested, please let me know a time that works for you, or set up a ) } -export default EditOrgTab; \ No newline at end of file +export default EditOrgTab; diff --git a/frontend/src/components/EditWorkflow.jsx b/frontend/src/components/EditWorkflow.jsx index a1687fc1..b67bde93 100644 --- a/frontend/src/components/EditWorkflow.jsx +++ b/frontend/src/components/EditWorkflow.jsx @@ -579,7 +579,7 @@ const EditWorkflow = (props) => { - Multi-Tenant Workflows. Make one workflow, and keep a separate, synced copy in all your tenants. Control distributed auth, runtime locations, files, datastore keys etc. (late beta - contact support@shuffler.io if you want a demo. Please try it!) + Multi-Tenant Workflows. Make one workflow, and keep a separate, synced copy in all your tenants. Control distributed auth, runtime locations, files, datastore keys etc. (contact support@shuffler.io if you want a demo. Please try it!) {userdata !== undefined && userdata !== null && userdata.orgs !== undefined && userdata.orgs !== null && userdata.orgs.length > 0 ? diff --git a/frontend/src/components/EnvironmentTab.jsx b/frontend/src/components/EnvironmentTab.jsx index 22a05f18..cd0a9416 100644 --- a/frontend/src/components/EnvironmentTab.jsx +++ b/frontend/src/components/EnvironmentTab.jsx @@ -421,7 +421,7 @@ const EnvironmentTab = memo((props) => { -e AUTH="${auth}" \\ -e ENVIRONMENT_NAME="${environment.Name}" \\ -e ORG="${environment.org_id}" \\ - -e SHUFFLE_WORKER_IMAGE="ghcr.io/shuffle/shuffle-worker:nightly" \\ + -e SHUFFLE_WORKER_IMAGE="ghcr.io/shuffle/shuffle-worker:latest" \\ -e SHUFFLE_SWARM_CONFIG=run \\ -e SHUFFLE_LOGS_DISABLED=true \\ -e BASE_URL="${newUrl}" \\${addProxy ? ` diff --git a/frontend/src/components/OrgHeaderexpandedNew.jsx b/frontend/src/components/OrgHeaderexpandedNew.jsx index a6616269..9a3cda99 100644 --- a/frontend/src/components/OrgHeaderexpandedNew.jsx +++ b/frontend/src/components/OrgHeaderexpandedNew.jsx @@ -549,7 +549,7 @@ const OrgHeaderexpandedNew = (props) => { {isCloud ? (
- Region + Change Region
) : null} diff --git a/frontend/src/components/ShuffleCodeEditor1.jsx b/frontend/src/components/ShuffleCodeEditor1.jsx index 182346ae..1f713c5a 100644 --- a/frontend/src/components/ShuffleCodeEditor1.jsx +++ b/frontend/src/components/ShuffleCodeEditor1.jsx @@ -657,6 +657,7 @@ const CodeEditor = (props) => { } if (!inputvariable.includes(".")) { + inputvariable = inputvariable.toLowerCase() return inputvariable } @@ -665,6 +666,9 @@ const CodeEditor = (props) => { var removedIndexes = 0 for (var key in itemsplit) { var tmpitem = itemsplit[key] + if (key == 0) { + tmpitem = tmpitem.toLowerCase() + } // Makes sure #0 and # are same, as we only visualize first one anyway if (tmpitem.startsWith("#")) { @@ -695,20 +699,24 @@ const CodeEditor = (props) => { var variable_occurence = current_code_line.match(/[\\]{0,1}[$]{1}([a-zA-Z0-9_@-]+\.?){1}([a-zA-Z0-9#_@-]+\.?){0,}/g) if (!variable_occurence) { - continue; + continue } - var new_occurences = variable_occurence.filter((occurrence) => occurrence[0]); - variable_occurence = new_occurences + //var new_occurences = variable_occurence.filter((occurrence) => occurrence[0]); + //variable_occurence = new_occurences + variable_occurence = variable_occurence.filter((occurrence) => occurrence[0]); + + // Checks code lines, not variable occurences. Then remaps later var dollar_occurence = []; for (let ch = 0; ch < current_code_line.length; ch++) { //if (current_code_line[ch] === '$' && (ch === 0)) { if (current_code_line[ch] === '$') { - dollar_occurence.push(ch); + dollar_occurence.push(ch) } } + // Lowercase anything between the $ and first . var dollar_occurence_len = [] try { for (let occ = 0; occ < variable_occurence.length; occ++) { @@ -1005,7 +1013,6 @@ const CodeEditor = (props) => { // Replace quotes with nothing } else { - console.log("NO TYPE? ", typeof new_input) try { new_input = new_input.toString() } catch (e) { @@ -1897,7 +1904,7 @@ const CodeEditor = (props) => { overflow: "hidden", }} onClick={() => { - console.log(innerdata.example) + //console.log(innerdata.example) //const handleClick = (item) => { handleItemClick([innerdata]); diff --git a/frontend/src/views/AngularWorkflow.jsx b/frontend/src/views/AngularWorkflow.jsx index 91146f9f..3904b15f 100755 --- a/frontend/src/views/AngularWorkflow.jsx +++ b/frontend/src/views/AngularWorkflow.jsx @@ -13457,7 +13457,7 @@ const AngularWorkflow = (defaultprops) => { Shuffle AI - What you write here will be fed to the Shuffle AI to generate a change for the selected action or field. Best used for when you are stuck with formatting. Uses your AI credits (resets monthly). Alpha feature. Please give feedback to support@shuffler.io {"<"}3 + What you write here will be fed to the Shuffle AI to generate a change for the selected action or field. Best used for when you are stuck with formatting. Uses your AI credits (resets monthly). Beta feature. Please give feedback to support@shuffler.io {"<"}3 { } export const validateJson = (showResult) => { - if (showResult === undefined || showResult === null) { - return { - valid: false, - result: "", - } - } + if (showResult === undefined || showResult === null) { + return { + valid: false, + result: "", + } + } - if (typeof showResult === 'string') { - showResult = showResult.split(" False").join(" false") - showResult = showResult.split(" True").join(" true") + if (typeof showResult === 'string') { + showResult = showResult.split(" False").join(" false") + showResult = showResult.split(" True").join(" true") - showResult.replaceAll("False,", "false,") - showResult.replaceAll("True,", "true,") - } + showResult.replaceAll("False,", "false,") + showResult.replaceAll("True,", "true,") + } - if (typeof showResult === "object" || typeof showResult === "array") { - return { - valid: true, - result: showResult, - } - } + if (typeof showResult === "object" || typeof showResult === "array") { + return { + valid: true, + result: showResult, + } + } - if (showResult[0] === "\"") { - return { - valid: false, - result: showResult, - } - } + if (showResult[0] === "\"") { + return { + valid: false, + result: showResult, + } + } var jsonvalid = true try { if (!showResult.includes("{") && !showResult.includes("[")) { jsonvalid = false - return { - valid: jsonvalid, - result: showResult, - }; + return { + valid: jsonvalid, + result: showResult, + }; } } catch (e) { @@ -509,102 +509,94 @@ export const validateJson = (showResult) => { var result = showResult; try { - result = jsonvalid ? JSON.parse(showResult, { "storeAsString": true }) : showResult; + result = jsonvalid ? JSON.parse(showResult, {"storeAsString": true}) : showResult; } catch (e) { ////console.log("Failed parsing JSON even though its valid: ", e) jsonvalid = false; } - if (jsonvalid === false) { + if (jsonvalid === false) { - if (typeof showResult === 'string') { - showResult = showResult.trim() - } - - try { - var newstr = showResult.replaceAll("'", '"') - - // Basic workarounds for issues with Python Dicts -> JSON - if (newstr.includes(": None")) { - newstr = newstr.replaceAll(": None", ': null') - } - - if (newstr.includes("[\"{") && newstr.includes("}\"]")) { - newstr = newstr.replaceAll("[\"{", '[{') - newstr = newstr.replaceAll("}\"]", '}]') - } - - if (newstr.includes("{\"[") && newstr.includes("]\"}")) { - newstr = newstr.replaceAll("{\"[", '[{') - newstr = newstr.replaceAll("]\"}", '}]') - } - - result = JSON.parse(newstr) - jsonvalid = true - } catch (e) { - - //console.log("Failed parsing JSON even though its valid (2): ", e) - jsonvalid = false - } - } - - if (jsonvalid && typeof result === "number") { - jsonvalid = false - } - - // This is where we start recursing - if (jsonvalid) { - // Check fields if they can be parsed too - try { - for (const [key, value] of Object.entries(result)) { - if (typeof value === "string") { - value = value.replaceAll(" ", "_") + if (typeof showResult === 'string') { + showResult = showResult.trim() } - if (typeof value === "string" && (value.startsWith("{") || value.startsWith("["))) { - //console.log("CHECKING STRING: ", value) + try { + var newstr = showResult.replaceAll("'", '"') - const inside_result = validateJson(value) - if (inside_result.valid) { - //console.log("INSIDE RESULT: ", inside_result.result) + // Basic workarounds for issues with Python Dicts -> JSON + if (newstr.includes(": None")) { + newstr = newstr.replaceAll(": None", ': null') + } - if (typeof inside_result.result === "string") { - const newres = JSON.parse(inside_result.result) + if (newstr.includes("[\"{") && newstr.includes("}\"]")) { + newstr = newstr.replaceAll("[\"{", '[{') + newstr = newstr.replaceAll("}\"]", '}]') + } - result[key] = newres - } else { - result[key] = inside_result.result - } - } - } else { + if (newstr.includes("{\"[") && newstr.includes("]\"}")) { + newstr = newstr.replaceAll("{\"[", '[{') + newstr = newstr.replaceAll("]\"}", '}]') + } - // Usually only reaches here if raw array > dict > value - if (typeof showResult !== "array") { - for (const [subkey, subvalue] of Object.entries(value)) { - if (typeof subvalue === "string") { - subvalue = subvalue.replaceAll(" ", "_") - } + result = JSON.parse(newstr) + jsonvalid = true + } catch (e) { - if (typeof subvalue === "string" && (subvalue.startsWith("{") || subvalue.startsWith("["))) { - const inside_result = validateJson(subvalue) - if (inside_result.valid) { - if (typeof inside_result.result === "string") { - const newres = JSON.parse(inside_result.result) - result[key][subkey] = newres - } else { - result[key][subkey] = inside_result.result - } - } - } + //console.log("Failed parsing JSON even though its valid (2): ", e) + jsonvalid = false + } + } - } - } - } - } - } catch (e) { - //console.log("Failed parsing inside json subvalues: ", e) - } - } + if (jsonvalid && typeof result === "number") { + jsonvalid = false + } + + // This is where we start recursing + if (jsonvalid) { + // Check fields if they can be parsed too + try { + for (const [key, value] of Object.entries(result)) { + if (typeof value === "string" && (value.startsWith("{") || value.startsWith("["))) { + //console.log("CHECKING STRING: ", value) + + const inside_result = validateJson(value) + if (inside_result.valid) { + //console.log("INSIDE RESULT: ", inside_result.result) + + if (typeof inside_result.result === "string") { + const newres = JSON.parse(inside_result.result) + + result[key] = newres + } else { + result[key] = inside_result.result + } + } + } else { + + // Usually only reaches here if raw array > dict > value + if (typeof showResult !== "array") { + for (const [subkey, subvalue] of Object.entries(value)) { + if (typeof subvalue === "string" && (subvalue.startsWith("{") || subvalue.startsWith("["))) { + const inside_result = validateJson(subvalue) + if (inside_result.valid) { + if (typeof inside_result.result === "string") { + const newres = JSON.parse(inside_result.result) + result[key][subkey] = newres + } else { + result[key][subkey] = inside_result.result + } + } + } + + } + } + } + } + } catch (e) { + //console.log("Failed parsing inside json subvalues: ", e) + } + } return { valid: jsonvalid, @@ -612,6 +604,7 @@ export const validateJson = (showResult) => { }; }; + //Custom hook for handling styling of the dropzone const useDropzoneStyles = () => { const { leftSideBarOpenByClick } = useContext(Context);