Made it possible to edit public workflows (frontend)

This commit is contained in:
frikky
2022-03-25 02:18:25 +01:00
parent 79b24f76d8
commit cff2b88845
3 changed files with 44 additions and 20 deletions
+1
View File
@@ -5796,6 +5796,7 @@ func handleAppZipUpload(resp http.ResponseWriter, request *http.Request) {
panic(err) panic(err)
} }
// https://github.com/alexmullins/zip/blob/master/example_test.go
for _, item := range zipdata.File { for _, item := range zipdata.File {
log.Printf("\n\nName: %s\n\n", item.FileHeader.Name) log.Printf("\n\nName: %s\n\n", item.FileHeader.Name)
log.Printf("item: %#v", item) log.Printf("item: %#v", item)
+43 -19
View File
@@ -1615,7 +1615,7 @@ const AngularWorkflow = (defaultprops) => {
} }
if (responseJson.public) { if (responseJson.public) {
alert.info("This workflow is public. Save the workflow to start using it."); alert.info("This workflow is public. Save the workflow to use it in your organization.");
console.log("RESP: ", responseJson) console.log("RESP: ", responseJson)
if (Object.getOwnPropertyNames(creatorProfile).length === 0) { if (Object.getOwnPropertyNames(creatorProfile).length === 0) {
@@ -2445,7 +2445,10 @@ const AngularWorkflow = (defaultprops) => {
//var newapps = JSON.parse(JSON.stringify(apps)) //var newapps = JSON.parse(JSON.stringify(apps))
var newapps = apps var newapps = apps
console.log(event.target.data()) if (apps === null || apps === undefined || apps.length === 0) {
newapps = filteredApps
}
const curapp = newapps.find( const curapp = newapps.find(
(a) => (a) =>
a.name === curaction.app_name && a.name === curaction.app_name &&
@@ -2454,9 +2457,8 @@ const AngularWorkflow = (defaultprops) => {
a.loop_versions.includes(curaction.app_version))) a.loop_versions.includes(curaction.app_version)))
); );
if (!curapp || curapp === undefined) { if (!curapp || curapp === undefined) {
alert.error( console.log("APPS: ", newapps)
`App ${curaction.app_name}:${curaction.app_version} not found. Is it activated?` //alert.error(`App ${curaction.app_name}:${curaction.app_version} not found. Is it activated?`);
);
const tmpapp = { const tmpapp = {
name: curaction.app_name, name: curaction.app_name,
@@ -3601,7 +3603,7 @@ const AngularWorkflow = (defaultprops) => {
// FIXME: Don't allow multiple in cloud yet. Cloud -> Onprem isn't stable. // FIXME: Don't allow multiple in cloud yet. Cloud -> Onprem isn't stable.
if (isCloud) { if (isCloud) {
console.log("Envs: ", responseJson) console.log("Envs: ", responseJson)
if (responseJson.length > 0) { if (responseJson !== undefined && responseJson !== null && responseJson.length > 0) {
setEnvironments(responseJson); setEnvironments(responseJson);
} else { } else {
setEnvironments([{ Name: "Cloud", Type: "cloud" }]); setEnvironments([{ Name: "Cloud", Type: "cloud" }]);
@@ -11025,7 +11027,7 @@ const AngularWorkflow = (defaultprops) => {
<AvatarGroup max={6} style={{marginLeft: 10, }}> <AvatarGroup max={6} style={{marginLeft: 10, }}>
{triggerGroup.map((data, index) => { {triggerGroup.map((data, index) => {
return ( return (
<Avatar alt={data.app_name} src={data.large_image} style={{width: 30, height: 30}}/> <Avatar key={index} alt={data.app_name} src={data.large_image} style={{width: 30, height: 30}}/>
) )
})} })}
</AvatarGroup> </AvatarGroup>
@@ -11034,12 +11036,13 @@ const AngularWorkflow = (defaultprops) => {
<div style={{display: "flex", marginTop: 10, }}> <div style={{display: "flex", marginTop: 10, }}>
<Typography variant="body1"> <Typography variant="body1">
Mitre Att&ck: Mitre Att&ck:&nbsp;
</Typography> </Typography>
<Typography variant="body1" color="textSecondary"> <Typography variant="body1" color="textSecondary">
TBD TBD
</Typography> </Typography>
</div> </div>
{/*
<div style={{display: "flex", marginTop: 10, }}> <div style={{display: "flex", marginTop: 10, }}>
<Typography variant="body1"> <Typography variant="body1">
Related Workflows: Related Workflows:
@@ -11048,6 +11051,7 @@ const AngularWorkflow = (defaultprops) => {
TBD TBD
</Typography> </Typography>
</div> </div>
*/}
{workflow.description !== undefined && workflow.description !== null && workflow.description.length > 0 ? {workflow.description !== undefined && workflow.description !== null && workflow.description.length > 0 ?
<div style={{marginTop: 5, }}> <div style={{marginTop: 5, }}>
<Typography variant="body1"> <Typography variant="body1">
@@ -11059,17 +11063,37 @@ const AngularWorkflow = (defaultprops) => {
</div> </div>
: null} : null}
{userdata.avatar === creatorProfile.github_avatar ? {userdata.avatar === creatorProfile.github_avatar ?
<Button <div style={{marginTop: 50, }}>
color="secondary" <Button
variant="outlined" color="primary"
fullWidth variant="contained"
style={{marginTop: 15, }} fullWidth
onClick={() => { style={{marginTop: 15, }}
setEditWorkflowDetails(true) onClick={() => {
}} //setEditWorkflowDetails(true)
> workflow.public = false
Edit Details setWorkflow(workflow)
</Button> setUpdate(Math.random());
}}
>
Edit Workflow
</Button>
<Button
color="secondary"
disabled
variant="outlined"
fullWidth
style={{marginTop: 15, }}
onClick={() => {
// setEditWorkflowDetails(true)
// workflow.public = false
// setWorkflow(workflow)
// setUpdate(Math.random());
}}
>
Unpublish Workflow
</Button>
</div>
: null} : null}
</div> </div>
: isMobile && leftViewOpen ? : isMobile && leftViewOpen ?
-1
View File
@@ -1666,7 +1666,6 @@ const Workflows = (props) => {
} }
} }
console.log("data: ", data)
return ( return (
<div style={{width: "100%", position: "relative",}}> <div style={{width: "100%", position: "relative",}}>
<Paper square style={paperAppStyle}> <Paper square style={paperAppStyle}>