Added more error message handlers to SDK
This commit is contained in:
@@ -34,8 +34,17 @@ import {
|
||||
AttachFile as AttachFileIcon,
|
||||
Apps as AppsIcon,
|
||||
ErrorOutline as ErrorOutlineIcon,
|
||||
AddAPhoto as AddAPhotoIcon,
|
||||
AddAPhotoOutlined as AddAPhotoOutlinedIcon,
|
||||
ZoomInOutlined as ZoomInOutlinedIcon,
|
||||
ZoomOutOutlined as ZoomOutOutlinedIcon,
|
||||
Loop as LoopIcon,
|
||||
} from "@material-ui/icons";
|
||||
|
||||
import {
|
||||
AddPhotoAlternate as AddPhotoAlternateIcon,
|
||||
} from '@mui/icons-material';
|
||||
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import { Link, useParams } from "react-router-dom";
|
||||
import YAML from "yaml";
|
||||
@@ -44,12 +53,6 @@ import { useAlert } from "react-alert";
|
||||
import words from "shellwords";
|
||||
|
||||
import AvatarEditor from "react-avatar-editor";
|
||||
import AddAPhotoIcon from "@material-ui/icons/AddAPhoto";
|
||||
import AddAPhotoOutlinedIcon from "@material-ui/icons/AddAPhotoOutlined";
|
||||
import ZoomInOutlinedIcon from "@material-ui/icons/ZoomInOutlined";
|
||||
import ZoomOutOutlinedIcon from "@material-ui/icons/ZoomOutOutlined";
|
||||
import LoopIcon from "@material-ui/icons/Loop";
|
||||
import AddPhotoAlternateIcon from "@material-ui/icons/AddPhotoAlternate";
|
||||
|
||||
const surfaceColor = "#27292D";
|
||||
const inputColor = "#383B40";
|
||||
@@ -344,14 +347,14 @@ const AppCreator = (defaultprops) => {
|
||||
useEffect(() => {
|
||||
if (window.location.pathname.includes("apps/edit")) {
|
||||
setIsEditing(true);
|
||||
handleEditApp();
|
||||
handleEditApp(props.match.params.appid);
|
||||
} else {
|
||||
checkQuery();
|
||||
}
|
||||
}, []);
|
||||
|
||||
const handleEditApp = () => {
|
||||
fetch(globalUrl + "/api/v1/apps/" + props.match.params.appid + "/config", {
|
||||
const handleEditApp = (appid) => {
|
||||
fetch(globalUrl + "/api/v1/apps/" + appid + "/config", {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
@@ -389,34 +392,36 @@ const AppCreator = (defaultprops) => {
|
||||
setIsAppLoaded(true);
|
||||
return;
|
||||
}
|
||||
|
||||
handleEditApp(urlParams.get("id"))
|
||||
|
||||
fetch(globalUrl + "/api/v1/get_openapi/" + urlParams.get("id"), {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
},
|
||||
credentials: "include",
|
||||
})
|
||||
.then((response) => {
|
||||
if (response.status !== 200) {
|
||||
throw new Error("NOT 200 :O");
|
||||
}
|
||||
//fetch(globalUrl + "/api/v1/get_openapi/" + urlParams.get("id"), {
|
||||
// method: "GET",
|
||||
// headers: {
|
||||
// "Content-Type": "application/json",
|
||||
// Accept: "application/json",
|
||||
// },
|
||||
// credentials: "include",
|
||||
//})
|
||||
// .then((response) => {
|
||||
// if (response.status !== 200) {
|
||||
// throw new Error("NOT 200 :O");
|
||||
// }
|
||||
|
||||
return response.json();
|
||||
})
|
||||
.then((responseJson) => {
|
||||
setIsAppLoaded(true);
|
||||
if (!responseJson.success) {
|
||||
alert.error("Failed to verify");
|
||||
} else {
|
||||
parseIncomingOpenapiData(responseJson);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log("Error: ", error.toString());
|
||||
alert.error(error.toString());
|
||||
});
|
||||
// return response.json();
|
||||
// })
|
||||
// .then((responseJson) => {
|
||||
// setIsAppLoaded(true);
|
||||
// if (!responseJson.success) {
|
||||
// alert.error("Failed to verify");
|
||||
// } else {
|
||||
// parseIncomingOpenapiData(responseJson);
|
||||
// }
|
||||
// })
|
||||
// .catch((error) => {
|
||||
// console.log("Error: ", error.toString());
|
||||
// alert.error(error.toString());
|
||||
// });
|
||||
};
|
||||
|
||||
const setFileFromb64 = () => {
|
||||
|
||||
+28
-15
@@ -39,6 +39,10 @@ import {
|
||||
Delete as DeleteIcon,
|
||||
} from "@material-ui/icons";
|
||||
|
||||
import {
|
||||
ForkRight as ForkRightIcon,
|
||||
} from '@mui/icons-material';
|
||||
|
||||
import { useTheme } from "@material-ui/core/styles";
|
||||
|
||||
import YAML from "yaml";
|
||||
@@ -807,9 +811,11 @@ 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 =
|
||||
//if (selectedApp.name !== undefined && selectedApp.name !== null && selectedApp.name.includes("New")) {
|
||||
//}
|
||||
|
||||
var editButton =
|
||||
selectedApp.activated &&
|
||||
selectedApp.private_id !== undefined &&
|
||||
selectedApp.private_id.length > 0 &&
|
||||
@@ -829,21 +835,19 @@ const Apps = (props) => {
|
||||
) : null;
|
||||
|
||||
//var editNewButton = editButton === null ?
|
||||
var editNewButton = selectedApp.generated && selectedApp.activated && props.userdata.id !== selectedApp.owner ?
|
||||
isCloud ?
|
||||
var editNewButton = selectedApp.generated && selectedApp.activated && props.userdata.id !== selectedApp.owner && isCloud ?
|
||||
<Link to={activateUrl} style={{ textDecoration: "none" }}>
|
||||
<Tooltip title={"Edit this public app to your liking"}>
|
||||
<Tooltip title={"Fork and Edit this public app to your liking"}>
|
||||
<Button
|
||||
variant="contained"
|
||||
component="label"
|
||||
color="primary"
|
||||
style={{ marginTop: 10, marginRight: 10 }}
|
||||
>
|
||||
<EditIcon />
|
||||
<ForkRightIcon />
|
||||
</Button>
|
||||
</Tooltip>
|
||||
</Link>
|
||||
: null
|
||||
: null
|
||||
|
||||
const activateButton =
|
||||
@@ -879,8 +883,7 @@ const Apps = (props) => {
|
||||
((selectedApp.private_id !== undefined &&
|
||||
selectedApp.private_id.length > 0 &&
|
||||
selectedApp.generated) ||
|
||||
(selectedApp.downloaded !== undefined &&
|
||||
selectedApp.downloaded == true) ||
|
||||
(selectedApp.downloaded !== undefined && selectedApp.downloaded == true) ||
|
||||
!selectedApp.generated) &&
|
||||
activateButton === null ? (
|
||||
<Tooltip title={"Delete app"}>
|
||||
@@ -982,6 +985,10 @@ const Apps = (props) => {
|
||||
|
||||
const userRoles = ["you", isCloud ? "public" : "everyone"];
|
||||
|
||||
// Admin in org or creator of app
|
||||
// FIXME: Missing check for if same creator account
|
||||
const canEditApp = userdata !== undefined && (userdata.admin === "true" || userdata.id === selectedApp.owner || selectedApp.owner === "" || (userdata.admin === "true" && userdata.active_org.id === selectedApp.reference_org)) || !selectedApp.generated
|
||||
|
||||
//fetch(globalUrl+"/api/v1/get_openapi/"+urlParams.get("id"),
|
||||
var baseInfo =
|
||||
newAppname.length > 0 ? (
|
||||
@@ -1086,14 +1093,20 @@ const Apps = (props) => {
|
||||
) : null}
|
||||
|
||||
{activateButton}
|
||||
{editNewButton}
|
||||
{(editNewButton === null && userdata !== undefined && (userdata.admin === "true" || userdata.id === selectedApp.owner || selectedApp.owner === "" )) || !selectedApp.generated ? (
|
||||
|
||||
{ /* editNewButton === null && */ }
|
||||
|
||||
{canEditApp ? (
|
||||
<div>
|
||||
{editButton}
|
||||
{downloadButton}
|
||||
{deleteButton}
|
||||
</div>
|
||||
) : null}
|
||||
) :
|
||||
<div>
|
||||
{editNewButton}
|
||||
</div>
|
||||
}
|
||||
{selectedApp.tags !== undefined && selectedApp.tags !== null ? (
|
||||
<div
|
||||
style={{
|
||||
@@ -1119,8 +1132,8 @@ const Apps = (props) => {
|
||||
})}
|
||||
</div>
|
||||
) : null}
|
||||
{props.userdata !== undefined &&
|
||||
props.userdata.id === selectedApp.owner ? (
|
||||
{canEditApp
|
||||
? (
|
||||
<div style={{ marginTop: 15 }}>
|
||||
{/*<p><b>ID:</b> {selectedApp.id}</p>*/}
|
||||
<b style={{ marginRight: 15 }}>Sharing </b>
|
||||
@@ -1877,7 +1890,7 @@ const Apps = (props) => {
|
||||
getApps();
|
||||
}, 1000);
|
||||
} else {
|
||||
alert.error("Failed deleting app");
|
||||
alert.error("Failed deleting app. Does it still exist?");
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
|
||||
Reference in New Issue
Block a user