Fixed suborg zIndex, execution debugging, Oauth2 view and SDK updates

This commit is contained in:
frikky
2021-10-13 02:28:46 +02:00
parent 7159bf207c
commit 1632a03753
15 changed files with 307 additions and 196 deletions
+14 -7
View File
@@ -1227,6 +1227,7 @@ const AngularWorkflow = (props) => {
if (selectedApp.authentication.required) {
//console.log("App requires auth!!")
// Setup auth here :)
var appUpdates = false
const authenticationOptions = []
var findAuthId = ""
if (selectedAction.authentication_id !== null && selectedAction.authentication_id !== undefined && selectedAction.authentication_id.length > 0) {
@@ -1261,6 +1262,7 @@ const AngularWorkflow = (props) => {
console.log("Setting auth at: ", workflow.actions[key], item.id)
workflow.actions[key].selectedAuthentication = item
workflow.actions[key].authentication_id = item.id
appUpdates = true
//if (workflow.actions[key].selectedAuthentication === undefined || workflow.actions[key].selectedAuthentication === null || workflow.actions[key].selectedAuthentication.length === 0) {
// console.log("Setting inner auth: ", workflow.actions[key])
//}
@@ -1282,12 +1284,16 @@ const AngularWorkflow = (props) => {
selectedAction.selectedAuthentication = {}
}
setSelectedAction(selectedAction)
setWorkflow(workflow)
saveWorkflow(workflow)
//for (var key in
alert.info("Added and updated authentication!")
if (appUpdates === true) {
setAuthenticationModalOpen(false)
setSelectedAction(selectedAction)
setWorkflow(workflow)
saveWorkflow(workflow)
alert.info("Added and updated authentication!")
} else {
alert.error("Failed to find new authentication - did it work?")
}
} else {
alert.info("No authentication to update")
}
@@ -2098,6 +2104,7 @@ const AngularWorkflow = (props) => {
{
"type": "oauth2",
"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,
@@ -2946,7 +2953,7 @@ const AngularWorkflow = (props) => {
//console.log(event.keyCode)
switch( event.keyCode ) {
case 27:
console.log("ESCAPE")
//console.log("ESCAPE")
if (configureWorkflowModalOpen === true) {
setConfigureWorkflowModalOpen(false)
}
@@ -9271,7 +9278,7 @@ const AngularWorkflow = (props) => {
// This whole part is redundant. Made it part of Arguments instead.
console.log(selectedApp)
//console.log(selectedApp)
const authenticationModal = authenticationModalOpen ?
<Dialog
open={authenticationModalOpen}
+70 -19
View File
@@ -202,7 +202,7 @@ const AppCreator = (props) => {
const actionNonBodyRequest = ["GET", "HEAD", "DELETE", "CONNECT"]
const actionBodyRequest = ["POST", "PUT", "PATCH",]
//const authenticationOptions = ["No authentication", "API key", "Bearer auth", "Basic auth", "JWT", "Oauth2"]
const authenticationOptions = ["No authentication", "API key", "Bearer auth", "Basic auth"]//, "Oauth2"]
const authenticationOptions = ["No authentication", "API key", "Bearer auth", "Basic auth", "Oauth2"]
const apikeySelection = ["Header", "Query",]
const [name, setName] = useState("");
@@ -222,7 +222,7 @@ const AppCreator = (props) => {
const [parameterName, setParameterName] = useState("");
const [parameterLocation, setParameterLocation] = useState(apikeySelection.length > 0 ? apikeySelection[0] : "");
const [refreshUrl, setRefreshUrl] = useState("");
const [oauth2Scopes, setOauth2Scopes] = useState(["google.com"]);
const [oauth2Scopes, setOauth2Scopes] = useState(["OAUTH2.SCOPE.HERE"]);
const [projectCategories, setProjectCategories] = useState([]);
const [selectedCategory, setSelectedCategory] = useState("");
@@ -949,6 +949,10 @@ const AppCreator = (props) => {
if (value.flow.authorizationCode.refreshUrl !== undefined) {
setRefreshUrl(value.flow.authorizationCode.refreshUrl)
}
if (value.flow.authorizationCode.scopes !== undefined && value.flow.authorizationCode.scopes !== null && value.flow.authorizationCode.scopes.length > 0) {
setOauth2Scopes(value.flow.authorizationCode.scopes)
}
} else if (key === "ApiKeyAuth") {
setAuthenticationOption("API key")
@@ -1316,7 +1320,7 @@ const AppCreator = (props) => {
data.paths[item.url][item.method.toLowerCase()].parameters.push(newitem)
} else {
console.log("Nothing to append?")
//console.log("Nothing to append?")
}
// https://swagger.io/docs/specification/describing-request-body/file-upload/
@@ -1438,17 +1442,19 @@ const AppCreator = (props) => {
"authorizationUrl": newparamName,
"tokenUrl": parameterLocation,
"refreshUrl": refreshUrl,
"scopes": [],
"scopes": oauth2Scopes === undefined || oauth2Scopes === null ? [] : oauth2Scopes,
},
},
}
if (oauth2Scopes.scopes > 0) {
for (var key in oauth2Scopes) {
const scope = oauth2Scopes[key]
data.components.securitySchemes["Oauth2"]["flow"]["authorizationCode"]["scopes"].push(scope)
}
}
console.log("SCOPES: ", oauth2Scopes)
//if (oauth2Scopes.scopes > 0) {
// for (var key in oauth2Scopes) {
// const scope = oauth2Scopes[key]
// data.components.securitySchemes["Oauth2"]["flow"]["authorizationCode"]["scopes"].push(scope)
// }
//}
}
if (setExtraAuth.length > 0) {
@@ -1747,12 +1753,12 @@ const AppCreator = (props) => {
const oauth2Auth = authenticationOption === "Oauth2" ?
<div style={{color: "white", marginTop: 20, }}>
<Typography variant="body1">Oauth2 authentication</Typography>
<Typography variant="body2" color="textSecondary">
<Typography variant="body2" color="textSecondary" style={{marginTop: 10,}}>
Base Authorization URL
</Typography>
<TextField
required
style={{flex: "1", backgroundColor: inputColor}}
style={{margin: 0, flex: "1", backgroundColor: inputColor}}
fullWidth={true}
placeholder="https://.../oauth2/authorize"
type="name"
@@ -1770,12 +1776,12 @@ const AppCreator = (props) => {
},
}}
/>
<Typography variant="body2" color="textSecondary">
<Typography variant="body2" color="textSecondary" style={{marginTop: 10,}}>
Token URL
</Typography>
<TextField
required
style={{flex: "1", backgroundColor: inputColor}}
style={{margin: 0, flex: "1", backgroundColor: inputColor}}
fullWidth={true}
placeholder="https://.../oauth2/token"
type="name"
@@ -1793,11 +1799,11 @@ const AppCreator = (props) => {
},
}}
/>
<Typography variant="body2" color="textSecondary">
<Typography variant="body2" color="textSecondary" style={{marginTop: 10,}}>
Refresh-token URL
</Typography>
<TextField
style={{flex: "1", backgroundColor: inputColor}}
style={{margin: 0, flex: "1", backgroundColor: inputColor}}
fullWidth={true}
placeholder="The URL to retrieve refresh-tokens at"
type="name"
@@ -1812,6 +1818,31 @@ const AppCreator = (props) => {
},
}}
/>
<Typography variant="body2" color="textSecondary" style={{marginTop: 10,}}>
Scopes
</Typography>
<ChipInput
style={{}}
InputProps={{
style:{
color: "white",
},
}}
placeholder="Scopes"
color="primary"
fullWidth
defaultValue={oauth2Scopes}
onAdd={(chip) => {
oauth2Scopes.push(chip)
console.log(oauth2Scopes)
setOauth2Scopes(oauth2Scopes)
}}
onDelete={(chip, index) => {
oauth2Scopes.splice(index, 1)
console.log(oauth2Scopes)
setOauth2Scopes(oauth2Scopes)
}}
/>
</div>
: null
@@ -2429,26 +2460,46 @@ const AppCreator = (props) => {
}}
onBlur={event => {
var parsedurl = event.target.value
console.log("URL: ", parsedurl)
//console.log("URL: ", parsedurl)
if (parsedurl.includes(" ")) {
parsedurl = parsedurl.replaceAll(" ", " ")
}
if (parsedurl.includes(" ")) {
parsedurl = parsedurl.replaceAll(" ", " ")
}
if (parsedurl.includes("[") && parsedurl.includes("]")) {
//console.log("REPLACE1")
parsedurl = parsedurl.replaceAll("[", "{")
parsedurl = parsedurl.replaceAll("]", "}")
}
if (parsedurl.includes("<") && parsedurl.includes(">")) {
console.log("REPLACE")
//console.log("REPLACE2")
parsedurl = parsedurl.replaceAll("<", "{")
parsedurl = parsedurl.replaceAll(">", "}")
}
//console.log("URL2: ", parsedurl)
if (parsedurl.startsWith("PUT ") || parsedurl.startsWith("GET ") ||parsedurl.startsWith("POST ") || parsedurl.startsWith("DELETE ") ||parsedurl.startsWith("PATCH ") || parsedurl.startsWith("CONNECT ")) {
const tmp = parsedurl.split(" ")
if (tmp.length > 1) {
parsedurl = tmp[1]
parsedurl = tmp[1].trim()
setActionField("url", parsedurl)
setCurrentActionMethod(tmp[0].toUpperCase())
setActionField("method", tmp[0].toUpperCase())
}
console.log("URL3: ", parsedurl)
setUpdate(Math.random())
} else if (parsedurl.startsWith("curl")) {
console.log("URL4: ", parsedurl)
const request = parseCurl(event.target.value)
if (request !== event.target.value && request.method !== undefined && request.method !== null) {
if (request.method.toUpperCase() !== currentAction.Method) {
+9 -5
View File
@@ -480,7 +480,7 @@ const Apps = (props) => {
color: "white",
borderRadius: 5,
backgroundColor: surfaceColor,
display: "flex",
//display: "flex",
marginBottom: 10,
overflow: "hidden",
}
@@ -522,7 +522,7 @@ const Apps = (props) => {
<Link to={editUrl} style={{textDecoration: "none"}}>
<Tooltip title={"Edit OpenAPI app"}>
<Button
variant="outlined"
variant="contained"
component="label"
color="primary"
style={{marginTop: 10, marginRight: 10,}}
@@ -700,8 +700,8 @@ const Apps = (props) => {
{activateButton}
{(props.userdata !== undefined && (props.userdata.role === "admin" || props.userdata.id === selectedApp.owner) || !selectedApp.generated) ?
<div>
{downloadButton}
{editButton}
{downloadButton}
{deleteButton}
</div>
: null}
@@ -977,31 +977,35 @@ const Apps = (props) => {
</div>
{isCloud ? null :
<span>
{isLoading ? null :
<Tooltip title={"Reload apps locally"} style={{marginTop: "28px", width: "100%"}} aria-label={"Upload"}>
<Button
variant="outlined"
component="label"
color="primary"
style={{margin: 5, maxHeight: 50, marginTop: 10}}
disabled={isLoading}
onClick={() => {
hotloadApps()
}}
>
<CachedIcon />
{isLoading ? <CircularProgress size={25} /> : <CachedIcon />}
</Button>
</Tooltip>
}
<Tooltip title={"Download from Github"} style={{marginTop: "28px", width: "100%"}} aria-label={"Upload"}>
<Button
variant="outlined"
component="label"
color="primary"
style={{margin: 5, maxHeight: 50, marginTop: 10}}
disabled={isLoading}
onClick={() => {
setOpenApi(baseRepository)
setLoadAppsModalOpen(true)
}}
>
<CloudDownloadIcon />
{isLoading ? <CircularProgress size={25} /> : <CloudDownloadIcon />}
</Button>
</Tooltip>
</span>
+14 -14
View File
@@ -139,7 +139,7 @@ const Docs = (props) => {
parsedline[1] = parsedline[1].replaceAll(")", "")
parsedline[1] = parsedline[1].replaceAll("(", "")
parsedline[1] = parsedline[1].trim()
console.log(parsedline[0], parsedline[1])
//console.log(parsedline[0], parsedline[1])
innerTocLines.push({
"text": parsedline[0],
@@ -205,12 +205,12 @@ const Docs = (props) => {
// Fix location..
if (element.innerHTML.toLowerCase() === name) {
console.log(element.offsetTop)
//element.scrollIntoView({behavior: "smooth"})
element.scrollTo({
top: element.offsetTop+offset,
behavior: "smooth"
})
//console.log(element.offsetTop)
element.scrollIntoView({behavior: "smooth"})
//element.scrollTo({
// top: element.offsetTop+offset,
// behavior: "smooth"
//})
found = true
//element.scrollTo({
// top: element.offsetTop-100,
@@ -222,7 +222,7 @@ const Docs = (props) => {
// H#
if (!found) {
elements = parent.getElementsByTagName('h3')
console.log(name)
//console.log("NAMe: ", name)
found = false
for (key in elements) {
const element = elements[key]
@@ -232,11 +232,11 @@ const Docs = (props) => {
// Fix location..
if (element.innerHTML.toLowerCase() === name) {
//element.scrollIntoView({behavior: "smooth"})
element.scrollTo({
top: element.offsetTop-offset,
behavior: "smooth"
})
element.scrollIntoView({behavior: "smooth"})
//element.scrollTo({
// top: element.offsetTop-offset,
// behavior: "smooth"
//})
found = true
//element.scrollTo({
// top: element.offsetTop-100,
@@ -392,7 +392,7 @@ const Docs = (props) => {
{itemMatching && tocLines !== null && tocLines !== undefined && tocLines.length > 0 ?
<div style={{marginLeft: 5}}>
{tocLines.map((data, index) => {
console.log(data)
//console.log(data)
return (
<Link key={index} style={innerHrefStyle} to={data.link} onClick={() => {}}>
+4
View File
@@ -91,6 +91,10 @@ const SetAuthentication = (props) => {
if (query[0] === "client_secret") {
appAuthData.fields.push({"key": "client_secret", "value": query[1]})
}
if (query[0] === "oauth_url") {
appAuthData.fields.push({"key": "oauth_url", "value": query[1]})
}
}
}