Fixed workflow editing things

This commit is contained in:
Frikky
2024-06-21 15:12:40 +02:00
parent d83489dbe1
commit ad9743af10
5 changed files with 153 additions and 57 deletions
+44 -31
View File
@@ -338,26 +338,6 @@ const EditWorkflow = (props) => {
autoFocus
fullWidth
/>
<div style={{display: "flex", }}>
<TextField
onBlur={(event) => {
setDescription(event.target.value)
}}
InputProps={{
style: {
color: "white",
},
}}
maxRows={4}
color="primary"
defaultValue={innerWorkflow.description}
placeholder="Description"
multiline
label="Description"
margin="dense"
fullWidth
/>
</div>
<div style={{display: "flex", marginTop: 10, }}>
{usecases !== null && usecases !== undefined && usecases.length > 0 ?
<FormControl style={{flex: 1, marginRight: 5,}}>
@@ -425,27 +405,56 @@ const EditWorkflow = (props) => {
fullWidth
value={newWorkflowTags}
onChange={(chip) => {
console.log("Chip: ", chip)
//newWorkflowTags.push(chip);
setNewWorkflowTags(chip);
}}
onBlur={(event) => {
if (event.target.value.length === 0) {
return
}
if (newWorkflowTags.includes(event.target.value)) {
return
}
newWorkflowTags.push(event.target.value)
setNewWorkflowTags(newWorkflowTags)
setUpdate(Math.random())
}}
onAdd={(chip) => {
newWorkflowTags.push(chip);
setNewWorkflowTags(newWorkflowTags);
newWorkflowTags.push(chip)
setNewWorkflowTags(newWorkflowTags)
}}
onDelete={(chip, index) => {
console.log("Deleting: ", chip, index)
newWorkflowTags.splice(index, 1);
setNewWorkflowTags(newWorkflowTags);
setUpdate(Math.random());
newWorkflowTags.splice(index, 1)
setNewWorkflowTags(newWorkflowTags)
setUpdate(Math.random())
}}
/>
</div>
{showMoreClicked === true ?
<span style={{marginTop: 25, }}>
<div style={{marginTop: 50, }}>
<TextField
onBlur={(event) => {
setDescription(event.target.value)
}}
InputProps={{
style: {
color: "white",
},
}}
multiLine
rows={3}
color="primary"
defaultValue={innerWorkflow.description}
placeholder="Description"
multiline
label="Description"
margin="dense"
fullWidth
/>
<div style={{display: "flex"}}>
<FormControl style={{marginTop: 15, }}>
@@ -564,6 +573,8 @@ const EditWorkflow = (props) => {
fullWidth
/>
<Divider style={{marginTop: 20, marginBottom: 20, }} />
<Typography variant="body1" style={{marginTop: 50, }}>
MSSP Suborg Distribution (beta - contact support@shuffler.io for more info)
</Typography>
@@ -669,6 +680,7 @@ const EditWorkflow = (props) => {
</Link>
}
<Divider style={{marginTop: 20, marginBottom: 20, }} />
<Typography variant="h6" style={{marginTop: 50, }}>
Input fields
@@ -781,6 +793,7 @@ const EditWorkflow = (props) => {
<AddIcon style={{}} />
</Button>
<Divider style={{marginTop: 20, marginBottom: 20, }} />
<Typography variant="body1" style={{marginTop: 50, }}>
Git Backup Repository
@@ -931,7 +944,7 @@ const EditWorkflow = (props) => {
</span>
</Grid>
</Grid>
</span>
</div>
: null}
+6 -12
View File
@@ -471,32 +471,26 @@ const AuthenticationOauth2 = (props) => {
state += `%26refresh_uri%3d${authentication_url}`;
}
// No prompt forcing
//var url = `${authenticationType.redirect_uri}?client_id=${client_id}&redirect_uri=${redirectUri}&response_type=code&prompt=login&scope=${resources}&state=${state}&access_type=offline`;
// FIXME: Should this be =consent?
var defaultPrompt = "login"
if (prompt !== undefined && prompt !== null && prompt.length > 0) {
defaultPrompt = prompt
defaultPrompt = prompt
}
var url = `${authenticationType.redirect_uri}?client_id=${client_id}&redirect_uri=${redirectUri}&response_type=code&prompt=${defaultPrompt}&scope=${resources}&state=${state}&access_type=offline`;
if (admin_consent === true) {
console.log("Running Oauth2 WITH admin consent")
//url = `${authenticationType.redirect_uri}?client_id=${client_id}&redirect_uri=${redirectUri}&response_type=code&prompt=consent&scope=${resources}&state=${state}&access_type=offline`;
url = `${authenticationType.redirect_uri}?client_id=${client_id}&redirect_uri=${redirectUri}&response_type=code&prompt=admin_consent&scope=${resources}&state=${state}&access_type=offline`;
}
// Force new consent
console.log("OAUTH2 URL: ", url)
// Force new consent
//const url = `${authenticationType.redirect_uri}?client_id=${client_id}&redirect_uri=${redirectUri}&response_type=code&scope=${resources}&prompt=consent&state=${state}&access_type=offline`;
// Admin consent
// Admin consent
//const url = `https://accounts.zoho.com/oauth/v2/auth?response_type=code&client_id=${client_id}&scope=AaaServer.profile.Read&redirect_uri=${redirectUri}&prompt=consent`
// &resource=https%3A%2F%2Fgraph.microsoft.com&
// FIXME: Awful, but works for prototyping
// How can we get a callback properly realtime?
// How can we properly try-catch without breaks on error?
try {
var newwin = window.open(url, "", "width=582,height=700");
//console.log(newwin)
+1 -1
View File
@@ -3745,7 +3745,7 @@ If you're interested, please let me know a time that works for you, or set up a
aria-label="disabled tabs example"
>
<Tab label=<span>Edit Details</span> />
<Tab label=<span>Org Limits & Cloud Sync</span> />
<Tab label=<span>Limits & Cloud Sync</span> />
<Tab label=<span>Priorities</span> />
<Tab label=<span>Billing & Stats</span> />
<Tab disabled={!isCloud} label=<span>Branding (Beta)</span> />
+95 -7
View File
@@ -5294,7 +5294,59 @@ const releaseToConnectLabel = "Release to Connect"
}
setTimeout(() => {
setSelectedTriggerIndex(trigger_index);
if (trigger_index !== -1) {
const trigger = workflow.triggers[trigger_index]
if (trigger !== undefined && trigger !== null) {
// Autofixer
if (trigger.trigger_type === "USERINPUT") {
const relevantparams = [
"alertinfo",
"options",
"type",
"email",
"sms",
"subflow",
]
var foundparams = 0
for (var paramkey in trigger.parameters) {
if (relevantparams.includes(trigger.parameters[paramkey].name)) {
foundparams++
}
}
if (foundparams < 6) {
trigger.parameters = [{
name: "alertinfo",
value: "Do you want to continue the workflow? Start parameters: $exec",
},{
name: "options",
value: "boolean",
},
{
name: "type",
value: "subflow",
},
{
name: "email",
value: "test@test.com",
},
{
name: "sms",
value: "0000000",
},
{
name: "subflow",
value: "",
}]
workflow.triggers[trigger_index].parameters = trigger.parameters
}
}
}
}
setSelectedTriggerIndex(trigger_index)
setSelectedTrigger(data)
setSelectedActionEnvironment(data.env)
}, 25)
@@ -12382,7 +12434,7 @@ const releaseToConnectLabel = "Release to Connect"
setSubworkflow(e.target.value);
// Sets the startnode
if (e.target.value.id !== workflow.id) {
if (e.target.value.id !== workflow.id && e.target.value.id.length > 0 ) {
console.log("WORKFLOW: ", e.target.value);
const startnode = e.target.value.actions.find((action) => action.id === e.target.value.start);
@@ -14808,6 +14860,10 @@ const releaseToConnectLabel = "Release to Connect"
})
}
if (workflow.triggers !== undefined && workflow.triggers !== null && workflow.triggers.length > 0 && selectedTriggerIndex >= 0 && selectedTriggerIndex < workflow.triggers.length) {
console.log(workflow.triggers[selectedTriggerIndex])
}
const UserinputSidebar = Object.getOwnPropertyNames(selectedTrigger).length === 0 || workflow.triggers[selectedTriggerIndex] === undefined || selectedTrigger.trigger_type !== "USERINPUT" ? null :
<div style={appApiViewStyle}>
<h3 style={{ marginBottom: "5px" }}>
@@ -14994,7 +15050,12 @@ const releaseToConnectLabel = "Release to Connect"
const newname = (option.name.charAt(0).toUpperCase() + option.name.substring(1)).replaceAll("_", " ");
return newname;
}}
options={workflows}
options={
[{
"id": "",
"name": "No Workflow Selected",
}].concat(workflows)
}
fullWidth
style={{
backgroundColor: theme.palette.inputColor,
@@ -15149,14 +15210,40 @@ const releaseToConnectLabel = "Release to Connect"
</div>
<div style={{marginTop: 20, }} />
<div style={{marginTop: 0, }} />
<b>Enabled Input-Questions</b>
{workflow.input_questions !== undefined && workflow.input_questions !== null && workflow.input_questions.length > 0 ?
<div>
{workflow.input_questions.map((question, index) => {
var foundParamIndex = workflow.triggers[selectedTriggerIndex].parameters.findIndex((param) => param.name === "input_questions")
const selectionClick = () => {
console.log("Clicked input question: ", question)
console.log("PARAMS: ", workflow.triggers[selectedTriggerIndex].parameters)
if (foundParamIndex === -1) {
workflow.triggers[selectedTriggerIndex].parameters.push({
"name": "input_questions",
"value": [],
})
foundParamIndex = workflow.triggers[selectedTriggerIndex].parameters.length - 1
} else {
try {
workflow.triggers[selectedTriggerIndex].parameters[foundParamIndex].value = JSON.parse(workflow.triggers[selectedTriggerIndex].parameters[foundParamIndex].value)
} catch (e) {
console.log("Couldn't parse input questions: ", e)
workflow.triggers[selectedTriggerIndex].parameters[foundParamIndex].value = []
}
}
if (workflow.triggers[selectedTriggerIndex].parameters[foundParamIndex].value.includes(question.name)) {
workflow.triggers[selectedTriggerIndex].parameters[foundParamIndex].value = workflow.triggers[selectedTriggerIndex].parameters[foundParamIndex].value.filter((item) => item !== question.name)
} else {
workflow.triggers[selectedTriggerIndex].parameters[foundParamIndex].value.push(question.name)
}
// Make it back to a string
workflow.triggers[selectedTriggerIndex].parameters[foundParamIndex].value = JSON.stringify(workflow.triggers[selectedTriggerIndex].parameters[foundParamIndex].value)
setWorkflow(workflow)
setUpdate(Math.random())
}
return (
@@ -15164,7 +15251,7 @@ const releaseToConnectLabel = "Release to Connect"
selectionClick()
}}>
<Checkbox
checked={false}
checked={foundParamIndex !== -1 ? workflow.triggers[selectedTriggerIndex].parameters[foundParamIndex].value.includes(question.name) : false}
/>
<Typography variant="body2" style={{marginTop: 10, }}>
{question.name}
@@ -15176,6 +15263,7 @@ const releaseToConnectLabel = "Release to Connect"
:
<div style={{cursor: "pointer", color: "#f85a3e", marginTop: 10, }} onClick={() => {
setEditWorkflowModalOpen(true)
toast.info("Expand and scroll down to add input-questions")
}}>
<Typography variant="body2">No Input-Questions found. Click to add them!</Typography>
</div>
+7 -6
View File
@@ -1162,10 +1162,11 @@ const Workflows = (props) => {
})
.then((responseJson) => {
if (responseJson !== undefined) {
var newarray = []
for (var key in responseJson) {
const wf = responseJson[key]
if (wf.public === true) {
for (var wfkey in responseJson) {
const wf = responseJson[wfkey]
if (wf.public === true || wf.hidden === true) {
continue
}
@@ -1178,9 +1179,9 @@ const Workflows = (props) => {
var parsedactionlist = [];
for (var key in newarray) {
const workflow = newarray[key]
if (workflow.status === "production") {
setProdFilter = true
}
//if (workflow.status === "production") {
// setProdFilter = true
//}
for (var actionkey in newarray[key].actions) {
const action = newarray[key].actions[actionkey];