Major fixes to app creator

This commit is contained in:
frikky
2020-09-13 08:10:46 +02:00
parent 4d6984e23e
commit 6ec4fed722
8 changed files with 225 additions and 86 deletions
+35 -20
View File
@@ -118,6 +118,7 @@ const AngularWorkflow = (props) => {
const [currentView, setCurrentView] = React.useState(0)
const [triggerAuthentication, setTriggerAuthentication] = React.useState({})
const [triggerFolders, setTriggerFolders] = React.useState([])
const [showEnvironment, setShowEnvironment] = React.useState(false)
const [workflow, setWorkflow] = React.useState({});
const [leftViewOpen, setLeftViewOpen] = React.useState(true);
@@ -766,6 +767,13 @@ const AngularWorkflow = (props) => {
return data
}
// This can be used to only show prioritzed ones later
// Right now, it can prioritize authenticated ones
const internalIds = [
"Shuffle Tools",
"Testing",
"Http",
]
const getAppAuthentication = () => {
fetch(globalUrl+"/api/v1/apps/authentication", {
method: 'GET',
@@ -795,10 +803,6 @@ const AngularWorkflow = (props) => {
});
}
const internalIds = [
"80a1fdd2-95c2-49ab-81f6-e05689beb745", // Shuffle tools
"39c5f8fa-a088-4cdc-826f-19e2e61cb284", // Testing
]
const getApps = () => {
fetch(globalUrl+"/api/v1/workflows/apps", {
@@ -823,11 +827,10 @@ const AngularWorkflow = (props) => {
//tmpapps = tmpapps.concat(getExtraApps())
//tmpapps = tmpapps.concat(responseJson)
setApps(responseJson)
setFilteredApps(responseJson)
getAppAuthentication()
setPrioritizedApps(responseJson.filter(app => internalIds.includes(app.id)))
setFilteredApps(responseJson.filter(app => !internalIds.includes(app.name)))
setPrioritizedApps(responseJson.filter(app => internalIds.includes(app.name)))
})
.catch(error => {
alert.error(error.toString())
@@ -931,7 +934,9 @@ const AngularWorkflow = (props) => {
setSelectedActionEnvironment(env)
setSelectedActionName(curaction.name)
setRequiresAuthentication(curapp.authentication.required)
setRequiresAuthentication(curapp.authentication.required && curapp.authentication.parameters !== undefined && curapp.authentication.parameters !== null)
if (curapp.authentication.required) {
// Setup auth here :)
@@ -1237,12 +1242,20 @@ const AngularWorkflow = (props) => {
})
.then((responseJson) => {
var found = false
var showEnvCnt = 0
for (var key in responseJson) {
if (responseJson[key].default) {
setDefaultEnvironmentIndex(key)
found = true
break
}
if (responseJson[key].archived === false) {
showEnvCnt += 1
}
}
if (showEnvCnt > 1) {
setShowEnvironment(true)
}
if (!found) {
@@ -1813,13 +1826,12 @@ const AngularWorkflow = (props) => {
<Tabs
value={currentView}
indicatorColor="primary"
textColor="white"
onChange={handleSetTab}
aria-label="Left sidebar tab"
>
<Tab label={
<Grid container direction="row" alignItems="center">
<Grid item>
<Grid item>
<AppsIcon style={iconStyle} />
</Grid>
<Grid item>
@@ -2246,16 +2258,16 @@ const AngularWorkflow = (props) => {
<Grid item>
<div style={{borderRadius: borderRadius, height: 80, width: 80, backgroundImage: image, backgroundSize: "cover", backgroundRepeat: "no-repeat"}} />
</Grid>
<Grid style={{display: "flex", flexDirection: "column", marginLeft: "20px"}}>
<Grid style={{display: "flex", flexDirection: "column", marginLeft: "20px", minWidth: 185, maxWidth: 185, overflow: "hidden", maxHeight: 80, }}>
<Grid item style={{flex: 1}}>
<h4 style={{marginBottom: "0px", marginTop: "5px"}}>{newAppname}</h4>
</Grid>
<Grid item style={{flex: 1, width: "100%", }}>
Short description...
<h4 style={{marginBottom: 0, marginTop: 5}}>{newAppname}</h4>
</Grid>
<Grid item style={{flex: 1}}>
Version: {app.app_version}
</Grid>
<Grid item style={{flex: 1, width: "100%", maxHeight: 27, overflow: "hidden",}}>
{app.description}
</Grid>
</Grid>
</Grid>
</Paper>
@@ -2291,12 +2303,12 @@ const AngularWorkflow = (props) => {
*/}
{prioritizedApps.map((app, index) => {
return(
<ParsedAppPaper app={app} />
<ParsedAppPaper key={index} app={app} />
)
})}
{filteredApps.filter(innerapp => !internalIds.includes(innerapp.id)).map((app, index) => {
return(
<ParsedAppPaper app={app} />
<ParsedAppPaper key={index} app={app} />
)
})}
</div>
@@ -2637,6 +2649,9 @@ const AngularWorkflow = (props) => {
data.variant = "STATIC_VALUE"
}
// selectedAction.selectedAuthentication = e.target.value
// selectedAction.authentication_id = e.target.value.id
if (!selectedAction.auth_not_required && selectedAction.selectedAuthentication !== undefined && selectedAction.selectedAuthentication.fields !== undefined && selectedAction.selectedAuthentication.fields[data.name] !== undefined) {
// This sets the placeholder in the frontend. (Replaced in backend)
selectedActionParameters[count].value = selectedAction.selectedAuthentication.fields[data.name]
@@ -3227,7 +3242,7 @@ const AngularWorkflow = (props) => {
</div>
</div>
: null}
{environments !== undefined && environments !== null && environments.length > 1 ?
{showEnvironment ?
<div style={{marginTop: "20px"}}>
<Typography>
Environment
@@ -5658,7 +5673,7 @@ const AngularWorkflow = (props) => {
return null
}
if (selectedApp.authentication.parameters.length === undefined || selectedApp.authentication.parameters.length === 0) {
if (selectedApp.authentication.parameters === null || selectedApp.authentication.parameters === undefined || selectedApp.authentication.parameters.length === 0) {
return null
}