Minor fixes here and there
This commit is contained in:
@@ -249,6 +249,11 @@ const AppModal = ({ open, onClose, app, globalUrl, getApps }) => {
|
||||
}
|
||||
|
||||
const getUsecase = (subcase, index, subindex) => {
|
||||
//console.log("Skipping getUsecase")
|
||||
// FIXME: Skipping for now as this screws over a lot of the prioritization system
|
||||
// due to them having "looked at" the usecase.
|
||||
return
|
||||
|
||||
subcase = parseUsecase(subcase)
|
||||
setPrevSubcase(subcase)
|
||||
|
||||
@@ -490,8 +495,10 @@ const AppModal = ({ open, onClose, app, globalUrl, getApps }) => {
|
||||
}
|
||||
|
||||
|
||||
var canEditApp = userdata !== undefined && (userdata?.admin === "true" || userdata?.id === app?.owner || app?.owner === "" || (userdata?.admin === "true" && userdata?.active_org?.id === app?.reference_org)) || !app?.generated
|
||||
|
||||
var canEditApp = userdata?.support ||
|
||||
userdata?.id === app?.owner ||
|
||||
(userdata?.admin === "true" && userdata?.active_org?.id === app?.reference_org) ||
|
||||
app?.contributors?.includes(userdata?.id)
|
||||
return (
|
||||
<Dialog
|
||||
open={open}
|
||||
@@ -533,15 +540,22 @@ const AppModal = ({ open, onClose, app, globalUrl, getApps }) => {
|
||||
fontFamily: theme?.typography?.fontFamily
|
||||
}}
|
||||
>
|
||||
{/*
|
||||
<Typography component="div" sx={{ fontWeight: 500, color: "#F1F1F1", fontSize: "20px" }}>
|
||||
About {app?.name.replace(/_/g, ' ').replace(/\b\w/g, char => char.toUpperCase())}
|
||||
</Typography>
|
||||
*/}
|
||||
<IconButton
|
||||
onClick={onClose}
|
||||
sx={{
|
||||
color: 'rgba(255, 255, 255, 0.7)',
|
||||
'&:hover': { bgcolor: 'rgba(255, 255, 255, 0.1)' }
|
||||
}}
|
||||
style={{
|
||||
position: "absolute",
|
||||
top: 10,
|
||||
right: 10,
|
||||
}}
|
||||
>
|
||||
<CloseIcon />
|
||||
</IconButton>
|
||||
@@ -570,9 +584,11 @@ const AppModal = ({ open, onClose, app, globalUrl, getApps }) => {
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
}}>
|
||||
<Typography variant="h5" component="div" sx={{ fontWeight: 600 }}>
|
||||
{newAppname}
|
||||
</Typography>
|
||||
<a href={isCloud ? "/apps/" + (app?.id || app?.objectID) : `https://shuffler.io/apps/${app?.objectID || app?.id}`} target="_blank" rel="noopener noreferrer" style={{ textDecoration: "none", color: "rgba(255,255,255,0.9)", }}>
|
||||
<Typography variant="h5" component="div" sx={{ fontWeight: 600 }}>
|
||||
{newAppname}
|
||||
</Typography>
|
||||
</a>
|
||||
<Link
|
||||
to={isCloud ? "/apps/" + (app?.id || app?.objectID) : `https://shuffler.io/apps/${app?.objectID || app?.id}`}
|
||||
style={{ textDecoration: "none", color: "#f85a3e", marginTop: "-2px" }}
|
||||
@@ -663,6 +679,7 @@ const AppModal = ({ open, onClose, app, globalUrl, getApps }) => {
|
||||
</Tooltip>
|
||||
): null}
|
||||
|
||||
{(canEditApp && app?.generated) && (
|
||||
<Button
|
||||
variant="contained"
|
||||
sx={{
|
||||
@@ -676,10 +693,7 @@ const AppModal = ({ open, onClose, app, globalUrl, getApps }) => {
|
||||
color: "#fff",
|
||||
fontFamily: theme?.typography?.fontFamily
|
||||
}}
|
||||
startIcon={canEditApp ? <EditIcon /> :
|
||||
(app?.generated && app?.activated && userdata?.id !== app?.owner && isCloud ?
|
||||
<ForkRightIcon /> : null
|
||||
)}
|
||||
startIcon={canEditApp ? <EditIcon /> : <ForkRightIcon />}
|
||||
onClick={() => {
|
||||
if (canEditApp) {
|
||||
const editUrl = "/apps/edit/" + (app?.id || app?.objectID);
|
||||
@@ -690,8 +704,9 @@ const AppModal = ({ open, onClose, app, globalUrl, getApps }) => {
|
||||
}
|
||||
}}
|
||||
>
|
||||
{canEditApp ? "Edit" : "Fork"}
|
||||
</Button>
|
||||
{canEditApp ? "Edit" : "Fork"}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</Box>
|
||||
|
||||
@@ -812,13 +827,13 @@ const AppModal = ({ open, onClose, app, globalUrl, getApps }) => {
|
||||
marginBottom: "16px",
|
||||
fontWeight: 600
|
||||
}}>
|
||||
{
|
||||
{/*
|
||||
(foundAppUsecase?.srcapp !== undefined && foundAppUsecase?.dstapp !== undefined) ? (
|
||||
"Connect " + foundAppUsecase?.srcapp?.replaceAll("_", " ") + " to " + foundAppUsecase?.dstapp?.replaceAll("_", " ")
|
||||
) : (
|
||||
"Connect " + app?.name.replaceAll("_", " ") + " to any tool"
|
||||
)
|
||||
}
|
||||
*/}
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -830,7 +845,7 @@ const AppModal = ({ open, onClose, app, globalUrl, getApps }) => {
|
||||
alignItems: 'center',
|
||||
mb: 3
|
||||
}}>
|
||||
{usecaseLoading ? (
|
||||
{/*usecaseLoading ? (
|
||||
<Stack direction="row" spacing={2} alignItems="center" sx={{ width: '100%' }}>
|
||||
<Stack direction="row" spacing={-1}>
|
||||
<Skeleton variant="circular" width={32} height={32} />
|
||||
@@ -879,7 +894,7 @@ const AppModal = ({ open, onClose, app, globalUrl, getApps }) => {
|
||||
{foundAppUsecase?.name || "Search for a Usecase"}
|
||||
</Typography>
|
||||
</>
|
||||
)}
|
||||
)*/}
|
||||
</Box>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1467,15 +1467,23 @@ const ParsedAction = (props) => {
|
||||
actionname = "comms"
|
||||
}
|
||||
|
||||
if (isIntegration) {
|
||||
|
||||
if (isAgent || isIntegration) {
|
||||
// Check if actionname uppercase is in the parsedDatatypeImages() dictionary
|
||||
if (parsedDatatypeImages()[actionname.toUpperCase()] !== undefined) {
|
||||
var newimage = parsedDatatypeImages()[actionname.toUpperCase()]
|
||||
//newimage = <img src={newimage} style={{width: 35, height: 35, marginRight: 5, borderRadius: 5, cursor: "pointer", border: noAppSelected ? "3px solid #86c142" : "2px solid rgba(255,255,255,0.6)"}} />
|
||||
wrapperapp.large_image = newimage
|
||||
if (isAgent) {
|
||||
wrapperapp.large_image = theme.palette.singulBlackWhite
|
||||
newimage = wrapperapp.large_image
|
||||
} else if (isIntegration) {
|
||||
wrapperapp.large_image = theme.palette.singulGreen
|
||||
newimage = theme.palette.singulGreen
|
||||
} else {
|
||||
console.log("Couldn't find actionname: ", actionname)
|
||||
const uppercaseimage = parsedDatatypeImages()[actionname.toUpperCase()]
|
||||
if (uppercaseimage !== undefined) {
|
||||
var newimage = uppercaseimage
|
||||
//newimage = <img src={newimage} style={{width: 35, height: 35, marginRight: 5, borderRadius: 5, cursor: "pointer", border: noAppSelected ? "3px solid #86c142" : "2px solid rgba(255,255,255,0.6)"}} />
|
||||
wrapperapp.large_image = newimage
|
||||
} else {
|
||||
console.log("Couldn't find actionname: ", actionname)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1745,6 +1753,37 @@ const ParsedAction = (props) => {
|
||||
}
|
||||
</Tooltip>
|
||||
</IconButton>
|
||||
|
||||
{selectedAction?.generated === true && selectedAction?.app_version === "1.0.0" ?
|
||||
<Button
|
||||
variant="contained"
|
||||
color="secondary"
|
||||
style={{marginLeft: 30, textTransform: "none", }}
|
||||
onClick={() => {
|
||||
if (apps === null || apps === undefined || apps?.length === 0) {
|
||||
toast.error("No apps found. Please refresh the page.")
|
||||
return
|
||||
}
|
||||
|
||||
const app = apps.find((app) => app.id === selectedAction.app_id)
|
||||
if (app !== undefined && app !== null) {
|
||||
//setSelectedApp(app)
|
||||
if (app.app_version !== undefined && app.app_version !== null && app.app_version !== "1.0.0") {
|
||||
toast.info(`Upgraded to app version ${app.app_version}`)
|
||||
selectedAction.app_version = app.app_version
|
||||
setSelectedAction(selectedAction)
|
||||
setUpdate(Math.random())
|
||||
}
|
||||
} else {
|
||||
toast.error("No upgrade to be performed for this app. Expected version 1.1.0 available. App rebuild may be available.")
|
||||
}
|
||||
}}
|
||||
>
|
||||
|
||||
Upgrade
|
||||
</Button>
|
||||
: null}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div style={{ display: "flex", flexDirection: "column" }}>
|
||||
@@ -2764,6 +2803,7 @@ const ParsedAction = (props) => {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
const iconInfo = GetIconInfo(selectedAction)
|
||||
if (iconInfo !== undefined && iconInfo !== null) {
|
||||
selectedAction.fillGradient = iconInfo.fillGradient
|
||||
@@ -2771,6 +2811,7 @@ const ParsedAction = (props) => {
|
||||
selectedAction.iconBackground = iconInfo.iconBackgroundColor
|
||||
selectedAction.fillstyle = "linear-gradient"
|
||||
}
|
||||
*/
|
||||
|
||||
if (paramIndex === -1) {
|
||||
console.log("Couldn't find app_name parameter")
|
||||
@@ -2797,13 +2838,14 @@ const ParsedAction = (props) => {
|
||||
minHeight: 30,
|
||||
maxHeight: 30,
|
||||
|
||||
marginRight: 5,
|
||||
marginRight: 25,
|
||||
marginTop: isIntegration ? 3 : 0,
|
||||
borderRadius: 5,
|
||||
cursor: "pointer",
|
||||
border: noAppSelected ? "3px solid #86c142" : "2px solid rgba(255,255,255,0.6)",
|
||||
|
||||
paddingLeft: 5,
|
||||
paddingTop: 5,
|
||||
paddingLeft: isAgent || isIntegration ? 0 : 5,
|
||||
paddingTop: isAgent || isIntegration ? 0 : 5,
|
||||
}} />
|
||||
</div>
|
||||
</Tooltip>
|
||||
@@ -4579,7 +4621,7 @@ const ParsedAction = (props) => {
|
||||
}
|
||||
|
||||
//console.log("Required fields: ", selectedActionParameters[count])
|
||||
navigate(`?action_id=${selectedAction.id}&field=${data.name}&action_name=${selectedAction.name}`)
|
||||
navigate(`?action_id=${selectedAction.id}&field=${data.name}&action_name=${selectedAction.name}&app_name=${selectedAction?.label}`)
|
||||
setEditorData({
|
||||
"name": data.name,
|
||||
"value": fixExample(parsedvalue),
|
||||
|
||||
@@ -53,7 +53,7 @@ import PaperComponent from "../components/PaperComponent.jsx";
|
||||
|
||||
import { padding, textAlign } from '@mui/system';
|
||||
import data from '../frameworkStyle.jsx';
|
||||
import { useNavigate, Link, useParams } from "react-router-dom";
|
||||
import { useNavigate, Link, useParams, useSearchParams } from "react-router-dom";
|
||||
import { tags as t } from '@lezer/highlight';
|
||||
|
||||
|
||||
@@ -100,6 +100,7 @@ const pythonFilters = [
|
||||
const extensions = []
|
||||
const CodeEditor = (props) => {
|
||||
const {
|
||||
workflow,
|
||||
globalUrl,
|
||||
fieldCount,
|
||||
actionlist,
|
||||
@@ -107,13 +108,14 @@ const CodeEditor = (props) => {
|
||||
expansionModalOpen,
|
||||
setExpansionModalOpen,
|
||||
codedata,
|
||||
handleActionParamChange,
|
||||
setcodedata,
|
||||
isFileEditor,
|
||||
runUpdateText,
|
||||
toolsAppId,
|
||||
parameterName,
|
||||
selectedAction,
|
||||
selectedTrigger,
|
||||
// selectedAction,
|
||||
// selectedTrigger,
|
||||
workflowExecutions,
|
||||
getParents,
|
||||
activeDialog,
|
||||
@@ -145,7 +147,8 @@ const CodeEditor = (props) => {
|
||||
|
||||
const [currentCharacter, setCurrentCharacter] = React.useState(-1);
|
||||
const [currentLine, setCurrentLine] = React.useState(-1);
|
||||
|
||||
const [selectedAction, setSelectedAction] = React.useState({});
|
||||
const [selectedTrigger, setSelectedTrigger] = React.useState({});
|
||||
const [variableOccurences, setVariableOccurences] = React.useState([]);
|
||||
const [currentLocation, setCurrentLocation] = React.useState([]);
|
||||
const [currentVariable, setCurrentVariable] = React.useState("");
|
||||
@@ -187,6 +190,33 @@ const CodeEditor = (props) => {
|
||||
}, [localcodedata])
|
||||
|
||||
let navigate = useNavigate();
|
||||
const [searchParams] = useSearchParams();
|
||||
const actionId = searchParams.get('action_id');
|
||||
const appName = searchParams.get('app_name');
|
||||
const fieldName = searchParams.get('field');
|
||||
const triggerId = searchParams.get('trigger_id');
|
||||
const triggerField = searchParams.get('trigger_field');
|
||||
const triggerName = searchParams.get('trigger_name');
|
||||
|
||||
useEffect(() => {
|
||||
if (actionId === undefined || actionId === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const action = workflow?.actions?.find(action => action.id === actionId);
|
||||
setlocalcodedata(editorData?.value);
|
||||
setSelectedAction(action);
|
||||
}, [actionId, fieldName])
|
||||
|
||||
useEffect(() => {
|
||||
if (triggerId === undefined || triggerId === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const trigger = workflow?.triggers?.find(trigger => trigger.id === triggerId);
|
||||
setlocalcodedata(editorData?.value);
|
||||
setSelectedTrigger(trigger);
|
||||
}, [triggerId])
|
||||
|
||||
useEffect(() => {
|
||||
var allVariables = []
|
||||
@@ -1364,7 +1394,7 @@ const CodeEditor = (props) => {
|
||||
console.log("In closer")
|
||||
|
||||
if (changeActionParameterCodeMirror !== undefined) {
|
||||
changeActionParameterCodeMirror({ target: { value: "" } }, fieldCount, localcodedata)
|
||||
changeActionParameterCodeMirror({ target: { value: "" } }, fieldCount, localcodedata, selectedAction, setSelectedAction)
|
||||
} else {
|
||||
console.log("No action called changeActionParameterCodeMirror in code editor")
|
||||
}
|
||||
@@ -2120,7 +2150,7 @@ const CodeEditor = (props) => {
|
||||
>
|
||||
<div>
|
||||
<span style={{ color: "white" }}>
|
||||
{selectedAction === undefined ? "" : selectedAction.name === "execute_python" || selectedAction.name === "execute_bash" ? "Code to run" : `Output`}
|
||||
{actionId === null ? `Output : ${triggerName?.replaceAll("_", " ").slice(0, 1).toUpperCase() + triggerName?.replaceAll("_", " ").slice(1)}` : selectedAction.name === "execute_python" || selectedAction.name === "execute_bash" ? "Code to run" : `Output : ${appName?.replaceAll("_", " ").slice(0, 1).toUpperCase() + appName?.replaceAll("_", " ").slice(1)}(${fieldName})`}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -2134,12 +2164,28 @@ const CodeEditor = (props) => {
|
||||
disabled={executing}
|
||||
color="primary"
|
||||
style={{
|
||||
border: `1px solid ${theme.palette.primary.main}`,
|
||||
border: `1px solid rgba(255, 255, 255, 0.15)`,
|
||||
position: "absolute",
|
||||
top: 24,
|
||||
top: 20,
|
||||
right: 100,
|
||||
maxHeight: 35,
|
||||
minWidth: 70,
|
||||
zIndex: 1200,
|
||||
fontWeight: 500,
|
||||
fontSize: 14,
|
||||
backgroundColor: "rgba(33, 33, 33, 0.95)",
|
||||
backdropFilter: "blur(8px)",
|
||||
boxShadow: "0 4px 6px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.08)",
|
||||
transition: "all 0.2s ease",
|
||||
borderRadius: "4px",
|
||||
"&:hover": {
|
||||
backgroundColor: "rgba(45, 45, 45, 0.95)",
|
||||
transform: "translateY(-1px)",
|
||||
boxShadow: "0 7px 14px rgba(0, 0, 0, 0.12), 0 3px 6px rgba(0, 0, 0, 0.08)",
|
||||
},
|
||||
"&:active": {
|
||||
transform: "translateY(1px)",
|
||||
}
|
||||
}}
|
||||
onClick={() => {
|
||||
executeSingleAction(expOutput)
|
||||
@@ -2148,7 +2194,7 @@ const CodeEditor = (props) => {
|
||||
{executing ?
|
||||
<CircularProgress style={{ height: 18, width: 18, }} />
|
||||
:
|
||||
<span>{selectedAction === undefined ? "" : selectedAction.name === "execute_python" ? "Run Python Code" : selectedAction.name === "execute_bash" ? "Run Bash" : "Try it"}<PlayArrowIcon style={{ height: 18, width: 18, marginBottom: -4, marginLeft: 5, }} /> </span>
|
||||
<span>{selectedAction === undefined ? "Try it" : selectedAction.name === "execute_python" ? "Run Python Code" : selectedAction.name === "execute_bash" ? "Run Bash" : "Try it"}<PlayArrowIcon style={{ height: 18, width: 18, marginBottom: -4, marginLeft: 5, }} /> </span>
|
||||
}
|
||||
</Button>
|
||||
</Tooltip>
|
||||
@@ -2326,22 +2372,32 @@ const CodeEditor = (props) => {
|
||||
setExpansionModalOpen(false)
|
||||
} else if (changeActionParameterCodeMirror !== undefined) {
|
||||
//changeActionParameterCodeMirror(event, fieldCount, fixedcodedata)
|
||||
changeActionParameterCodeMirror(event, fieldCount, fixedcodedata, actionlist, parameterName)
|
||||
changeActionParameterCodeMirror(event, fieldCount, fixedcodedata, actionlist, parameterName, selectedAction, setSelectedAction)
|
||||
setExpansionModalOpen(false)
|
||||
setcodedata(fixedcodedata)
|
||||
}
|
||||
|
||||
// Check if fieldname is set, and try to find and inject the text
|
||||
if (fieldname !== undefined && fieldname !== null && fieldname.length > 0) {
|
||||
const foundfield = document.getElementById(fieldname)
|
||||
if (foundfield !== undefined && foundfield !== null) {
|
||||
foundfield.value = fixedcodedata
|
||||
if(selectedTrigger !== undefined && selectedTrigger !== null && selectedTrigger.name === "Shuffle Workflow") {
|
||||
handleSubflowParamChange(fixedcodedata)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//toast("No fieldname found: " + fieldname)
|
||||
// console.log("fieldname", fieldname)
|
||||
// // Check if fieldname is set, and try to find and inject the text
|
||||
// if (fieldname !== undefined && fieldname !== null && fieldname.length > 0) {
|
||||
// const foundfield = document.getElementById(fieldname)
|
||||
// console.log("foundfield", foundfield)
|
||||
// if (foundfield !== undefined && foundfield !== null) {
|
||||
// foundfield.value = fixedcodedata
|
||||
// if(selectedTrigger !== undefined && selectedTrigger !== null && selectedTrigger.name === "Shuffle Workflow") {
|
||||
// handleSubflowParamChange(fixedcodedata)
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// //toast("No fieldname found: " + fieldname)
|
||||
// }
|
||||
|
||||
if(actionId !== undefined && actionId !== null && actionId.length > 0) {
|
||||
handleActionParamChange(actionId, fieldName, fixedcodedata)
|
||||
}
|
||||
|
||||
if(triggerId !== undefined && triggerId !== null && triggerId.length > 0) {
|
||||
handleSubflowParamChange(triggerId, triggerField, fixedcodedata)
|
||||
}
|
||||
|
||||
setExpansionModalOpen(false)
|
||||
|
||||
Reference in New Issue
Block a user