Merge branch 'launch' into master

This commit is contained in:
Frikky
2021-10-31 22:21:17 +01:00
committed by GitHub
33 changed files with 1973 additions and 3782 deletions
+156 -13
View File
@@ -2,8 +2,9 @@ import React, { useEffect} from 'react';
import { makeStyles } from '@material-ui/core/styles';
import { useTheme } from '@material-ui/core/styles';
import { Grid, Paper, Tooltip, Button, TextField, FormControl, IconButton, Menu, MenuItem, Chip, Typography, CircularProgress, Dialog, DialogTitle, DialogActions, DialogContent} from '@material-ui/core';
import {GridOn as GridOnIcon, List as ListIcon, Close as CloseIcon, Compare as CompareIcon, Maximize as MaximizeIcon, Minimize as MinimizeIcon, AddCircle as AddCircleIcon, Toc as TocIcon, Send as SendIcon, Search as SearchIcon, FileCopy as FileCopyIcon, Delete as DeleteIcon, BubbleChart as BubbleChartIcon, Restore as RestoreIcon, Cached as CachedIcon, GetApp as GetAppIcon, Edit as EditIcon, MoreVert as MoreVertIcon, PlayArrow as PlayArrowIcon, Add as AddIcon, Publish as PublishIcon, CloudUpload as CloudUploadIcon, CloudDownload as CloudDownloadIcon} from '@material-ui/icons';
import {Badge, Avatar, Grid, Paper, Tooltip, Divider, Button, TextField, FormControl, IconButton, Menu, MenuItem, FormControlLabel, Chip, Switch, Typography, Zoom, CircularProgress, Dialog, DialogTitle, DialogActions, DialogContent} from '@material-ui/core';
import {GridOn as GridOnIcon, List as ListIcon, Close as CloseIcon, Compare as CompareIcon, Maximize as MaximizeIcon, Minimize as MinimizeIcon, AddCircle as AddCircleIcon, Toc as TocIcon, Send as SendIcon, Search as SearchIcon, FileCopy as FileCopyIcon, Delete as DeleteIcon, BubbleChart as BubbleChartIcon, Restore as RestoreIcon, Cached as CachedIcon, GetApp as GetAppIcon, Apps as AppsIcon, Edit as EditIcon, MoreVert as MoreVertIcon, PlayArrow as PlayArrowIcon, Add as AddIcon, Publish as PublishIcon, CloudUpload as CloudUploadIcon, CloudDownload as CloudDownloadIcon} from '@material-ui/icons';
import NestedMenuItem from "material-ui-nested-menu-item";
//import {Search as SearchIcon, ArrowUpward as ArrowUpwardIcon, Visibility as VisibilityIcon, Done as DoneIcon, Close as CloseIcon, Error as ErrorIcon, FindReplace as FindreplaceIcon, ArrowLeft as ArrowLeftIcon, Cached as CachedIcon, DirectionsRun as DirectionsRunIcon, Add as AddIcon, Polymer as PolymerIcon, FormatListNumbered as FormatListNumberedIcon, Create as CreateIcon, PlayArrow as PlayArrowIcon, AspectRatio as AspectRatioIcon, MoreVert as MoreVertIcon, Apps as AppsIcon, Schedule as ScheduleIcon, FavoriteBorder as FavoriteBorderIcon, Pause as PauseIcon, Delete as DeleteIcon, AddCircleOutline as AddCircleOutlineIcon, Save as SaveIcon, KeyboardArrowLeft as KeyboardArrowLeftIcon, KeyboardArrowRight as KeyboardArrowRightIcon, ArrowBack as ArrowBackIcon, Settings as SettingsIcon, LockOpen as LockOpenIcon, ExpandMore as ExpandMoreIcon, VpnKey as VpnKeyIcon} from '@material-ui/icons';
@@ -291,6 +292,7 @@ const Workflows = (props) => {
const theme = useTheme();
const alert = useAlert()
const classes = useStyles(theme);
const imgSize = 60
const referenceUrl = globalUrl+"/api/v1/hooks/"
@@ -326,6 +328,7 @@ const Workflows = (props) => {
const [view, setView] = React.useState("grid")
const [filters, setFilters] = React.useState([])
const [submitLoading, setSubmitLoading] = React.useState(false)
const [actionImageList, setActionImageList] = React.useState([])
const isCloud = window.location.host === "localhost:3002" || window.location.host === "shuffler.io"
@@ -344,6 +347,7 @@ const Workflows = (props) => {
found = filters.map(filter => curWorkflow.name.toLowerCase().includes(filter))
} else {
found = filters.map(filter => {
const newfilter = filter.toLowerCase()
if (filter === undefined) {
return false
}
@@ -357,10 +361,9 @@ const Workflows = (props) => {
} else if (curWorkflow.org_id === filter) {
return true
} else if (curWorkflow.actions !== null && curWorkflow.actions !== undefined) {
const newfilter = filter.toLowerCase()
for (var key in curWorkflow.actions) {
const action = curWorkflow.actions[key]
if (action.app_name.toLowerCase().includes(newfilter)) {
if (action.app_name.toLowerCase() === newfilter || action.app_name.toLowerCase().includes(newfilter)) {
return true
}
}
@@ -390,7 +393,7 @@ const Workflows = (props) => {
return
}
if (filters.includes(data)) {
if (filters.includes(data) || filters.includes(data.toLowerCase())) {
return
}
@@ -629,6 +632,27 @@ const Workflows = (props) => {
if (responseJson !== undefined) {
setWorkflows(responseJson)
if (responseJson !== undefined) {
var actionnamelist = []
var parsedactionlist = []
for (var key in responseJson) {
for (var actionkey in responseJson[key].actions) {
const action = responseJson[key].actions[actionkey]
console.log("Action: ", action)
if (actionnamelist.includes(action.app_name)) {
continue
}
actionnamelist.push(action.app_name)
parsedactionlist.push(action)
}
}
console.log(parsedactionlist)
setActionImageList(parsedactionlist)
}
setFilteredWorkflows(responseJson)
setWorkflowDone(true)
} else {
@@ -689,6 +713,7 @@ const Workflows = (props) => {
display: "flex",
flexWrap: 'wrap',
alignContent: "space-between",
marginTop: 5,
}
const paperAppStyle = {
@@ -845,6 +870,16 @@ const Workflows = (props) => {
if (sanitize === true) {
data = sanitizeWorkflow(data)
if (data.subflows !== null && data.subflows !== undefined) {
alert.info("Not exporting with subflows when sanitizing. Please manually export them.")
data.subflows = []
}
// for (var key in data.subflows) {
// if (data.sublof
// }
//}
}
// Add correct ID's for triggers
@@ -1065,14 +1100,45 @@ const Workflows = (props) => {
<FileCopyIcon style={{marginLeft: 0, marginRight: 8}}/>
{"Duplicate Workflow"}
</MenuItem>
<NestedMenuItem disabled={userdata.orgs === undefined || userdata.orgs === null || userdata.orgs.length === 1 || userdata.orgs.length >= 0} style={{backgroundColor: inputColor, color: "white"}} onClick={() => {
{/*<NestedMenuItem disabled={userdata.orgs === undefined || userdata.orgs === null || userdata.orgs.length === 1 || userdata.orgs.length >= 0} style={{backgroundColor: inputColor, color: "white"}} onClick={() => {
//copyWorkflow(data)
//setOpen(false)
}} key={"duplicate"}>
<FileCopyIcon style={{marginLeft: 0, marginRight: 8}}/>
{"Copy to Child Org"}
</NestedMenuItem>
</NestedMenuItem>*/}
<MenuItem style={{backgroundColor: inputColor, color: "white"}} onClick={() => {
setExportModalOpen(true)
if (data.triggers !== null && data.triggers !== undefined) {
var newSubflows = []
for (var key in data.triggers) {
const trigger = data.triggers[key]
if (trigger.parameters !== null && trigger.parameters !== undefined) {
for (var subkey in trigger.parameters) {
const param = trigger.parameters[subkey]
if (param.name === "workflow" && param.value !== data.id && !newSubflows.includes(param.value)) {
newSubflows.push(param.value)
}
}
}
}
var parsedworkflows = []
for (var key in newSubflows) {
const foundWorkflow = workflows.find(workflow => workflow.id === newSubflows[key])
if (foundWorkflow !== undefined && foundWorkflow !== null) {
parsedworkflows.push(foundWorkflow)
}
}
if (parsedworkflows.length > 0) {
console.log("Appending subflows during export: ", parsedworkflows.length)
data.subflows = parsedworkflows
}
}
setExportData(data)
setOpen(false)
}} key={"export"}>
@@ -1389,7 +1455,7 @@ const Workflows = (props) => {
let workflowData = "";
if (workflows.length > 0) {
const columns = [
{ field: 'image', headerName: 'Logo', width: 42, renderCell: (params) => {
{ field: 'image', headerName: 'Logo', width: 50, sortable: false, renderCell: (params) => {
const data = params.row.record
var boxColor = "#FECC00"
@@ -1430,7 +1496,7 @@ const Workflows = (props) => {
return (
<Grid item>
<Link to={`/workflows/{data.id}`} style={{textDecoration: "none", color: "inherit",}}>
<Link to={"/workflows/"+data.id} style={{textDecoration: "none", color: "inherit",}}>
<Typography>
{data.name}
</Typography>
@@ -1539,7 +1605,7 @@ const Workflows = (props) => {
}
];
let rows = [];
rows = workflows.map((data, index) => {
rows = filteredWorkflows.map((data, index) => {
let obj = {
"id":index+1,
"title":data.name,
@@ -1547,7 +1613,7 @@ const Workflows = (props) => {
}
return obj;
});
})
workflowData =
<DataGrid
color="primary"
@@ -1691,7 +1757,7 @@ const Workflows = (props) => {
}} color="primary">
{submitLoading ?
<CircularProgress />
<CircularProgress color="secondary" />
:
"Submit"
}
@@ -1805,6 +1871,53 @@ const Workflows = (props) => {
<h2>Workflows</h2>
</div>
</div>
{/*
<div style={flexContainerStyle}>
<div style={{...flexBoxStyle, ...activeWorkflowStyle}}>
<div style={flexContentStyle}>
<div><img src={mobileImage} style={iconStyle} /></div>
<div style={ blockRightStyle }>
<div style={counterStyle}>{workflows.length}</div>
<div style={fontSize_16}>ACTIVE WORKFLOWS</div>
</div>
</div>
</div>
<div style={{...flexBoxStyle, ...availableWorkflowStyle}}>
<div style={flexContentStyle}>
<div><img src={bookImage} style={iconStyle} /></div>
<div style={ blockRightStyle }>
<div style={counterStyle}>{workflows.length}</div>
<div style={fontSize_16}>AVAILABE WORKFLOWS</div>
</div>
</div>
</div>
<div style={{...flexBoxStyle, ...notificationStyle}}>
<div style={flexContentStyle}>
<div><img src={bagImage} style={iconStyle} /></div>
<div style={ blockRightStyle }>
<div style={counterStyle}>{workflows.length}</div>
<div style={fontSize_16}>NOTIFICATIONS</div>
</div>
</div>
</div>
</div>
*/}
{/*
chipRenderer={({ value, isFocused, isDisabled, handleClick, handleRequestDelete }, key) => {
console.log("VALUE: ", value)
return (
<Chip
key={key}
style={chipStyle}
>
{value}
</Chip>
)
}}
*/}
<div style={{display: "flex", margin: "0px 0px 20px 0px"}}>
<div style={{flex: 1}}>
<Typography style={{marginTop: 7, marginBottom: "auto"}}>
@@ -1836,6 +1949,36 @@ const Workflows = (props) => {
</div>
</div>
<div style={{marginTop: 15,}} />
{actionImageList !== undefined && actionImageList !== null && actionImageList.length > 0 ?
<div style={{display: "flex", maxWidth: 1024, zIndex: 11, border: "1px solid rgba(255,255,255,0.1)", borderRadius: theme.palette.borderRadius, textAlign: "center", overflow: "auto",}}>
{actionImageList.map((data, index) => {
if (data.large_image === undefined || data.large_image === null || data.large_image.length === 0) {
return null
}
if (data.app_name.toLowerCase() === "shuffle tools") {
data.large_image = theme.palette.defaultImage
}
return (
<span style={{zIndex: 10}}>
<IconButton style={{backgroundColor: "transparent", margin: 0, padding: 12, }} onClick={() => {
console.log("FILTER: ", data)
addFilter(data.app_name)
}}>
<Tooltip title={`Filter by ${data.app_name}`} placement="top">
<Badge badgeContent={0} color="secondary" style={{fontSize: 10}}>
<div style={{height: imgSize, width: imgSize, position: "relative", filter: "brightness(0.6)", backgroundColor: "#000", borderRadius: imgSize/2, zIndex: 100, overflow: "hidden", display: "flex", justifyContent: "center", }}>
<img style={{height: imgSize, width: imgSize, position: "absolute", top: -2, left: -2, cursor: "pointer", zIndex: 99, border: "2px solid rgba(255,255,255,0.7)", }} alt={data.app_name} src={data.large_image}/>
</div>
</Badge>
</Tooltip>
</IconButton>
</span>
)
})}
</div>
: null}
{view === "grid" ?
<Grid container spacing={4} style={paperAppContainer}>
<NewWorkflowPaper />