@@ -9,7 +9,7 @@ import { makeStyles, } from "@mui/styles";
import WorkflowTemplatePopup from "../components/WorkflowTemplatePopup.jsx"
import { v4 as uuidv4 } from "uuid" ;
import { useNavigate , Link , useParams } from "react-router-dom" ;
import { useBeforeunload } from "react-beforeunload" ;
import { useBeforeunload } from "react-beforeunload"
import ReactJson from "react-json-view" ;
import { NestedMenuItem } from 'mui-nested-menu' ;
import Markdown from "react-markdown" ;
@@ -642,6 +642,72 @@ const AngularWorkflow = (defaultprops) => {
"field_id" : "" ,
} )
const [ loadedApps , setLoadedApps ] = React . useState ( [ ] )
const loadAppConfig = ( appId , select ) => {
if ( appId === undefined || appId === null || appId . length === 0 ) {
return
}
if ( loadedApps . includes ( appId ) ) {
return
}
loadedApps . push ( appId )
setLoadedApps ( loadedApps )
const appUrl = ` ${ globalUrl } /api/v1/apps/ ${ appId } /config?openapi=false `
fetch ( appUrl , {
headers : {
Accept : "application/json" ,
} ,
credentials : "include" ,
} )
. then ( ( response ) => {
return response . json ( )
} )
. then ( ( responseJson ) => {
console . log ( "Loaded app config: " , responseJson )
if ( responseJson . success === true && responseJson . app !== undefined && responseJson . app !== null && responseJson . app . length > 0 ) {
/ / B a s e 6 4 d e c o d e i n t o j s o n
const foundapp = JSON . parse ( atob ( responseJson . app ) )
console . log ( "Checked app: " , foundapp )
const selectedAppActions = selectedApp . actions === undefined || selectedApp . actions === null ? [ ] : selectedApp . actions
if ( foundapp . actions !== undefined && foundapp . actions !== null && foundapp . actions . length > selectedAppActions . length ) {
if ( select ) {
setSelectedApp ( foundapp )
}
if ( apps === undefined || apps === null || apps . length === 0 ) {
console . log ( "LOAD APPS!" )
}
for ( var i = 0 ; i < apps . length ; i ++ ) {
if ( apps [ i ] . id !== foundapp . id ) {
continue
}
apps [ i ] = foundapp
setApps ( apps )
setFilteredApps ( apps )
/ / U p d a t e t h e l o c a l s t o r a g e
localStorage . setItem ( "apps" , JSON . stringify ( apps ) )
break
}
}
/ / F I X M E : A d d i t t o t h e e x i s t i n g l i s t A N D u p d a t e t h e s e l e c t e d a p p
}
} )
. catch ( ( error ) => {
console . log ( ` Failed side-loading app ${ appId } : ${ error } ` )
} )
}
/ / E v e n t f o r m a k i n g s u r e a p p i s c o r r e c t
useEffect ( ( ) => {
if ( selectedApp === undefined || selectedApp === null && selectedApp . app _name === undefined ) {
@@ -657,45 +723,7 @@ const AngularWorkflow = (defaultprops) => {
return
} else {
if ( selectedApp . id !== undefined && selectedApp . id !== null && selectedApp . id . length > 0 ) {
const appUrl = ` ${ globalUrl } /api/v1/apps/ ${ selectedApp . id } /config?openapi=false `
fetch ( appUrl , {
headers : {
Accept : "application/json" ,
} ,
credentials : "include" ,
} )
. then ( ( response ) => {
return response . json ( )
} )
. then ( ( responseJson ) => {
if ( responseJson . success === true && responseJson . app !== undefined && responseJson . app !== null && responseJson . app . length > 0 ) {
/ / B a s e 6 4 d e c o d e i n t o j s o n
const foundapp = JSON . parse ( atob ( responseJson . app ) )
if ( foundapp . actions !== undefined && foundapp . actions !== null && foundapp . actions . length > selectedApp . actions . length ) {
setSelectedApp ( foundapp )
for ( var i = 0 ; i < apps . length ; i ++ ) {
if ( apps [ i ] . id !== foundapp . id ) {
continue
}
apps [ i ] = foundapp
setApps ( apps )
setFilteredApps ( apps )
/ / U p d a t e t h e l o c a l s t o r a g e
localStorage . setItem ( "apps" , JSON . stringify ( apps ) )
break
}
}
/ / F I X M E : A d d i t t o t h e e x i s t i n g l i s t A N D u p d a t e t h e s e l e c t e d a p p
}
} )
. catch ( ( error ) => {
console . log ( ` Failed side-loading app ${ selectedApp . name } ` )
} )
loadAppConfig ( selectedApp . id , true )
}
}
@@ -705,7 +733,6 @@ const AngularWorkflow = (defaultprops) => {
continue
}
console . log ( "Found app: " , curapp )
if ( curapp . actions !== undefined && curapp . actions !== null && curapp . actions . length > selectedApp . actions . length ) {
var foundActionIndex = - 1
for ( let actionkey in curapp . actions ) {
@@ -1128,6 +1155,8 @@ const AngularWorkflow = (defaultprops) => {
"autoClose" : false ,
} )
} else {
if ( refresh === true ) {
getAppAuthentication ( true , true , true )
@@ -1138,6 +1167,13 @@ const AngularWorkflow = (defaultprops) => {
setAuthenticationModalOpen ( false )
/ / N e e d s a r e f r e s h w i t h t h e n e w a u t h e n t i c a t i o n . .
/ / t o a s t ( " S u c c e s s f u l l y s a v e d n e w a p p a u t h " )
if ( configureWorkflowModalOpen === true ) {
setConfigureWorkflowModalOpen ( false )
setTimeout ( ( ) => {
setConfigureWorkflowModalOpen ( true )
} , 1000 )
}
}
} )
. catch ( ( error ) => {
@@ -1179,7 +1215,6 @@ const AngularWorkflow = (defaultprops) => {
if ( tmpView !== undefined && tmpView !== null && tmpView . length > 0 ) {
/ / D o n ' t c l e a n u p i f i t ' s a l r e a d y o p e n
if ( executionModalOpen === true ) {
console . log ( "Execution modal already open, not cleaning up" )
return
}
@@ -3221,8 +3256,9 @@ const AngularWorkflow = (defaultprops) => {
responseJson . errors . length > 0
) {
console . log ( "Setting configure Modal to open" )
setConfigureWorkflowModalOpen ( true ) ;
}
setConfigureWorkflowModalOpen ( true )
}
}
} )
@@ -3777,8 +3813,21 @@ const AngularWorkflow = (defaultprops) => {
if ( data . buttonType == "ACTIONSUGGESTION" ) {
const attachedToId = data . attachedTo
const parentitem = cy . getElementById ( data . attachedTo ) . data ( )
const parentitemRaw = cy . getElementById ( data . attachedTo )
const parentitem = parentitemRaw . data ( )
if ( parentitem !== null && parentitem !== undefined ) {
setTimeout ( ( ) => {
parentitemRaw . select ( )
const allNodes = cy . nodes ( ) . jsons ( )
for ( var _key in allNodes ) {
const currentNode = allNodes [ _key ]
if ( currentNode . data . buttonType === "ACTIONSUGGESTION" ) {
cy . getElementById ( currentNode . data . id ) . remove ( )
}
}
} , 100 )
const findaction = data . label
console . log ( "CLICKED: " , findaction , apps . length )
@@ -4262,20 +4311,31 @@ const AngularWorkflow = (defaultprops) => {
curaction . app _id = curapp . id
setAuthenticationType (
curapp . authentication . type === "oauth2-app" || ( curapp . authentication . type === "oauth2" && curapp . authentication . redirect _uri !== undefined && curapp . authentication . redirect _uri !== null ) ? {
type : curapp . authentication . type ,
redirect _uri : curapp . authentication . redirect _uri ,
refresh _uri : curapp . authentication . refresh _uri ,
token _uri : curapp . authentication . token _uri ,
scope : curapp . authentication . scope ,
client _id : curapp . authentication . client _id ,
client _secret : curapp . authentication . client _secret ,
grant _type : curapp . authentication . grant _type ,
} : {
type : "" ,
}
)
if ( curapp . authentication === undefined || curapp . authentication === null ) {
setAuthenticationType ( {
type : "" ,
} )
curapp . authentication = {
type : "" ,
required : false ,
}
} else {
setAuthenticationType (
curapp . authentication . type === "oauth2-app" || ( curapp . authentication . type === "oauth2" && curapp . authentication . redirect _uri !== undefined && curapp . authentication . redirect _uri !== null ) ? {
type : curapp . authentication . type ,
redirect _uri : curapp . authentication . redirect _uri ,
refresh _uri : curapp . authentication . refresh _uri ,
token _uri : curapp . authentication . token _uri ,
scope : curapp . authentication . scope ,
client _id : curapp . authentication . client _id ,
client _secret : curapp . authentication . client _secret ,
grant _type : curapp . authentication . grant _type ,
} : {
type : "" ,
}
)
}
const requiresAuth = curapp . authentication . required ; / / & & ( ( c u r a p p . a u t h e n t i c a t i o n . p a r a m e t e r s ! = = u n d e f i n e d & & c u r a p p . a u t h e n t i c a t i o n . p a r a m e t e r s ! = = n u l l ) | | ( c u r a p p . a u t h e n t i c a t i o n . t y p e = = = " o a u t h 2 " & & c u r a p p . a u t h e n t i c a t i o n . r e d i r e c t _ u r i ! = = u n d e f i n e d & & c u r a p p . a u t h e n t i c a t i o n . r e d i r e c t _ u r i ! = = n u l l ) )
setRequiresAuthentication ( requiresAuth ) ;
@@ -5855,15 +5915,15 @@ const AngularWorkflow = (defaultprops) => {
} ;
const addActionSuggestions = ( nodedata , event ) => {
console . log ( "App Action suggestions disabled for now " )
return
console . log ( "App Action suggestions being added " )
if ( nodedata . type !== "ACTION" ) {
return
}
var parentNode = cy . $ ( "#" + event . target . data ( "id" ) ) ;
if ( parentNode . data ( "isButton" ) || parentNode . data ( "buttonId" ) ) return ;
var parentNode = cy . $ ( "#" + event . target . data ( "id" ) )
if ( parentNode . data ( "isButton" ) || parentNode . data ( "buttonId" ) ) {
return
}
const px = parentNode . position ( "x" ) + 0 ;
const py = parentNode . position ( "y" ) + 100 ;
@@ -5887,6 +5947,8 @@ const AngularWorkflow = (defaultprops) => {
/ / 1 . F i n d t h e a p p
/ / 2 . L o o p t h e a p p s ' a c t i o n s
/ / 3 . F i n d a c t i o n s b a s e d o n c a t e g o r y l a b e l I F i t e x i s t s
console . log ( "Fidning app match for: " , parentname )
var added = 0
for ( let appKey in apps ) {
const curapp = apps [ appKey ]
@@ -5898,6 +5960,7 @@ const AngularWorkflow = (defaultprops) => {
continue
}
console . log ( "Found matching: " , curapp . name , parentname , curapp . actions . length )
for ( let actionKey in curapp . actions ) {
const curaction = curapp . actions [ actionKey ]
@@ -5907,6 +5970,7 @@ const AngularWorkflow = (defaultprops) => {
}
if ( curaction . category _label !== undefined && curaction . category _label !== null && curaction . category _label . length > 0 ) {
console . log ( "IN NODE ADD" )
cy . add ( {
group : "nodes" ,
@@ -5925,7 +5989,7 @@ const AngularWorkflow = (defaultprops) => {
} )
added += 1
if ( added >= 2 ) {
if ( added >= 3 ) {
break
}
}
@@ -6182,7 +6246,6 @@ const AngularWorkflow = (defaultprops) => {
cytoscapeElement . style . cursor = "pointer"
}
sendStreamRequest ( {
"item" : "node" ,
"type" : "hover" ,
@@ -6268,7 +6331,8 @@ const AngularWorkflow = (defaultprops) => {
for ( var _key in allNodes ) {
const currentNode = allNodes [ _key ] ;
/ / c o n s o l e . l o g ( " C U R R E N T N O D E : " , c u r r e n t N o d e )
if ( ( currentNode . data . isButton || currentNode . data . isSuggestion ) && currentNode . data . attachedTo !== nodedata . id ) {
if ( ( currentNode . data . buttonType === "ACTIONSUGGESTION" || currentNode . data . isButton || currentNode . data . isSuggestion ) && currentNode . data . attachedTo !== nodedata . id ) {
cy . getElementById ( currentNode . data . id ) . remove ( ) ;
}
@@ -6320,6 +6384,10 @@ const AngularWorkflow = (defaultprops) => {
/ / " c u r s o r " : " p o i n t e r " ,
}
if ( nodedata . buttonType === "ACTIONSUGGESTION" ) {
parsedStyle [ "font-size" ] = "18px"
}
const typeIds = cy . elements ( 'node:selected' ) . jsons ( ) ;
for ( var idkey in typeIds ) {
const item = typeIds [ idkey ]
@@ -7149,6 +7217,7 @@ const AngularWorkflow = (defaultprops) => {
cy . edgehandles ( {
handleNodes : ( el ) => {
if ( el . isNode ( ) &&
el . data ( "buttonType" ) != "ACTIONSUGGESTION" &&
! el . data ( "isButton" ) &&
! el . data ( "isDescriptor" ) &&
! el . data ( "isSuggestion" ) &&
@@ -8342,7 +8411,6 @@ const AngularWorkflow = (defaultprops) => {
newAppStyle . borderLeft = ` ${ pixelSize } solid ${ yellow } ` ;
}
return (
< Draggable
onDrag = { ( e ) => {
@@ -8361,8 +8429,17 @@ const AngularWorkflow = (defaultprops) => {
< Paper
square
style = { newAppStyle }
onMouseOver = { ( ) => {
setHover ( true ) ;
onMouseOver = { ( e ) => {
e . preventDefault ( )
e . stopPropagation ( )
setHover ( true )
if ( app . actions !== undefined && app . actions !== null && app . actions . length === 1 ) {
console . log ( "HOVERING: " , app . id )
loadAppConfig ( app . id , false )
}
} }
onMouseOut = { ( ) => {
setHover ( false ) ;
@@ -8784,6 +8861,7 @@ const AngularWorkflow = (defaultprops) => {
const CustomSearchBox = connectSearchBox ( SearchBox )
const CustomAppHits = connectHits ( AppHits )
var viewedApps = [ ]
return (
< div style = { appViewStyle } >
< div style = { { flex : "1" } } >
@@ -8839,6 +8917,12 @@ const AngularWorkflow = (defaultprops) => {
return null
}
if ( viewedApps . includes ( app . id ) ) {
return null
}
viewedApps . push ( app . id )
var extraMessage = ""
if ( index == 2 ) {
extraMessage = < div style = { { marginTop : 5 } } / >
@@ -14217,7 +14301,8 @@ const AngularWorkflow = (defaultprops) => {
right : 0 ,
left : isMobile ? 20 : leftBarSize + 20 ,
top : isMobile ? 30 : appBarSize + 20 ,
} ;
pointerEvents : "none" ,
}
@@ -14235,11 +14320,16 @@ const AngularWorkflow = (defaultprops) => {
return (
< div style = { topBarStyle } >
< div style = { { margin : "0px 10px 0px 10px" } } >
< div style = { {
margin : "0px 10px 0px 10px" ,
pointerEvents : "none" ,
} } >
< Breadcrumbs
aria - label = "breadcrumb"
separator = "› "
style = { { color : "white" } }
style = { {
color : "white"
} }
>
< Link
to = "/workflows"
@@ -14255,7 +14345,10 @@ const AngularWorkflow = (defaultprops) => {
Workflows
< / h2 >
< / Link >
< h2 style = { { margin : 0 } } > { workflow . name } < / h2 >
< h2 style = { {
margin : 0 ,
pointerEvents : "none" ,
} } > { workflow . name } < / h2 >
< / Breadcrumbs >
{ isCorrectOrg ? null :
@@ -14282,7 +14375,9 @@ const AngularWorkflow = (defaultprops) => {
if ( response . status !== 200 ) {
console . log ( "Error in response" ) ;
} else {
localStorage . setItem ( "apps" , [ ] )
localStorage . removeItem ( "apps" )
localStorage . removeItem ( "workflows" )
localStorage . removeItem ( "userinfo" )
}
return response . json ( ) ;
@@ -15939,7 +16034,6 @@ const AngularWorkflow = (defaultprops) => {
} ;
const handleReactJsonClipboard = ( copy ) => {
console . log ( "COPY: " , copy ) ;
const elementName = "copy_element_shuffle" ;
var copyText = document . getElementById ( elementName ) ;
@@ -17270,10 +17364,9 @@ const AngularWorkflow = (defaultprops) => {
? "red"
: yellow ;
const validate = ! codeModalOpen ? "" : validateJson ( selectedResult . result . trim ( ) ) ;
const validate = ! codeModalOpen ? "" : validateJson ( selectedResult . result . trim ( ) )
if ( validate . valid && typeof validate . result === "string" ) {
validate . result = JSON . parse ( validate . result ) ;
validate . result = JSON . parse ( validate . result )
}
const AppResultVariable = ( { data } ) => {
@@ -17381,7 +17474,6 @@ const AngularWorkflow = (defaultprops) => {
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 {
}
}
@@ -17405,10 +17497,19 @@ const AngularWorkflow = (defaultprops) => {
return "Authorization failed (403). The API user most likely doesn't have the correct permissions. Check the body of the result for more information."
}
if ( result . status === 404 ) {
return "The URL, or content of the URL is incorrect. Check it and try again."
}
if ( result . status === 400 ) {
return "The queries or data sent to the API is most likely wrong (400). Check the body of the result for more information."
}
if ( result . status === 200 || result . status === 201 || result . status === 204 ) {
return "It looks like the result was successful! If it didn't work, make sure to check if the body you are sending was correct."
}
/ / V a l i d a t e a n d c h e c k f o r n e w l i n e s
if ( result . success !== false ) {
@@ -17425,7 +17526,7 @@ const AngularWorkflow = (defaultprops) => {
}
}
return ""
/ / r e t u r n " "
}
@@ -17447,13 +17548,14 @@ const AngularWorkflow = (defaultprops) => {
return "Consider whether your Orborus environment can connect to a local IP or not."
}
if ( stringjson . includes ( "invalidurl" ) ) {
/ / I F c o u n t o f " h t t p " i s m o r e t h a n o n e , 1 , i t ' s p r o l l y i n v a l i d
var additionalinfo = ""
if ( stringjson . includes ( "http" ) && stringjson . match ( /http/g ) . length > 1 ) {
additionalinfo = "You may be using multiple 'http' in the URL. "
}
if ( stringjson . includes ( "connectionerror" ) ) {
if ( stringjson . includes ( "kms" ) ) {
return "KMS authentication failed. Check your notifications for more details."
}
return "Your URL is incorrect."
return "The URL is invalid. Change the URL to a valid one, and try again. " + additionalinfo
}
if ( stringjson . includes ( "result too large to handle" ) ) {
@@ -17469,6 +17571,15 @@ const AngularWorkflow = (defaultprops) => {
}
if ( stringjson . includes ( "connectionerror" ) ) {
if ( stringjson . includes ( "kms" ) ) {
return "KMS authentication failed. Check your notifications for more details."
}
return "The URL is incorrect, or Shuffle can't reach it. Set up a Shuffle Environment in the same VLAN, or whitelist Shuffle's IPs."
}
return ""
}
@@ -17706,7 +17817,7 @@ const AngularWorkflow = (defaultprops) => {
{ currentSuggestion . length > 0 ?
< div style = { { marginBottom : 5 } } >
< b style = { { color : "rgba(214,110,117)" , } } > Debug Info : < / b > { currentSuggestion }
< b style = { { color : "rgba(214,110,117)" , } } > Debug : < / b > { currentSuggestion }
< / div >
:
< div style = { { marginBottom : 5 } } >
@@ -18381,9 +18492,14 @@ const AngularWorkflow = (defaultprops) => {
selectedAction . authentication === undefined ||
selectedAction . authentication === null
) {
selectedAction . authentication = [ authenticationOption ] ;
selectedAction . authentication = [ authenticationOption ]
} else {
selectedAction . authentication . push ( authenticationOption ) ;
try {
selectedAction . authentication . push ( authenticationOption )
} catch ( e ) {
/ / c o n s o l e . l o g ( " E r r o r : " , e )
}
}
setSelectedAction ( selectedAction ) ;
@@ -19647,7 +19763,7 @@ const AngularWorkflow = (defaultprops) => {
}
}
const foundusecase . name === undefined || foundusecase . name === null || foundusecase . name === "" ? null :
const templatePopup = foundusecase . name === undefined || foundusecase . name === null || foundusecase . name === "" ? null :
< Slide direction = "down" in = { true } mountOnEnter unmountOnExit >
< div style = { { position : "fixed" , top : "10%" , left : "37%" , border : "1px solid rgba(255,255,255,0.3)" , backgroundColor : theme . palette . inputColor , borderRadius : theme . palette . borderRadius , display : "flex" , } } >
< WorkflowTemplatePopup
@@ -19665,7 +19781,7 @@ const AngularWorkflow = (defaultprops) => {
/ >
< / div >
< / Slide >
* /
* /
const loadedCheck =
isLoaded && workflowDone ? (