diff --git a/frontend/src/components/UsecaseSearch.jsx b/frontend/src/components/UsecaseSearch.jsx index e9edb0f4..d5d3acf2 100644 --- a/frontend/src/components/UsecaseSearch.jsx +++ b/frontend/src/components/UsecaseSearch.jsx @@ -27,7 +27,7 @@ import { Divider, } from "@material-ui/core"; -const defaultValue = {"id": "", "name": "", +const defaultValue = {"id": "", "name": "Build your own", "source": {"text": "No trigger selected", "error": ""}, "destination": {"text": "No subflow selected", "error": ""}, "middle": [] @@ -284,7 +284,7 @@ export const subflows = [ ] const UsecaseSearch = (props) => { - const { defaultSearch, appFramework, globalUrl, showTitle, canExpand, apps, setFoundWorkflowId, getFramework, userdata, usecaseSearch, setUsecaseSearch, autotry, setCloseWindow, } = props + const { defaultSearch, appFramework, globalUrl, showTitle, canExpand, apps, setFoundWorkflowId, getFramework, userdata, usecaseSearch, setUsecaseSearch, autotry, setCloseWindow, sourceapp, destinationapp} = props const [allusecases, setAllUsecases] = React.useState([ @@ -371,21 +371,18 @@ const UsecaseSearch = (props) => { setUpdate(Math.random()) } } else { - console.log("NOT FOUND FOR: ", defaultSearch) setAllUsecases([JSON.parse(JSON.stringify(defaultValue))]) setUpdate(Math.random()) } } if (defaultSearch !== undefined && defaultSearch !== null && defaultSearch !== searchType) { - console.log("Setting searchtype to", defaultSearch) - - setSearchType(defaultSearch) setUsecaseIndex(0) rerunWorkflowCheck(defaultSearch, usecaseSearch) } + //if (defaultSearch !== undefined && defaultSearch.length > 0 && allusecases[usecaseIndex].name === "") { // rerunWorkflowCheck() //} @@ -442,10 +439,10 @@ const UsecaseSearch = (props) => { var usecases = JSON.parse(JSON.stringify(allusecases)) const imagestyle = { - height: 50, - width: 50, + height: 40, + width: 40, borderRadius: 25, - border: "1px solid rgba(255,255,255,0.3)", + border: "1px solid rgba(255,255,255,0.7)", cursor: "pointer", } @@ -869,8 +866,8 @@ const UsecaseSearch = (props) => { } const mergeWorkflowUsecases = (usecasedata) => { - //const url = `${globalUrl}/api/v1/workflows/merge`; - const url = `https://shuffler.io/api/v1/workflows/merge`; + // To properly handle multiple-locations + const url = isCloud ? `${globalUrl}/api/v1/workflows/merge` : `https://shuffler.io/api/v1/workflows/merge`; fetch(url, { mode: "cors", method: "POST", @@ -981,7 +978,6 @@ const UsecaseSearch = (props) => { } else if (isCloud) { if (responseJson.workflow_id !== null && responseJson.workflow_id !== undefined) { if (responseJson.added_auth !== undefined && responseJson.added_auth !== null && responseJson.added_auth.length > 0) { - console.log("SHOULD HANDLE AUTH: ", responseJson.added_auth) setConfigureWorkflowAuth(responseJson.added_auth) if (setFoundWorkflowId !== undefined) { @@ -1021,7 +1017,11 @@ const UsecaseSearch = (props) => { }); } - //console.log("Filled in: ", appFramework, usecases) + // Autosearch in framework & set it? + if (sourceapp !== undefined && destinationapp !== undefined) { + console.log("FIND APPS", sourceapp, destinationapp) + } + if (appFramework !== undefined && usecases !== undefined) { for (var key in usecases) { @@ -1180,10 +1180,10 @@ const UsecaseSearch = (props) => { mergeWorkflowUsecases(data) } - if (autotry === true && firstRequest === true) { - console.log("Should autotry the usecase! Make sure data is in order first. Usecase: ", usecases) + if (autotry === true && firstRequest === true && appFramework !== undefined && usecases !== undefined && isUploading === false) { + console.log("Should autotry the usecase! Make sure data is in order first. Usecase: ", usecases) - if (usecases !== undefined && usecases !== null && usecases.length > 0 && usecases[0].name !== "") { + if (usecases !== undefined && usecases !== null && usecases.length > 0 && usecases[0].name !== "Build your own" && usecases[0].name !== "") { setFirstRequest(false) createWorkflowFromTemplate(usecases[0]) } @@ -1332,44 +1332,38 @@ const UsecaseSearch = (props) => { const looplist = type === "source" ? triggerlist : type === "destination" ? subflows : midflows const hasError = data.error !== undefined && data.error !== null && data.error.length > 0 const borderColor = hasError ? theme.palette.primary.main : "rgba(255,255,255,0.3)" + const startText = miditem ? "" : type === "source" ? "When" : "Then" + + if (data.text.includes(startText)) { + data.text = data.text.replace(startText, "") + } return ( -
+
+ + {startText} + +
- {selectionOpen === true ? - - : null} + {selectionOpen === true ? + + : null} -
-
- - {data.app_name} { +
+
+ + {data.app_name} { - if (data.type === undefined || data.type === null || data.type === "") { - setexpanded(true) - console.log("No type. Skipping window open.") - return - } - - changeAppType() - }}/> - -
- - {data.text} - - {hasError ? - { if (data.type === undefined || data.type === null || data.type === "") { setexpanded(true) console.log("No type. Skipping window open.") @@ -1377,140 +1371,161 @@ const UsecaseSearch = (props) => { } changeAppType() - }}> - {data.error} + }}/> + +
+ + {data.text} - : - null} + {hasError ? + { + if (data.type === undefined || data.type === null || data.type === "") { + setexpanded(true) + console.log("No type. Skipping window open.") + return + } + + changeAppType() + }}> + {data.error} + + : + null} +
+
+
+ + + { + }} + > + + + + + + + + + {type === "middle" ? + { + allusecases[index][type] = [] + + setAllUsecases(allusecases) + setUpdate(Math.random()) + }} + style={{marginTop: 0, paddingTop: 8,}} + > + + + : null} + + + { + setexpanded(!expanded) + }} + > + {expanded ? : } + + +
-
- - - { - }} - > - - - - - - - - - {type === "middle" ? - { - allusecases[index][type] = [] + + {expanded ? + looplist.map((subdata, curindex) => { + if (appFramework === undefined) { + subdata.image = theme.palette.defaultImage + } else { + const srctype = getType(subdata.type) + const srcinfo = appFramework[srctype] + + if (srcinfo !== undefined && srcinfo.large_image !== undefined && srcinfo.large_image !== "" && (subdata.app_name === undefined || subdata.app_name === "")) { + subdata.image = srcinfo.large_image + subdata.app_id = srcinfo.id + subdata.app_name = srcinfo.name + } else { + subdata.image = theme.palette.defaultImage + } + } + + return ( +
{ + if (subdata.disabled === true) { + //alert.info("Usecase not available yet.") + return + } + + if (type === "middle") { + allusecases[index][type][subindex] = subdata + } else { + allusecases[index][type] = subdata + } setAllUsecases(allusecases) setUpdate(Math.random()) - }} - > - - - : null} - - - { - setexpanded(!expanded) - }} - > - {expanded ? : } - - - -
+ setexpanded(false) + }}> + {subdata.app_name} { + }}/> + + {subdata.text} + +
+ ) + }) + : + null + }
- - {expanded ? - looplist.map((subdata, curindex) => { - if (appFramework === undefined) { - subdata.image = theme.palette.defaultImage - } else { - const srctype = getType(subdata.type) - const srcinfo = appFramework[srctype] - - if (srcinfo !== undefined && srcinfo.large_image !== undefined && srcinfo.large_image !== "" && (subdata.app_name === undefined || subdata.app_name === "")) { - subdata.image = srcinfo.large_image - subdata.app_id = srcinfo.id - subdata.app_name = srcinfo.name - } else { - subdata.image = theme.palette.defaultImage - } - } - - return ( -
{ - if (subdata.disabled === true) { - //alert.info("Usecase not available yet.") - return - } - - if (type === "middle") { - allusecases[index][type][subindex] = subdata - } else { - allusecases[index][type] = subdata - } - - setAllUsecases(allusecases) - setUpdate(Math.random()) - setexpanded(false) - }}> - {subdata.app_name} { - }}/> - - {subdata.text} - -
- ) - }) - : - null - }
) } //console.log("ALLUSECASES: ", allusecases) + // {defaultSearch}: {allusecases[usecaseIndex].name} + //console.log("UseCase: ", usecases) return ( -
+
{configureWorkflowModal} {authenticationModal} {showTitle !== false && defaultSearch !== undefined ? - {defaultSearch}: {allusecases[usecaseIndex].name} + {allusecases[usecaseIndex].name} : null} {usecases.map((data, index) => { return ( -
+
{data.middle !== undefined && data.middle !== null && data.middle.length > 0 ? @@ -1551,19 +1566,17 @@ const UsecaseSearch = (props) => { {showTitle !== false && workflow.id === undefined ? : null} @@ -1576,9 +1589,13 @@ const UsecaseSearch = (props) => { target="_blank" style={{ textDecoration: "none", }} > - }