Added edit functionality for apps that are public, ensuring they can be worked on and explored together (NOT gonna work for Workflows due to sensitive data)
This commit is contained in:
@@ -484,10 +484,29 @@ const AppCreator = (defaultprops) => {
|
||||
// Sets the data up as it should be at later points
|
||||
// This is the data FROM the database, not what's being saved
|
||||
const parseIncomingOpenapiData = (data) => {
|
||||
|
||||
console.log("Data: ", data)
|
||||
var parsedDecoded = ""
|
||||
try {
|
||||
const decoded = base64_decode(data.openapi)
|
||||
parsedDecoded = decoded
|
||||
} catch (e) {
|
||||
console.log("Failed JSON parsing: ", e)
|
||||
parsedDecoded = data
|
||||
}
|
||||
|
||||
if (data.openapi === null) {
|
||||
alert.info("Failed to load OpenAPI for app. Please contact support if this persists.")
|
||||
setIsAppLoaded(true);
|
||||
return
|
||||
}
|
||||
|
||||
console.log("Decoded: ", parsedDecoded)
|
||||
const parsedapp =
|
||||
data.openapi === undefined
|
||||
data.openapi === undefined || data.openapi === null
|
||||
? data
|
||||
: JSON.parse(base64_decode(data.openapi));
|
||||
: JSON.parse(parsedDecoded);
|
||||
|
||||
data = parsedapp.body === undefined ? parsedapp : parsedapp.body;
|
||||
|
||||
var jsonvalid = false;
|
||||
@@ -1611,6 +1630,14 @@ const AppCreator = (defaultprops) => {
|
||||
id: props.match.params.appid,
|
||||
};
|
||||
|
||||
if (isEditing === false) {
|
||||
var urlParams = new URLSearchParams(window.location.search);
|
||||
if (urlParams !== undefined && urlParams !== null && urlParams.has("id")) {
|
||||
data.id = urlParams.get("id")
|
||||
}
|
||||
//id: props.match.params.appid,
|
||||
}
|
||||
|
||||
if (basedata.info !== undefined && basedata.info.contact !== undefined) {
|
||||
data.info["contact"] = basedata.info.contact;
|
||||
} else if (contact === "") {
|
||||
@@ -2083,6 +2110,9 @@ const AppCreator = (defaultprops) => {
|
||||
name: newparamName,
|
||||
description: refreshUrl,
|
||||
}
|
||||
|
||||
console.log("Full auth component: ", data.components.securitySchemes["ApiKeyAuth"])
|
||||
|
||||
} else if (authenticationOption === "Bearer auth") {
|
||||
data.components.securitySchemes["BearerAuth"] = {
|
||||
type: "http",
|
||||
@@ -5036,7 +5066,8 @@ const AppCreator = (defaultprops) => {
|
||||
marginTop: "5px",
|
||||
marginRight: "15px",
|
||||
backgroundColor: inputColor,
|
||||
maxHeight: 200,
|
||||
maxHeight: 250,
|
||||
overflow: "auto",
|
||||
}}
|
||||
fullWidth={true}
|
||||
type="name"
|
||||
|
||||
+15
-10
@@ -721,6 +721,8 @@ const Apps = (props) => {
|
||||
</Tooltip>
|
||||
) : null;
|
||||
|
||||
// FIXME: Add /apps/new?id=<PUBLIC> to allow for changes of the original
|
||||
// Should always reference the original ID.
|
||||
var editButton =
|
||||
selectedApp.activated &&
|
||||
selectedApp.private_id !== undefined &&
|
||||
@@ -741,10 +743,10 @@ const Apps = (props) => {
|
||||
) : null;
|
||||
|
||||
//var editNewButton = editButton === null ?
|
||||
var editNewButton = null
|
||||
/*
|
||||
<Link to={editUrl} style={{ textDecoration: "none" }}>
|
||||
<Tooltip title={"Add your version"}>
|
||||
console.log("User, & genrrated, activate: ", props.userdata, selectedApp.generated, selectedApp.activated)
|
||||
var editNewButton = selectedApp.generated && selectedApp.activated && props.userdata.id !== selectedApp.owner ?
|
||||
<Link to={activateUrl} style={{ textDecoration: "none" }}>
|
||||
<Tooltip title={"Edit this public app to your liking"}>
|
||||
<Button
|
||||
variant="contained"
|
||||
component="label"
|
||||
@@ -755,9 +757,9 @@ const Apps = (props) => {
|
||||
</Button>
|
||||
</Tooltip>
|
||||
</Link>
|
||||
*/
|
||||
: null
|
||||
|
||||
const activateButton =
|
||||
const activateButton =
|
||||
selectedApp.generated && !selectedApp.activated ? (
|
||||
<div>
|
||||
<Link to={activateUrl} style={{ textDecoration: "none" }}>
|
||||
@@ -997,15 +999,14 @@ const Apps = (props) => {
|
||||
) : null}
|
||||
|
||||
{activateButton}
|
||||
{editNewButton}
|
||||
{(props.userdata !== undefined &&
|
||||
(props.userdata.role === "admin" ||
|
||||
props.userdata.id === selectedApp.owner ||
|
||||
selectedApp.owner === ""
|
||||
)) ||
|
||||
!selectedApp.generated ? (
|
||||
)) || !selectedApp.generated ? (
|
||||
<div>
|
||||
{editButton}
|
||||
{editNewButton}
|
||||
{downloadButton}
|
||||
{deleteButton}
|
||||
</div>
|
||||
@@ -1821,7 +1822,11 @@ const Apps = (props) => {
|
||||
if (responseJson.success) {
|
||||
alert.success("Successfully updated app configuration");
|
||||
} else {
|
||||
alert.error("Error updating app configuration");
|
||||
if (responseJson.reason !== undefined && responseJson.reason !== null) {
|
||||
alert.error("Error: "+responseJson.reason);
|
||||
} else {
|
||||
alert.error("Error updating app configuration");
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
|
||||
Reference in New Issue
Block a user