Added new cloud fixes

This commit is contained in:
frikky
2023-07-06 17:58:35 +02:00
parent 9a0441813a
commit 4f38eecaa5
7 changed files with 169 additions and 151 deletions
+4 -2
View File
@@ -1390,7 +1390,7 @@ func handleExecution(id string, workflow shuffle.Workflow, request *http.Request
childNodes := shuffle.FindChildNodes(workflowExecution, workflowExecution.Start, []string{}, []string{})
topic := "workflows"
//topic := "workflows"
startFound := false
// FIXME - remove this?
newActions := []shuffle.Action{}
@@ -1708,6 +1708,7 @@ func handleExecution(id string, workflow shuffle.Workflow, request *http.Request
workflowExecution.Results = defaultResults
workflowExecution.Workflow.Actions = newActions
onpremExecution := true
_ = onpremExecution
environments := []string{}
if len(workflowExecution.ExecutionOrg) == 0 && len(workflow.ExecutingOrg.Id) > 0 {
@@ -1720,7 +1721,7 @@ func handleExecution(id string, workflow shuffle.Workflow, request *http.Request
allEnvironments, err := shuffle.GetEnvironments(ctx, workflowExecution.ExecutionOrg)
if err != nil {
log.Printf("Failed finding environments: %s", err)
log.Printf("[WARNING] Failed finding environments: %s", err)
return shuffle.WorkflowExecution{}, fmt.Sprintf("Workflow environments not found for this org"), errors.New(fmt.Sprintf("Workflow environments not found for this org"))
}
@@ -1744,6 +1745,7 @@ func handleExecution(id string, workflow shuffle.Workflow, request *http.Request
// Check if the actions are children of the startnode?
imageNames := []string{}
cloudExec := false
_ = cloudExec
for _, action := range workflowExecution.Workflow.Actions {
// Verify if the action environment exists and append
found := false
+5 -5
View File
@@ -68,7 +68,7 @@
"react-markdown-github": "^3.3.1",
"react-powerhooks": "0.0.7",
"react-router": "6.2.1",
"react-router-dom": "6.2.1",
"react-router-dom": "^6.14.1",
"react-scripts": "^4.0.1",
"react-shepherd": "^3.3.6",
"reactstrap": "^7.1.0",
@@ -104,11 +104,11 @@
"not op_mini all"
],
"devDependencies": {
"@babel/core": "^7.15.8",
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"babel-eslint": "^10.1.0",
"prettier": "2.4.1",
"promise-window": "^1.2.1",
"@babel/core": "^7.15.8",
"babel-eslint": "^10.1.0",
"webpack": "^4.44.2",
"@babel/plugin-proposal-private-property-in-object": "^7.21.11"
"webpack": "^4.44.2"
}
}
+157 -80
View File
@@ -41,18 +41,38 @@ import {
Visibility as VisibilityIcon,
VisibilityOff as VisibilityOffIcon,
} from "@material-ui/icons";
import data from "./frameworkStyle.jsx";
const scrollStyle1 = {
height: 100,
width: 225,
overflow: "hidden",
position: "relative",
}
const scrollStyle2 = {
position: "absolute",
top: 0,
left: 0,
bottom: "-20px",
right: "-20px",
overflow: "scroll",
}
const CacheView = (props) => {
const { globalUrl, userdata, serverside, orgId } = props;
const [orgCache, setOrgCache] = React.useState("");
const [listCache, setListCache] = React.useState([]);
const [addCache, setAddCache] = React.useState("");
const [editedCache, setEditedCache] = React.useState("");
const [modalOpen, setModalOpen] = React.useState(false);
const [key, setKey]= React.useState("");
const [value, setValue]= React.useState("");
const [cacheInput, setCacheInput]= React.useState("");
const [cacheCursor, setCacheCursor]= React.useState("");
const [key, setKey] = React.useState("");
const [value, setValue] = React.useState("");
const [cacheInput, setCacheInput] = React.useState("");
const [cacheCursor, setCacheCursor] = React.useState("");
const [dataValue, setDataValue] = React.useState({});
const [editCache, setEditCache] = React.useState(false);
const [show, setShow] = useState({});
const alert = useAlert();
useEffect(() => {
listOrgCache(orgId);
@@ -68,26 +88,26 @@ const CacheView = (props) => {
},
credentials: "include",
})
.then((response) => {
if (response.status !== 200) {
console.log("Status not 200 for apps :O!");
return;
}
.then((response) => {
if (response.status !== 200) {
console.log("Status not 200 for apps :O!");
return;
}
return response.json();
})
.then((responseJson) => {
if (responseJson.success === true) {
setListCache(responseJson.keys);
}
return response.json();
})
.then((responseJson) => {
if (responseJson.success === true) {
setListCache(responseJson.keys);
}
if (responseJson.cursor !== undefined && responseJson.cursor !== null && responseJson.cursor !== "") {
setCacheCursor(responseJson.cursor);
}
})
.catch((error) => {
alert.error(error.toString());
});
if (responseJson.cursor !== undefined && responseJson.cursor !== null && responseJson.cursor !== "") {
setCacheCursor(responseJson.cursor);
}
})
.catch((error) => {
alert.error(error.toString());
});
};
// const getCacheList = (orgId) => {
@@ -103,8 +123,8 @@ const CacheView = (props) => {
// if (response.status !== 200) {
// console.log("Status not 200 for WORKFLOW EXECUTION :O!");
// }
// return response.json();
// })
// .then((responseJson) => {
@@ -126,37 +146,72 @@ const CacheView = (props) => {
// console.log("Get userprofile error: ", error);
// })
// }
const deleteCache = (orgId, key) => {
alert.info("Attempting to delete Cache");
fetch(globalUrl + `/api/v1/orgs/${orgId}/cache/${key}`, {
method: "DELETE",
headers: {
Accept: "application/json",
},
credentials: "include",
method: "DELETE",
headers: {
Accept: "application/json",
},
credentials: "include",
})
.then((response) => {
if (response.status === 200) {
alert.success("Successfully deleted Cache");
setTimeout(() => {
.then((response) => {
if (response.status === 200) {
alert.success("Successfully deleted Cache");
setTimeout(() => {
listOrgCache(orgId);
}, 1000);
} else {
alert.error("Failed deleting Cache. Does it still exist?");
}
})
.catch((error) => {
alert.error(error.toString());
});
};
const editOrgCache = (orgId) => {
const cache = { key: dataValue.key , value: value };
setCacheInput([cache]);
console.log("cache:", cache)
console.log("cache input: ", cacheInput)
fetch(globalUrl + `/api/v1/orgs/${orgId}/set_cache`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
},
credentials: "include",
body: JSON.stringify(cache),
})
.then((response) => {
if (response.status !== 200) {
console.log("Status not 200 for Cache :O!");
return;
}
return response.json();
})
.then((responseJson) => {
setAddCache(responseJson);
alert.success("Cache Edited Successfully!");
listOrgCache(orgId);
}, 1000);
} else {
alert.error("Failed deleting Cache. Does it still exist?");
}
})
.catch((error) => {
alert.error(error.toString());
});
};
setModalOpen(false);
})
.catch((error) => {
alert.error(error.toString());
});
};
const addOrgCache = (orgId) => {
const cache={key:key,value:value};
setCacheInput([cache]);
console.log("cache input:",cacheInput)
const cache = { key: key, value: value };
setCacheInput([cache]);
console.log("cache input:", cacheInput)
fetch(globalUrl + `/api/v1/orgs/${orgId}/set_cache`, {
method: "POST",
@@ -187,6 +242,8 @@ const CacheView = (props) => {
};
const modalView = (
// console.log("key:", dataValue.key),
//console.log("value:",dataValue.value),
<Dialog
open={modalOpen}
onClose={() => {
@@ -203,10 +260,10 @@ const CacheView = (props) => {
>
<DialogTitle>
<span style={{ color: "white" }}>
Add Cache
{ editCache ? "Edit Cache" : "Add Cache" }
</span>
</DialogTitle>
<div style={{paddingLeft: "30px", paddingRight: '30px'}}>
<div style={{ paddingLeft: "30px", paddingRight: '30px' }}>
Key
<TextField
color="primary"
@@ -223,14 +280,14 @@ const CacheView = (props) => {
fullWidth={true}
autoComplete="Key"
placeholder="abc"
id="keyfield"
id="keyfield"
margin="normal"
variant="outlined"
value={key}
onChange={(e)=>setKey(e.target.value)}
value={editCache ? dataValue.key : key}
onChange={(e) => setKey(e.target.value)}
/>
</div>
<div style={{paddingLeft: "30px", paddingRight: '30px'}}>
<div style={{ paddingLeft: "30px", paddingRight: '30px' }}>
Value
<TextField
color="primary"
@@ -249,11 +306,11 @@ const CacheView = (props) => {
id="Valuefield"
margin="normal"
variant="outlined"
value={value}
onChange={(e)=>setValue(e.target.value)}
defaultValue={editCache ? dataValue.value : ""}
onChange={(e) => setValue(e.target.value)}
/>
</div>
<DialogActions style={{paddingLeft: "30px", paddingRight: '30px'}}>
<DialogActions style={{ paddingLeft: "30px", paddingRight: '30px' }}>
<Button
style={{ borderRadius: "0px" }}
onClick={() => setModalOpen(false)}
@@ -265,11 +322,11 @@ const CacheView = (props) => {
variant="contained"
style={{ borderRadius: "0px" }}
onClick={() => {
addOrgCache(orgId)
{editCache ? editOrgCache(orgId) : addOrgCache(orgId)}
}}
color="primary"
>
Submit
{editCache ? "Edit":"Submit"}
</Button>
</DialogActions>
</Dialog>
@@ -282,7 +339,7 @@ const CacheView = (props) => {
<div style={{ marginTop: 20, marginBottom: 20 }}>
<h2 style={{ display: "inline" }}>Shuffle Datastore</h2>
<span style={{ marginLeft: 25 }}>
Datastore is a key-value store for storing data that can be used cross-workflow.&nbsp;
Datastore is a key-value store for storing data that can be used cross-workflow.&nbsp;
<a
target="_blank"
rel="noopener noreferrer"
@@ -297,7 +354,11 @@ const CacheView = (props) => {
style={{}}
variant="contained"
color="primary"
onClick={() => setModalOpen(true)}
onClick={() =>{
setEditCache(false)
setModalOpen(true)
}
}
>
Add Cache
</Button>
@@ -319,19 +380,19 @@ const CacheView = (props) => {
<ListItem>
<ListItemText
primary="Key"
// style={{ minWidth: 150, maxWidth: 150 }}
// style={{ minWidth: 150, maxWidth: 150 }}
/>
<ListItemText
primary="value"
// style={{ minWidth: 150, maxWidth: 150 }}
// style={{ minWidth: 150, maxWidth: 150 }}
/>
<ListItemText
primary="Updated"
// style={{ minWidth: 150, maxWidth: 150 }}
// style={{ minWidth: 150, maxWidth: 150 }}
/>
<ListItemText
primary="Actions"
// style={{ minWidth: 150, maxWidth: 150 }}
// style={{ minWidth: 150, maxWidth: 150 }}
/>
</ListItem>
{listCache === undefined || listCache === null
@@ -345,27 +406,41 @@ const CacheView = (props) => {
return (
<ListItem key={index} style={{ backgroundColor: bgColor }}>
<ListItemText
style={{
maxWidth: 225,
minWidth: 225,
overflow: "hidden",
}}
style={{
maxWidth: 225,
minWidth: 225,
overflow: "hidden",
}}
primary={data.key}
/>
<div style={scrollStyle1}>
<ListItemText
style={{
maxWidth: 225,
minWidth: 225,
overflow: "hidden",
paddingLeft: "52px",
}}
// style={{
// maxWidth: 225,
// maxHeight: 150,
// // overflow: "hidden",
// paddingLeft: "52px",
// overflow: "scroll",
// }}
style={scrollStyle2}
// style={{ maxWidth: 100, minWidth: 100 }}
primary={data.value} />
// onMouseOver={() =>
// setShow((prevState) => ({ ...prevState, [data.value]: true }))
// }
// onMouseLeave={() =>
// setShow((prevState) => ({ ...prevState, [data.value]: false }))
// }
//primary={show[data.value] ? data.value : `${data.value.substring(0, 5)}...`}
primary={data.value}
/>
</div>
<ListItemText
style={{
maxWidth: 225,
minWidth: 225,
overflow: "hidden",
marginLeft: "42px",
}}
primary={new Date(data.edited * 1000).toISOString()}
/>
@@ -377,7 +452,7 @@ const CacheView = (props) => {
paddingLeft: "155px",
}}
primary=<span style={{ display: "inline" }}>
{/* <Tooltip
<Tooltip
title="Edit"
style={{}}
aria-label={"Edit"}
@@ -386,7 +461,9 @@ const CacheView = (props) => {
<IconButton
style={{ padding: "6px" }}
onClick={() => {
setEditCache(true)
setDataValue({"key":data.key,"value":data.value})
setModalOpen(true)
}}
>
<EditIcon
@@ -394,7 +471,7 @@ const CacheView = (props) => {
/>
</IconButton>
</span>
</Tooltip> */}
</Tooltip>
<Tooltip
title={"Delete Cache"}
style={{ marginLeft: 15, }}
+1 -54
View File
@@ -325,61 +325,7 @@ const AuthenticationOauth2 = (props) => {
console.log("Adding authorization from user side")
state += `%26authorization%3d${userAuth}`;
}
// write:request:jira-service-management
}
const handleOauth2Request = (client_id, client_secret, oauth_url, scopes, admin_consent, prompt) => {
setButtonClicked(true);
//console.log("SCOPES: ", scopes);
client_id = client_id.trim()
client_secret = client_secret.trim()
oauth_url = oauth_url.trim()
var resources = "";
if (scopes !== undefined && (scopes !== null) & (scopes.length > 0)) {
console.log("IN scope 1")
if (offlineAccess === true && !scopes.includes("offline_access")) {
console.log("IN scope 2")
if (!authenticationType.redirect_uri.includes("google")) {
console.log("Appending offline access")
scopes.push("offline_access")
}
}
resources = scopes.join(" ");
//resources = scopes.join(",");
}
const authentication_url = authenticationType.token_uri;
//console.log("AUTH: ", authenticationType)
//console.log("SCOPES2: ", resources)
const redirectUri = `${window.location.protocol}//${window.location.host}/set_authentication`;
const workflowId = workflow !== undefined ? workflow.id : "";
var state = `workflow_id%3D${workflowId}%26reference_action_id%3d${selectedAction.app_id}%26app_name%3d${selectedAction.app_name}%26app_id%3d${selectedAction.app_id}%26app_version%3d${selectedAction.app_version}%26authentication_url%3d${authentication_url}%26scope%3d${resources}%26client_id%3d${client_id}%26client_secret%3d${client_secret}`;
if (oauth_url !== undefined && oauth_url !== null && oauth_url.length > 0) {
state += `%26oauth_url%3d${oauth_url}`;
console.log("ADDING OAUTH2 URL: ", state);
}
if (
authenticationType.refresh_uri !== undefined &&
authenticationType.refresh_uri !== null &&
authenticationType.refresh_uri.length > 0
) {
state += `%26refresh_uri%3d${authenticationType.refresh_uri}`;
} else {
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`;
var defaultPrompt = "login"
if (prompt !== undefined && prompt !== null && prompt.length > 0) {
defaultPrompt = prompt
}
// Check for org_id
const orgId = urlParams.get("org_id");
if (orgId !== undefined && orgId !== null && orgId.length > 0) {
@@ -524,6 +470,7 @@ const AuthenticationOauth2 = (props) => {
} else {
alert.info(
"Field " + selectedApp.authentication.parameters[key].name.replace("_basic", "", -1).replace("_", " ", -1) + " can't be empty"
);
return;
}
+1 -1
View File
@@ -1595,7 +1595,7 @@ const ParsedAction = (props) => {
maxWidth: "95%",
fontSize: "1em",
},
disableUnderline: true,
disableUnderline: true,
endAdornment: hideExtraTypes ? null : (
<InputAdornment position="end">
<ButtonGroup orientation={multiline ? "vertical" : "horizontal"}>
-9
View File
@@ -3532,12 +3532,7 @@ Let me know if you're interested, or set up a call here: https://drift.me/${user
<div style={{ marginTop: 20, marginBottom: 20 }}>
<h2 style={{ display: "inline" }}>App Authentication</h2>
<span style={{ marginLeft: 25 }}>
<<<<<<< HEAD
Control the authentication options for individual apps. PS: Actions
performed here can be destructive!
=======
Control the authentication options for individual apps.
>>>>>>> master
</span>
&nbsp;
<a
@@ -3546,11 +3541,7 @@ Let me know if you're interested, or set up a call here: https://drift.me/${user
href="/docs/organizations#app_authentication"
style={{ textDecoration: "none", color: "#f85a3e" }}
>
<<<<<<< HEAD
Learn more about authentication
=======
Learn more about App Authentication
>>>>>>> master
</a>
</div>
<Divider
+1
View File
@@ -206,6 +206,7 @@ const SetAuthentication = (props) => {
.then((responseJson) => {
//setUserSettings(responseJson)
console.log("Resp: ", responseJson);
if (responseJson.reason !== undefined) {
setResponse(responseJson.reason);
setFinished(true);