diff --git a/backend/go-app/main.go b/backend/go-app/main.go index d15e31f5..54733b33 100644 --- a/backend/go-app/main.go +++ b/backend/go-app/main.go @@ -6086,7 +6086,8 @@ func initHandlers() { r.HandleFunc("/api/v1/files/namespaces/{namespace}", shuffle.HandleGetFileNamespace).Methods("GET", "OPTIONS") r.HandleFunc("/api/v1/files/{fileId}/content", shuffle.HandleGetFileContent).Methods("GET", "OPTIONS") r.HandleFunc("/api/v1/files/create", shuffle.HandleCreateFile).Methods("POST", "OPTIONS") - r.HandleFunc("/api/v1/files/{fileId}/upload", shuffle.HandleUploadFile).Methods("POST", "OPTIONS") + r.HandleFunc("/api/v1/files/{fileId}/upload", shuffle.HandleUploadFile).Methods("POST", "OPTIONS", "PATCH") + r.HandleFunc("/api/v1/files/{fileId}/edit", shuffle.HandleEditFile).Methods("PUT", "OPTIONS") r.HandleFunc("/api/v1/files/{fileId}", shuffle.HandleGetFileMeta).Methods("GET", "OPTIONS") r.HandleFunc("/api/v1/files/{fileId}", shuffle.HandleDeleteFile).Methods("DELETE", "OPTIONS") r.HandleFunc("/api/v1/files", shuffle.HandleGetFiles).Methods("GET", "OPTIONS") diff --git a/frontend/src/components/ShuffleCodeEditor.jsx b/frontend/src/components/ShuffleCodeEditor.jsx index bd8c83ed..527aac8b 100644 --- a/frontend/src/components/ShuffleCodeEditor.jsx +++ b/frontend/src/components/ShuffleCodeEditor.jsx @@ -23,7 +23,7 @@ import { } from "@material-ui/icons"; import { - AutoFixHigh as AutoFixHighIcon, CompressOutlined, + AutoFixHigh as AutoFixHighIcon, CompressOutlined, QrCodeScannerOutlined, } from '@mui/icons-material'; import { useTheme } from '@material-ui/core/styles'; @@ -37,6 +37,7 @@ import 'codemirror/addon/selection/mark-selection.js' import 'codemirror/theme/gruvbox-dark.css'; import 'codemirror/theme/duotone-light.css'; import { padding, textAlign } from '@mui/system'; +import data from '../frameworkStyle.jsx'; const liquidFilters = [ {"name": "Size", "value": "size", "example": ""}, @@ -54,7 +55,7 @@ const pythonFilters = [ ] const CodeEditor = (props) => { - const { fieldCount, setFieldCount, actionlist, changeActionParameterCodeMirror, expansionModalOpen, setExpansionModalOpen, codedata, setcodedata } = props + const { fieldCount, setFieldCount, actionlist, changeActionParameterCodeMirror, expansionModalOpen, setExpansionModalOpen, codedata, setcodedata, isFileEditor, runUpdateText } = props const [localcodedata, setlocalcodedata] = React.useState(codedata === undefined || codedata === null || codedata.length === 0 ? "" : codedata); // const {codelang, setcodelang} = props const theme = useTheme(); @@ -79,11 +80,16 @@ const CodeEditor = (props) => { const mathOpen = Boolean(anchorEl2); const pythonOpen = Boolean(anchorEl3); + // console.log("is it file editor? - ", isFileEditor); useEffect(() => { var allVariables = [] var tmpVariables = [] + if (actionlist === undefined || actionlist === null) { + return + } + for(var i=0; i < actionlist.length; i++){ allVariables.push('$'+actionlist[i].autocomplete.toLowerCase()) tmpVariables.push('$'+actionlist[i].autocomplete.toLowerCase()) @@ -366,7 +372,7 @@ const CodeEditor = (props) => { disableEnforceFocus={true} //style={{ pointerEvents: "none" }} hideBackdrop={true} - open={expansionModalOpen} + open={expansionModalOpen} onClose={() => { console.log("In closer") changeActionParameterCodeMirror({target: {value: ""}}, fieldCount, localcodedata) @@ -384,6 +390,26 @@ const CodeEditor = (props) => { }, }} > + { isFileEditor ? +
+
+ + File Editor + +
+
+ :
{
- - + } + + + { isFileEditor ? null :
+ + } { }}> { @@ -695,7 +723,7 @@ const CodeEditor = (props) => { */} - + {isFileEditor ? null :
{isMobile ? null : { > JSON Validation: {validation ? "Correct" : "Incorrect"}

-
+ }
- -
+ //setDealName("") + //setDealAddress("") + //setDealCountry("") + //setDealValue("") + }} + > + Cancel + + + ); @@ -1979,8 +2135,8 @@ const Admin = (props) => { open={selectedUserModalOpen} onClose={() => { setSelectedUserModalOpen(false); - setImage2FA(""); - setSecret2FA(""); + setImage2FA(""); + setSecret2FA(""); }} PaperProps={{ style: { @@ -2078,7 +2234,7 @@ const Admin = (props) => { )} - {userOrgEdit} + {userOrgEdit} { color="primary" disabled={selectedUser.username === userdata.username} onClick={() => { - deleteUser(selectedUser) - setSelectedUserModalOpen(false); - }} + deleteUser(selectedUser); + setSelectedUserModalOpen(false); + }} > {selectedUser.active ? "Delete from org" : "Delete from org"} @@ -2116,14 +2272,15 @@ const Admin = (props) => { run2FASetup(userdata); }} disabled={ - (selectedUser.role === "admin" && selectedUser.username !== userdata.username) + selectedUser.role === "admin" && + selectedUser.username !== userdata.username } variant="outlined" color="primary" > - { selectedUser.mfa_info !== undefined && - selectedUser.mfa_info !== null && - selectedUser.mfa_info.active === true + {selectedUser.mfa_info !== undefined && + selectedUser.mfa_info !== null && + selectedUser.mfa_info.active === true ? "Disable 2FA" : "Enable 2FA"} @@ -2407,21 +2564,21 @@ const Admin = (props) => { ); - const submitDeal = (dealName, dealAddress, dealCountry, dealValue) => { - if (dealerror.length > 0) { - setDealerror("") - } + const submitDeal = (dealName, dealAddress, dealCountry, dealValue) => { + if (dealerror.length > 0) { + setDealerror(""); + } - const orgId = selectedOrganization.id; + const orgId = selectedOrganization.id; const data = { - reseller_org: orgId, - name: dealName, - address: dealAddress, - country: dealCountry, - value: dealValue, + reseller_org: orgId, + name: dealName, + address: dealAddress, + country: dealCountry, + value: dealValue, }; - const url = `${globalUrl}/api/v1/orgs/${orgId}/deals` + const url = `${globalUrl}/api/v1/orgs/${orgId}/deals`; fetch(url, { mode: "cors", method: "POST", @@ -2433,33 +2590,35 @@ const Admin = (props) => { "Content-Type": "application/json; charset=utf-8", }, }) - .then(function (response) { - if (response.status !== 200) { - console.log("Error in response"); - } + .then(function (response) { + if (response.status !== 200) { + console.log("Error in response"); + } - return response.json(); - }) - .then(function (responseJson) { - if (responseJson.success === true) { - setSelectedDealModalOpen(false); - alert.success("Added new deal! We will be in touch shortly with an update."); + return response.json(); + }) + .then(function (responseJson) { + if (responseJson.success === true) { + setSelectedDealModalOpen(false); + alert.success( + "Added new deal! We will be in touch shortly with an update." + ); - setDealName("") - setDealAddress("") - setDealValue("") - setDealCountry("United States") - setDealType("MSSP") - } else { - setDealerror(responseJson.reason) - } - }) - .catch(function (error) { - //console.log("Error: ", error); - setDealerror(error.toString()) - alert.error("Failed adding deal reg: ", error) - }); - } + setDealName(""); + setDealAddress(""); + setDealValue(""); + setDealCountry("United States"); + setDealType("MSSP"); + } else { + setDealerror(responseJson.reason); + } + }) + .catch(function (error) { + //console.log("Error: ", error); + setDealerror(error.toString()); + alert.error("Failed adding deal reg: ", error); + }); + }; const cancelSubscriptions = (subscription_id) => { console.log(selectedOrganization); @@ -2796,169 +2955,190 @@ const Admin = (props) => { backgroundColor: theme.palette.inputColor, }} /> - - {isCloud && selectedOrganization.partner_info !== undefined && selectedOrganization.partner_info.reseller === true ? -
+ {isCloud && + selectedOrganization.partner_info !== undefined && + selectedOrganization.partner_info.reseller === true ? ( +
- Reseller dashboard + Reseller dashboard - - - - - - - - + + + + + + + + - - + + - - - - - {dealList.length === 0 ? - - No deals registered yet. Click "Add deal" to register one - - : - dealList.map((deal, index) => { - var bgColor = "#27292d"; - if (index % 2 === 0) { - bgColor = "#1f2023"; - } + + + + + {dealList.length === 0 ? ( + + No deals registered yet. Click "Add deal" to register one + + ) : ( + dealList.map((deal, index) => { + var bgColor = "#27292d"; + if (index % 2 === 0) { + bgColor = "#1f2023"; + } - return ( - - - - - + return ( + + + + + - - - - - - - ) - }) - } - - - -
- : null} + + + + + + ); + }) + )} + + +
+ ) : null} {isCloud && selectedOrganization.subscriptions !== undefined && selectedOrganization.subscriptions !== null && @@ -3218,9 +3398,6 @@ const Admin = (props) => { ); - - - const usersView = curTab === 1 ? (
@@ -3294,12 +3471,14 @@ const Admin = (props) => { primary="MFA" style={{ minWidth: 100, maxWidth: 100 }} /> - {selectedOrganization.child_orgs !== undefined && selectedOrganization.child_orgs !== null && selectedOrganization.child_orgs.length > 0 ? - - : null} + {selectedOrganization.child_orgs !== undefined && + selectedOrganization.child_orgs !== null && + selectedOrganization.child_orgs.length > 0 ? ( + + ) : null} { > Org User - - Org Reader + Org Reader } @@ -3452,40 +3631,63 @@ const Admin = (props) => { } style={{ minWidth: 100, maxWidth: 100 }} /> - {selectedOrganization.child_orgs !== undefined && selectedOrganization.child_orgs !== null && selectedOrganization.child_orgs.length > 0 ? - - : null} - + {selectedOrganization.child_orgs !== undefined && + selectedOrganization.child_orgs !== null && + selectedOrganization.child_orgs.length > 0 ? ( + + ) : null} + { setSelectedUserModalOpen(true); setSelectedUser(data); - // Find matching orgs between current org and current user's access to those orgs - if (userdata.orgs !== undefined && userdata.orgs !== null && userdata.orgs.length > 0 && selectedOrganization.child_orgs !== undefined && selectedOrganization.child_orgs !== null && selectedOrganization.child_orgs.length > 0) { - console.log("In here?") - var active = [] - for (var key in userdata.orgs) { - console.log("ORG: ", userdata.orgs[key]) - const found = selectedOrganization.child_orgs.find(item => item.id === userdata.orgs[key].id) - if (found !== null && found !== undefined) { + // Find matching orgs between current org and current user's access to those orgs + if ( + userdata.orgs !== undefined && + userdata.orgs !== null && + userdata.orgs.length > 0 && + selectedOrganization.child_orgs !== undefined && + selectedOrganization.child_orgs !== null && + selectedOrganization.child_orgs.length > 0 + ) { + console.log("In here?"); + var active = []; + for (var key in userdata.orgs) { + console.log("ORG: ", userdata.orgs[key]); + const found = + selectedOrganization.child_orgs.find( + (item) => item.id === userdata.orgs[key].id + ); + if (found !== null && found !== undefined) { + if ( + data.orgs === undefined || + data.orgs === null + ) { + continue; + } - if (data.orgs === undefined || data.orgs === null) { - continue - } + const subfound = data.orgs.find( + (item) => item === found.id + ); + if ( + subfound !== null && + subfound !== undefined + ) { + active.push(subfound); + } + } + } - const subfound = data.orgs.find(item => item === found.id) - if (subfound !== null && subfound !== undefined) { - active.push(subfound) - } - } - } - - setMatchingOrganizations(active) - } + setMatchingOrganizations(active); + } }} > @@ -3514,8 +3716,8 @@ const Admin = (props) => { get2faCode(data.id); } else { // Should remove? - setImage2FA(""); - setSecret2FA(""); + setImage2FA(""); + setSecret2FA(""); } setShow2faSetup(!show2faSetup); @@ -3596,6 +3798,8 @@ const Admin = (props) => { > Upload files + {/* */} { {fileNamespaces !== undefined && fileNamespaces !== null && fileNamespaces.length > 1 ? ( - + File Category ) : null} - +
+ {renderTextBox ? + + + + + : + + + } + {renderTextBox && { + handleKeyDown(event); + }} + InputProps={{ + style: { + color: "white", + }, + }} + color="primary" + placeholder="File category name" + required + margin="dense" + defaultValue={""} + autoFocus + />}
+ { backgroundColor: theme.palette.inputColor, }} /> + { } return ( - + { }} /> - - + primary= + + + { + setOpenEditor(true) + setOpenFileId(file.id) + readFileData(file) + }} + > + + + + + + + { + downloadFile(file); + }} + > + + + + + + + { + deleteFile(file); + }} + > + + + + + { - downloadFile(file); + const elementName = "copy_element_shuffle"; + var copyText = + document.getElementById(elementName); + if ( + copyText !== null && + copyText !== undefined + ) { + const clipboard = navigator.clipboard; + if (clipboard === undefined) { + alert.error( + "Can only copy over HTTPS (port 3443)" + ); + return; + } + + navigator.clipboard.writeText(file.id); + copyText.select(); + copyText.setSelectionRange( + 0, + 99999 + ); /* For mobile devices */ + + /* Copy the text inside the text field */ + document.execCommand("copy"); + + alert.info(file.id + " copied to clipboard"); + } }} > - + - - - - - { - deleteFile(file); - }} - > - - - - - - { - const elementName = "copy_element_shuffle"; - var copyText = document.getElementById(elementName); - if (copyText !== null && copyText !== undefined) { - const clipboard = navigator.clipboard; - if (clipboard === undefined) { - alert.error( - "Can only copy over HTTPS (port 3443)" - ); - return; - } - - navigator.clipboard.writeText(file.id); - copyText.select(); - copyText.setSelectionRange( - 0, - 99999 - ); /* For mobile devices */ - - /* Copy the text inside the text field */ - document.execCommand("copy"); - - alert.info(file.id + " copied to clipboard"); - } - }} - > - - - - + + style={{ - minWidth: 150, - maxWidth: 150, - overflow: "hidden", + minWidth: 250, + maxWidth: 250, + // overflow: "hidden", }} /> @@ -4105,8 +4409,8 @@ const Admin = (props) => {

App Authentication

- Control the authentication options for individual apps.{" "} - PS: Actions performed here can be destructive! + Control the authentication options for individual apps. PS: Actions + performed here can be destructive!   { primary="Workflows" style={{ minWidth: 100, maxWidth: 100, overflow: "hidden" }} /> - {/* + {/* { bgColor = "#1f2023"; } - //console.log("Auth data: ", data) - if (data.type === "oauth2") { - data.fields = [ - { - "key": "url", - "value": "Secret. Replaced during app execution!", - }, - { - "key": "client_id", - "value": "Secret. Replaced during app execution!", - }, - { - "key": "client_secret", - "value": "Secret. Replaced during app execution!", - }, - { - "key": "scope", - "value": "Secret. Replaced during app execution!", - }] - } + //console.log("Auth data: ", data) + if (data.type === "oauth2") { + data.fields = [ + { + key: "url", + value: "Secret. Replaced during app execution!", + }, + { + key: "client_id", + value: "Secret. Replaced during app execution!", + }, + { + key: "client_secret", + value: "Secret. Replaced during app execution!", + }, + { + key: "scope", + value: "Secret. Replaced during app execution!", + }, + ]; + } return ( @@ -4197,7 +4502,10 @@ const Admin = (props) => { primary= style={{ minWidth: 75, maxWidth: 75 }} /> @@ -4213,7 +4521,7 @@ const Admin = (props) => { primary={data.app.name} style={{ minWidth: 175, maxWidth: 175, marginLeft: 10 }} /> - {/* + {/* { style={{ minWidth: 100, maxWidth: 100, - textAlign: "center", + textAlign: "center", overflow: "hidden", }} /> - {/* + {/* { overflow: "hidden", }} /> - + { @@ -4361,7 +4669,7 @@ const Admin = (props) => { setShowArchived(!showArchived); }} />{" "} - Show disabled + Show disabled { /> { /> { {environment.default ? null : ( - +
@@ -4534,7 +4852,7 @@ const Admin = (props) => { style={{}} variant="contained" color="primary" - disabled={userdata.admin !== "true"} + disabled={userdata.admin !== "true"} onClick={() => { setModalOpen(true); }} @@ -4706,7 +5024,7 @@ const Admin = (props) => { // primary={environment.Registered ? "true" : "false"} const iconStyle = { marginRight: 10 }; - const data = ( + const data = (
{ @@ -4729,7 +5047,7 @@ const Admin = (props) => { /> Users @@ -4742,34 +5060,34 @@ const Admin = (props) => { /> Files /> Schedules /> - - - Environments - - /> - - Organizations - - /> + + + Environments + + /> + + Organizations + + /> {/*window.location.protocol == "http:" && window.location.port === "3000" ? Hybrid/> : null*/} {/*window.location.protocol === "http:" && window.location.port === "3000" ? Categories/> : null*/} @@ -4800,7 +5118,7 @@ const Admin = (props) => { {modalView} {cloudSyncModal} {editUserModal} - {addDealModal} + {addDealModal} {editAuthenticationModal} {data}