Fixed parts of mod migration
This commit is contained in:
@@ -64,6 +64,7 @@ const Admin = (props) => {
|
||||
const theme = useTheme();
|
||||
const classes = useStyles();
|
||||
const [firstRequest, setFirstRequest] = React.useState(true);
|
||||
const [orgRequest, setOrgRequest] = React.useState(true);
|
||||
const [modalUser, setModalUser] = React.useState({});
|
||||
const [modalOpen, setModalOpen] = React.useState(false);
|
||||
|
||||
@@ -942,8 +943,8 @@ const Admin = (props) => {
|
||||
}
|
||||
}
|
||||
|
||||
if (selectedOrganization.id === undefined && userdata !== undefined && userdata.active_org !== undefined) {
|
||||
//setSelectedOrganization(userdata.active_org)
|
||||
if (selectedOrganization.id === undefined && userdata !== undefined && userdata.active_org !== undefined && orgRequest) {
|
||||
setOrgRequest(false)
|
||||
handleGetOrg(userdata.active_org.id)
|
||||
}
|
||||
|
||||
@@ -1655,6 +1656,7 @@ const Admin = (props) => {
|
||||
</div>
|
||||
<div />
|
||||
<Button
|
||||
disabled={isCloud}
|
||||
style={{}}
|
||||
variant="contained"
|
||||
color="primary"
|
||||
@@ -2399,7 +2401,7 @@ const Admin = (props) => {
|
||||
aria-label="disabled tabs example"
|
||||
>
|
||||
<Tab label=<span><BusinessIcon style={iconStyle} /> Organization</span>/>
|
||||
{isCloud ? null : <Tab label=<span><AccessibilityNewIcon style={iconStyle} />Users</span> />}
|
||||
<Tab label=<span><AccessibilityNewIcon style={iconStyle} />Users</span> />
|
||||
{isCloud ? null : <Tab label=<span><LockIcon style={iconStyle} />App Authentication</span>/>}
|
||||
{isCloud ? null : <Tab label=<span><EcoIcon style={iconStyle} />Environments</span>/>}
|
||||
{isCloud ? null : <Tab label=<span><ScheduleIcon style={iconStyle} />Schedules</span> />}
|
||||
|
||||
@@ -1180,7 +1180,7 @@ const AngularWorkflow = (props) => {
|
||||
setSelectedApp(curapp)
|
||||
}
|
||||
|
||||
if (environments !== undefined) {
|
||||
if (environments !== undefined && environments !== null) {
|
||||
var env = environments.find(a => a.Name === curaction.environment)
|
||||
if (!env || env === undefined) {
|
||||
env = environments[defaultEnvironmentIndex]
|
||||
@@ -2414,7 +2414,7 @@ const AngularWorkflow = (props) => {
|
||||
app_id: app.id,
|
||||
sharing: app.sharing,
|
||||
private_id: app.private_id,
|
||||
environment: environments[defaultEnvironmentIndex].Name,
|
||||
environment: environments === null ? "cloud" : environments[defaultEnvironmentIndex].Name,
|
||||
errors: [],
|
||||
id_: newNodeId,
|
||||
_id_: newNodeId,
|
||||
@@ -2601,6 +2601,11 @@ const AngularWorkflow = (props) => {
|
||||
)
|
||||
})}
|
||||
{filteredApps.filter(innerapp => !internalIds.includes(innerapp.id)).map((app, index) => {
|
||||
if (app.invalid) {
|
||||
return null
|
||||
}
|
||||
|
||||
console.log("APP: ", app)
|
||||
return(
|
||||
<ParsedAppPaper key={index} app={app} />
|
||||
)
|
||||
|
||||
@@ -195,6 +195,7 @@ const AppCreator = (props) => {
|
||||
const alert = useAlert()
|
||||
|
||||
var upload = ""
|
||||
const increaseAmount = 30
|
||||
const actionNonBodyRequest = ["GET", "HEAD", "DELETE", "CONNECT"]
|
||||
const actionBodyRequest = ["POST", "PUT", "PATCH",]
|
||||
const authenticationOptions = ["No authentication", "API key", "Bearer auth", "Basic auth", ]
|
||||
@@ -228,6 +229,7 @@ const AppCreator = (props) => {
|
||||
const [appBuilding, setAppBuilding] = useState(false)
|
||||
const [extraBodyFields, setExtraBodyFields] = useState([])
|
||||
const [fileUploadEnabled, setFileUploadEnabled] = useState(false)
|
||||
const [actionAmount, setActionAmount] = useState(increaseAmount)
|
||||
|
||||
//const [actions, setActions] = useState([{
|
||||
// "name": "Get workflows",
|
||||
@@ -447,11 +449,21 @@ const AppCreator = (props) => {
|
||||
}
|
||||
|
||||
if (data.tags !== undefined && data.tags.length > 0) {
|
||||
var newtags = []
|
||||
for (var key in data.tags) {
|
||||
newWorkflowTags.push(data.tags[key].name)
|
||||
if (data.tags[key].name.length > 50) {
|
||||
console.log("Skipping tag cus it's too long: ", data.tags[key].name.length)
|
||||
continue
|
||||
}
|
||||
|
||||
newtags.push(data.tags[key].name)
|
||||
}
|
||||
|
||||
setNewWorkflowTags(newWorkflowTags)
|
||||
if (newtags.length > 10) {
|
||||
newtags = newtags.slice(0,9)
|
||||
}
|
||||
|
||||
setNewWorkflowTags(newtags)
|
||||
}
|
||||
|
||||
// This is annoying (:
|
||||
@@ -512,7 +524,7 @@ const AppCreator = (props) => {
|
||||
//console.log("Handle requestbody: ", methodvalue["requestBody"])
|
||||
if (methodvalue["requestBody"]["content"] !== undefined) {
|
||||
if (methodvalue["requestBody"]["content"]["application/json"] !== undefined) {
|
||||
if (methodvalue["requestBody"]["content"]["application/json"]["schema"] !== undefined) {
|
||||
if (methodvalue["requestBody"]["content"]["application/json"]["schema"] !== undefined && methodvalue["requestBody"]["content"]["application/json"]["schema"] !== null) {
|
||||
if (methodvalue["requestBody"]["content"]["application/json"]["schema"]["properties"] !== undefined) {
|
||||
var tmpobject = {}
|
||||
for (let [prop, propvalue] of Object.entries(methodvalue["requestBody"]["content"]["application/json"]["schema"]["properties"])) {
|
||||
@@ -529,7 +541,7 @@ const AppCreator = (props) => {
|
||||
}
|
||||
} else if (methodvalue["requestBody"]["content"]["application/xml"] !== undefined) {
|
||||
console.log("METHOD XML: ", methodvalue)
|
||||
if (methodvalue["requestBody"]["content"]["application/xml"]["schema"] !== undefined) {
|
||||
if (methodvalue["requestBody"]["content"]["application/xml"]["schema"] !== undefined && methodvalue["requestBody"]["content"]["application/xml"]["schema"] !== null) {
|
||||
if (methodvalue["requestBody"]["content"]["application/xml"]["schema"]["properties"] !== undefined) {
|
||||
var tmpobject = {}
|
||||
for (let [prop, propvalue] of Object.entries(methodvalue["requestBody"]["content"]["application/xml"]["schema"]["properties"])) {
|
||||
@@ -555,7 +567,7 @@ const AppCreator = (props) => {
|
||||
|
||||
console.log(methodvalue["requestBody"]["content"])
|
||||
if (methodvalue["requestBody"]["content"]["multipart/form-data"] !== undefined) {
|
||||
if (methodvalue["requestBody"]["content"]["multipart/form-data"]["schema"] !== undefined) {
|
||||
if (methodvalue["requestBody"]["content"]["multipart/form-data"]["schema"] !== undefined && methodvalue["requestBody"]["content"]["multipart/form-data"]["schema"] !== null) {
|
||||
if (methodvalue["requestBody"]["content"]["multipart/form-data"]["schema"]["type"] === "object") {
|
||||
const fieldname = methodvalue["requestBody"]["content"]["multipart/form-data"]["schema"]["properties"]["fieldname"]
|
||||
if (fieldname !== undefined) {
|
||||
@@ -616,7 +628,7 @@ const AppCreator = (props) => {
|
||||
} else if (parameter.in === "header") {
|
||||
newaction.headers += `${parameter.name}=${parameter.example}\n`
|
||||
} else {
|
||||
console.log("WARNING: don't know how to handle: ", parameter)
|
||||
console.log("WARNING: don't know how to handle this param: ", parameter)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -734,6 +746,17 @@ const AppCreator = (props) => {
|
||||
}
|
||||
}
|
||||
|
||||
if (newActions.length > increaseAmount-1) {
|
||||
setActionAmount(increaseAmount)
|
||||
} else {
|
||||
setActionAmount(newActions.length)
|
||||
}
|
||||
|
||||
if (newActions.length > 1000) {
|
||||
alert.error("Cut down actions from "+newActions.length+" to 999 because of limit")
|
||||
newActions = newActions.slice(0,999)
|
||||
}
|
||||
|
||||
setActions(newActions)
|
||||
setIsAppLoaded(true)
|
||||
}
|
||||
@@ -811,6 +834,11 @@ const AppCreator = (props) => {
|
||||
}
|
||||
|
||||
const regex = /[A-Za-z0-9 _]/g;
|
||||
if (item.name === undefined) {
|
||||
console.log("Skipping action ", item)
|
||||
continue
|
||||
}
|
||||
|
||||
const found = item.name.match(regex);
|
||||
if (found !== null) {
|
||||
item.name = found.join("")
|
||||
@@ -1326,7 +1354,7 @@ const AppCreator = (props) => {
|
||||
null
|
||||
:
|
||||
<div>
|
||||
{actions.map((data, index) => {
|
||||
{actions.slice(0,actionAmount).map((data, index) => {
|
||||
var error = data.errors.length > 0 ?
|
||||
<Tooltip color="primary" title={data.errors.join("\n")} placement="bottom">
|
||||
<ErrorOutline />
|
||||
@@ -1745,11 +1773,13 @@ const AppCreator = (props) => {
|
||||
id: 'method-option',
|
||||
}}
|
||||
>
|
||||
{actionNonBodyRequest.map(data => (
|
||||
<MenuItem style={{backgroundColor: inputColor, color: "white"}} value={data}>
|
||||
{actionNonBodyRequest.map((data, index) => {
|
||||
return (
|
||||
<MenuItem key={index} style={{backgroundColor: inputColor, color: "white"}} value={data}>
|
||||
{data}
|
||||
</MenuItem>
|
||||
))}
|
||||
)
|
||||
})}
|
||||
{actionBodyRequest.map(data => (
|
||||
<MenuItem style={{backgroundColor: inputColor, color: "white"}} value={data}>
|
||||
{data}
|
||||
@@ -2001,27 +2031,40 @@ const AppCreator = (props) => {
|
||||
|
||||
const actionView =
|
||||
<div style={{color: "white"}}>
|
||||
<h2>Actions</h2>
|
||||
<h2>Actions ({actions.length})</h2>
|
||||
Actions are the tasks performed by an app. Read more about actions and apps
|
||||
<Link target="_blank" to="https://shuffler.io/docs/apps#actions" style={{textDecoration: "none", color: "#f85a3e"}}> here</Link>.
|
||||
<div>
|
||||
{loopActions}
|
||||
<Button color="primary" style={{marginTop: "20px", borderRadius: "0px"}} variant="outlined" onClick={() => {
|
||||
setCurrentAction({
|
||||
"name": "",
|
||||
"description": "",
|
||||
"url": "",
|
||||
"file_field": "",
|
||||
"headers": "",
|
||||
"queries": [],
|
||||
"paths": [],
|
||||
"body": "",
|
||||
"errors": [],
|
||||
"method": actionNonBodyRequest[0],
|
||||
})
|
||||
setCurrentActionMethod(actionNonBodyRequest[0])
|
||||
setActionsModalOpen(true)
|
||||
}}>New action</Button>
|
||||
<div style={{display: "flex"}}>
|
||||
<Button color="primary" style={{marginTop: "20px", borderRadius: "0px"}} variant="outlined" onClick={() => {
|
||||
setCurrentAction({
|
||||
"name": "",
|
||||
"description": "",
|
||||
"url": "",
|
||||
"file_field": "",
|
||||
"headers": "",
|
||||
"queries": [],
|
||||
"paths": [],
|
||||
"body": "",
|
||||
"errors": [],
|
||||
"method": actionNonBodyRequest[0],
|
||||
})
|
||||
setCurrentActionMethod(actionNonBodyRequest[0])
|
||||
setActionsModalOpen(true)
|
||||
}}>New action</Button>
|
||||
{actionAmount > 0 && actionAmount < actions.length ? null :
|
||||
<Button color="primary" style={{marginTop: "20px", borderRadius: "0px", textAlign: "center"}} variant="outlined" onClick={() => {
|
||||
if (actionAmount+increaseAmount > actions.length) {
|
||||
setActionAmount(actions.length)
|
||||
} else {
|
||||
setActionAmount(actionAmount+increaseAmount)
|
||||
}
|
||||
}}>
|
||||
See more actions
|
||||
</Button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import {Link} from 'react-router-dom';
|
||||
import Breadcrumbs from '@material-ui/core/Breadcrumbs';
|
||||
import ReactJson from 'react-json-view'
|
||||
import Chip from '@material-ui/core/Chip';
|
||||
import { useTheme } from '@material-ui/core/styles';
|
||||
|
||||
import CachedIcon from '@material-ui/icons/Cached';
|
||||
import CloudDownloadIcon from '@material-ui/icons/CloudDownload';
|
||||
@@ -113,6 +114,7 @@ const Apps = (props) => {
|
||||
const { globalUrl, isLoggedIn, isLoaded, userdata } = props;
|
||||
|
||||
//const [workflows, setWorkflows] = React.useState([]);
|
||||
const theme = useTheme();
|
||||
const baseRepository = "https://github.com/frikky/shuffle-apps"
|
||||
const alert = useAlert()
|
||||
const [selectedApp, setSelectedApp] = React.useState({});
|
||||
@@ -316,10 +318,18 @@ const Apps = (props) => {
|
||||
boxColor = "orange"
|
||||
}
|
||||
|
||||
if (data.invalid) {
|
||||
boxColor = "red"
|
||||
}
|
||||
|
||||
//<div style={{backgroundColor: theme.palette.inputColor, height: 100, width: 100, borderRadius: 3, verticalAlign: "middle", textAlign: "center", display: "table-cell"}}>
|
||||
// <div style={{width: "100px", height: "100px", border: "1px solid black", verticalAlign: "middle", textAlign: "center", display: "table-cell"}}>
|
||||
var imageline = data.large_image.length === 0 ?
|
||||
<img alt={data.title} style={{width: 100, height: 100}} />
|
||||
<img alt={data.title} style={{width: 100, height: 100, backgroundColor: theme.palette.inputColor,}} />
|
||||
:
|
||||
<img alt={data.title} src={data.large_image} style={{width: 100, height: 100, maxWidth: "100%"}} />
|
||||
<img alt={data.title} src={data.large_image} style={{maxWidth: 100, maxHeight: "100%", display: "block", margin: "0 auto"}} onLoad={(event) => {
|
||||
//console.log("IMG LOADED!: ", event.target)
|
||||
}} />
|
||||
|
||||
// FIXME - add label to apps, as this might be slow with A LOT of apps
|
||||
var newAppname = data.name
|
||||
@@ -341,7 +351,7 @@ const Apps = (props) => {
|
||||
}
|
||||
|
||||
var description = data.description
|
||||
const maxDescLen = 56
|
||||
const maxDescLen = 51
|
||||
if (description.length > maxDescLen) {
|
||||
description = data.description.slice(0, maxDescLen)+"..."
|
||||
}
|
||||
@@ -364,8 +374,8 @@ const Apps = (props) => {
|
||||
}
|
||||
}
|
||||
}}>
|
||||
<Grid container style={{margin: 10, flex: "10"}}>
|
||||
<ButtonBase>
|
||||
<Grid container style={{margin: 10, flex: "10", maxHeight: 110, overflow: "hidden",}}>
|
||||
<ButtonBase style={{backgroundColor: theme.palette.inputColor, border: 3}}>
|
||||
{imageline}
|
||||
</ButtonBase>
|
||||
<div style={{marginLeft: "10px", marginTop: "5px", marginBottom: "5px", width: boxWidth, backgroundColor: boxColor}}>
|
||||
@@ -520,9 +530,9 @@ const Apps = (props) => {
|
||||
: null
|
||||
|
||||
var imageline = selectedApp.large_image === undefined || selectedApp.large_image.length === 0 ?
|
||||
<img alt={selectedApp.title} style={{width: 100, height: 100}} />
|
||||
<img alt={selectedApp.title} style={{width: 100, height: 100, backgroundColor: theme.palette.inputColor,}} />
|
||||
:
|
||||
<img alt={selectedApp.title} src={selectedApp.large_image} style={{width: 100, height: 100, maxWidth: "100%"}} />
|
||||
<img alt={selectedApp.title} src={selectedApp.large_image} style={{maxHeight: 100, maxWidth: 100, backgroundColor: theme.palette.inputColor}} />
|
||||
|
||||
const GetAppExample = () => {
|
||||
if (selectedAction.returns === undefined) {
|
||||
@@ -639,7 +649,7 @@ const Apps = (props) => {
|
||||
updateAppField(selectedApp.id, "sharing", !selectedApp.sharing)
|
||||
//setSelectedAction(event.target.value)
|
||||
}}
|
||||
style={{width: 150, backgroundColor: inputColor, color: "white", height: 35, marginleft: 10,}}
|
||||
style={{width: 150, backgroundColor: theme.palette.surfaceColor, backgroundColor: inputColor, color: "white", height: 35, marginleft: 10,}}
|
||||
SelectDisplayProps={{
|
||||
style: {
|
||||
marginLeft: 10,
|
||||
|
||||
Reference in New Issue
Block a user