From cdf0a1eee768c10228dd6c6fca7cb237b6c2dab1 Mon Sep 17 00:00:00 2001 From: Hari Krishna Date: Mon, 4 Mar 2024 12:28:21 +0000 Subject: [PATCH 1/9] added list of sub orgs --- frontend/src/views/Admin.jsx | 112 +++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) diff --git a/frontend/src/views/Admin.jsx b/frontend/src/views/Admin.jsx index f653bd2c..e6dc8bc0 100755 --- a/frontend/src/views/Admin.jsx +++ b/frontend/src/views/Admin.jsx @@ -1102,6 +1102,40 @@ If you're interested, please let me know a time that works for you, or set up a toast("Error getting current organization"); }); }; +const handleGetSubOrgs = (orgId) => { + + if (serverside !== true && window.location.search !== undefined && window.location.search !== null) { + const urlSearchParams = new URLSearchParams(window.location.search); + const params = Object.fromEntries(urlSearchParams.entries()); + const foundorgid = params["org_id"]; + if (foundorgid !== undefined && foundorgid !== null) { + orgId = foundorgid; + } + } + + if (orgId.length === 0) { + toast("Organization ID not defined. Please contact us on https://shuffler.io if this persists logout."); + return; + } + + fetch(`${globalUrl}/api/v1/subOrgs/${orgId}`, { + method: "GET", + credentials: "include", + headers: { + "Content-Type": "application/json", + }, + }) + .then((response) => { + return response.json(); + }) + .then((responseJson) => { + setSubOrgs(responseJson); + }) + .catch((error) => { + console.log("Error getting sub orgs: ", error); + toast("Error getting sub organizations"); + }); +}; const inviteUser = (data) => { //console.log("INPUT: ", data); @@ -4678,6 +4712,84 @@ If you're interested, please let me know a time that works for you, or set up a backgroundColor: theme.palette.inputColor, }} /> + +{subOrgs.length > 0 ? ( + +
+

Your Sub Organizations of the Current Organization

+
+ + + + + + + + + + + + {subOrgs.map((data, index) => { + const imagesize = 40; + const imageStyle = { + width: imagesize, + height: imagesize, + pointerEvents: "none", + }; + const image = + data.image === "" ? ( + {data.name} + ) : ( + {data.name} + ); + + var bgColor = "#27292d"; + if (index % 2 === 0) { + bgColor = "#1f2023"; + } + + return ( + + + + + + + ); + })} + + + + +
+) : ( + + No Sub-Organizations available. + +)} +
+

All Tenants

+
+ + Date: Mon, 4 Mar 2024 12:47:01 +0000 Subject: [PATCH 2/9] Revert "fixed overflow in conditions" This reverts commit 906333d8a2dea3d8a2d486c3b20803edf001c059. --- frontend/src/views/AngularWorkflow.jsx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/frontend/src/views/AngularWorkflow.jsx b/frontend/src/views/AngularWorkflow.jsx index 3f397674..2f461690 100755 --- a/frontend/src/views/AngularWorkflow.jsx +++ b/frontend/src/views/AngularWorkflow.jsx @@ -9767,8 +9767,6 @@ const AngularWorkflow = (defaultprops) => { marginTop: "15px", marginLeft: "10px", overflow: "hidden", - textOverflow: "ellipsis", - whiteSpace: "nowrap", maxWidth: 72, }} > @@ -9788,7 +9786,7 @@ const AngularWorkflow = (defaultprops) => { flex: 1, textAlign: "center", marginTop: "15px", - overflow: "hidden", + overflow: "hidden", maxWidth: 72, }} onClick={() => { }} @@ -9812,8 +9810,6 @@ const AngularWorkflow = (defaultprops) => { marginBottom: "auto", marginLeft: "10px", overflow: "hidden", - textOverflow: "ellipsis", - whiteSpace: "nowrap", maxWidth: 72, }} > From 1e510c6b84a3936c65348ec0a3337ece99da925e Mon Sep 17 00:00:00 2001 From: Hari Krishna Date: Sat, 24 Feb 2024 11:37:36 +0000 Subject: [PATCH 3/9] Added a way to get the sub orgs of the current org --- backend/go-app/main.go | 1 + frontend/src/views/Admin.jsx | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/backend/go-app/main.go b/backend/go-app/main.go index b2e901d5..8b4264d5 100755 --- a/backend/go-app/main.go +++ b/backend/go-app/main.go @@ -4923,6 +4923,7 @@ func initHandlers() { r.HandleFunc("/api/v1/orgs/{orgId}/change", shuffle.HandleChangeUserOrg).Methods("POST", "OPTIONS") // Swaps to the org r.HandleFunc("/api/v1/orgs/{orgId}", shuffle.HandleDeleteOrg).Methods("DELETE", "OPTIONS") + r.HandleFunc("/api/v1/subOrg/{orgId}", shuffle.HandleGetSubOrg).Methods("GET", "OPTIONS") // This is a new API that validates if a key has been seen before. // Not sure what the best course of action is for it. diff --git a/frontend/src/views/Admin.jsx b/frontend/src/views/Admin.jsx index e6dc8bc0..674eaeb0 100755 --- a/frontend/src/views/Admin.jsx +++ b/frontend/src/views/Admin.jsx @@ -162,6 +162,7 @@ const Admin = (props) => { const [loginInfo, setLoginInfo] = React.useState(""); const [curTab, setCurTab] = React.useState(0); const [users, setUsers] = React.useState([]); + const [subOrgs, setSubOrgs] = useState([]); const [organizations, setOrganizations] = React.useState([]); const [orgSyncResponse, setOrgSyncResponse] = React.useState(""); const [userSettings, setUserSettings] = React.useState({}); @@ -204,6 +205,10 @@ const Admin = (props) => { } }, [isDropzone]); + useEffect(() => { + handleGetSubOrgs(userdata.active_org.id); + }, []); + const isCloud = window.location.host === "localhost:3002" || window.location.host === "shuffler.io"; const get2faCode = (userId) => { From 4a3d956023ddd7b8b3b502244174878c89243727 Mon Sep 17 00:00:00 2001 From: Hari Krishna Date: Mon, 4 Mar 2024 12:28:21 +0000 Subject: [PATCH 4/9] added list of sub orgs --- frontend/src/views/Admin.jsx | 68 +++++++++++++++++++++++++++++++++--- 1 file changed, 64 insertions(+), 4 deletions(-) diff --git a/frontend/src/views/Admin.jsx b/frontend/src/views/Admin.jsx index 674eaeb0..629b5a4b 100755 --- a/frontend/src/views/Admin.jsx +++ b/frontend/src/views/Admin.jsx @@ -1142,6 +1142,57 @@ const handleGetSubOrgs = (orgId) => { }); }; +const handleClickChangeOrg = (orgId) => { + // Don't really care about the logout + //name: org.name, + //orgId = "asd" + const data = { + org_id: orgId, + } + + localStorage.setItem("globalUrl", "") + localStorage.setItem("getting_started_sidebar", "open"); + + fetch(`${globalUrl}/api/v1/orgs/${orgId}/change`, { + mode: 'cors', + credentials: 'include', + crossDomain: true, + method: 'POST', + body: JSON.stringify(data), + withCredentials: true, + headers: { + 'Content-Type': 'application/json; charset=utf-8', + }, + }) + .then(function(response) { + if (response.status !== 200) { + console.log("Error in response") + } + + return response.json(); + }).then(function(responseJson) { + if (responseJson.success === true) { + if (responseJson.region_url !== undefined && responseJson.region_url !== null && responseJson.region_url.length > 0) { + console.log("Region Change: ", responseJson.region_url) + localStorage.setItem("globalUrl", responseJson.region_url) + //globalUrl = responseJson.region_url + } + + setTimeout(() => { + window.location.reload() + }, 2000) + toast("Successfully changed active organization - refreshing!") + } else { + toast("Failed changing org: ", responseJson.reason) + } + }) + .catch(error => { + console.log("error changing: ", error) + //removeCookie("session_token", {path: "/"}) + }) +} + + const inviteUser = (data) => { //console.log("INPUT: ", data); setLoginInfo(""); @@ -4761,10 +4812,19 @@ const handleGetSubOrgs = (orgId) => { return ( - - - - + + + + + ); })} From c581618817840e836d27ed5543092107c91f7286 Mon Sep 17 00:00:00 2001 From: Hari Krishna Date: Tue, 5 Mar 2024 07:29:22 +0000 Subject: [PATCH 5/9] fixed few issues with the frontend --- frontend/src/views/Admin.jsx | 77 ++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 35 deletions(-) diff --git a/frontend/src/views/Admin.jsx b/frontend/src/views/Admin.jsx index 629b5a4b..63800693 100755 --- a/frontend/src/views/Admin.jsx +++ b/frontend/src/views/Admin.jsx @@ -206,8 +206,12 @@ const Admin = (props) => { }, [isDropzone]); useEffect(() => { - handleGetSubOrgs(userdata.active_org.id); - }, []); + if (userdata.orgs !== undefined && userdata.orgs !== null && userdata.orgs.length > 0) { + handleGetSubOrgs(userdata.active_org.id); + } + else console.log("error in user data") + }, [userdata]); + const isCloud = window.location.host === "localhost:3002" || window.location.host === "shuffler.io"; @@ -4770,10 +4774,10 @@ const handleClickChangeOrg = (orgId) => { /> {subOrgs.length > 0 ? ( - -
-

Your Sub Organizations of the Current Organization

-
+ +
+

Sub Organizations of the Current Organization

+
{ return ( - - - - - + + ); })}
- +) : ( +
+

No Sub-Organizations found for the Current Organization

+
+)} + + { }} /> - -) : ( - - No Sub-Organizations available. - -)} -
-

All Tenants

-
+
+

All Tenants

+
- + Date: Tue, 5 Mar 2024 15:27:11 +0530 Subject: [PATCH 6/9] fixed a typo subOrg --> subOrgs --- backend/go-app/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/go-app/main.go b/backend/go-app/main.go index 8b4264d5..26235d13 100755 --- a/backend/go-app/main.go +++ b/backend/go-app/main.go @@ -4923,7 +4923,7 @@ func initHandlers() { r.HandleFunc("/api/v1/orgs/{orgId}/change", shuffle.HandleChangeUserOrg).Methods("POST", "OPTIONS") // Swaps to the org r.HandleFunc("/api/v1/orgs/{orgId}", shuffle.HandleDeleteOrg).Methods("DELETE", "OPTIONS") - r.HandleFunc("/api/v1/subOrg/{orgId}", shuffle.HandleGetSubOrg).Methods("GET", "OPTIONS") + r.HandleFunc("/api/v1/subOrgs/{orgId}", shuffle.HandleGetSubOrg).Methods("GET", "OPTIONS") // This is a new API that validates if a key has been seen before. // Not sure what the best course of action is for it. From b71d008edcb74622973cac0061109235cb6310e3 Mon Sep 17 00:00:00 2001 From: Hari Krishna Date: Wed, 6 Mar 2024 11:09:47 +0000 Subject: [PATCH 7/9] changed HandleGetSubOrg -> HandleGetSubOrgs --- backend/go-app/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/go-app/main.go b/backend/go-app/main.go index 26235d13..62652d92 100755 --- a/backend/go-app/main.go +++ b/backend/go-app/main.go @@ -4923,7 +4923,7 @@ func initHandlers() { r.HandleFunc("/api/v1/orgs/{orgId}/change", shuffle.HandleChangeUserOrg).Methods("POST", "OPTIONS") // Swaps to the org r.HandleFunc("/api/v1/orgs/{orgId}", shuffle.HandleDeleteOrg).Methods("DELETE", "OPTIONS") - r.HandleFunc("/api/v1/subOrgs/{orgId}", shuffle.HandleGetSubOrg).Methods("GET", "OPTIONS") + r.HandleFunc("/api/v1/subOrgs/{orgId}", shuffle.HandleGetSubOrgs).Methods("GET", "OPTIONS") // This is a new API that validates if a key has been seen before. // Not sure what the best course of action is for it. From eab95ae90676a90fe30e04103c24f91f399e9552 Mon Sep 17 00:00:00 2001 From: Hari Krishna Date: Thu, 14 Mar 2024 06:22:38 +0000 Subject: [PATCH 8/9] implemented changes to show parent of the suborg --- backend/go-app/main.go | 2 +- frontend/src/views/Admin.jsx | 381 ++++++++++++++++++++++++----------- 2 files changed, 268 insertions(+), 115 deletions(-) diff --git a/backend/go-app/main.go b/backend/go-app/main.go index 62652d92..97aede9d 100755 --- a/backend/go-app/main.go +++ b/backend/go-app/main.go @@ -4923,7 +4923,7 @@ func initHandlers() { r.HandleFunc("/api/v1/orgs/{orgId}/change", shuffle.HandleChangeUserOrg).Methods("POST", "OPTIONS") // Swaps to the org r.HandleFunc("/api/v1/orgs/{orgId}", shuffle.HandleDeleteOrg).Methods("DELETE", "OPTIONS") - r.HandleFunc("/api/v1/subOrgs/{orgId}", shuffle.HandleGetSubOrgs).Methods("GET", "OPTIONS") + r.HandleFunc("/api/v1/sub_orgs/{orgId}", shuffle.HandleGetSubOrgs).Methods("GET", "OPTIONS") // This is a new API that validates if a key has been seen before. // Not sure what the best course of action is for it. diff --git a/frontend/src/views/Admin.jsx b/frontend/src/views/Admin.jsx index 63800693..15351d38 100755 --- a/frontend/src/views/Admin.jsx +++ b/frontend/src/views/Admin.jsx @@ -163,6 +163,7 @@ const Admin = (props) => { const [curTab, setCurTab] = React.useState(0); const [users, setUsers] = React.useState([]); const [subOrgs, setSubOrgs] = useState([]); + const [parentOrg, setParentOrg] = React.useState(null); const [organizations, setOrganizations] = React.useState([]); const [orgSyncResponse, setOrgSyncResponse] = React.useState(""); const [userSettings, setUserSettings] = React.useState({}); @@ -1111,40 +1112,41 @@ If you're interested, please let me know a time that works for you, or set up a toast("Error getting current organization"); }); }; -const handleGetSubOrgs = (orgId) => { - if (serverside !== true && window.location.search !== undefined && window.location.search !== null) { - const urlSearchParams = new URLSearchParams(window.location.search); - const params = Object.fromEntries(urlSearchParams.entries()); - const foundorgid = params["org_id"]; - if (foundorgid !== undefined && foundorgid !== null) { - orgId = foundorgid; - } - } - - if (orgId.length === 0) { - toast("Organization ID not defined. Please contact us on https://shuffler.io if this persists logout."); - return; - } + const handleGetSubOrgs = (orgId) => { - fetch(`${globalUrl}/api/v1/subOrgs/${orgId}`, { - method: "GET", - credentials: "include", - headers: { - "Content-Type": "application/json", - }, - }) + if (orgId.length === 0) { + toast("Organization ID not defined. Please contact us on https://shuffler.io if this persists logout."); + return; + } + + fetch(`${globalUrl}/api/v1/sub_orgs/${orgId}`, { + method: "GET", + credentials: "include", + headers: { + "Content-Type": "application/json", + }, + }) .then((response) => { + if (!response.ok) { + throw new Error('Failed to fetch sub organizations'); + } return response.json(); }) .then((responseJson) => { - setSubOrgs(responseJson); + if (responseJson.success === false) { + toast("Failed getting your org. If this persists, please contact support."); + } else { + const { subOrgs, parentOrg } = responseJson; + setSubOrgs(subOrgs); + setParentOrg(parentOrg); + } }) - .catch((error) => { - console.log("Error getting sub orgs: ", error); - toast("Error getting sub organizations"); - }); -}; + .catch((error) => { + console.log("Error getting sub orgs: ", error); + toast("Error getting sub organizations"); + }); + }; const handleClickChangeOrg = (orgId) => { // Don't really care about the logout @@ -4745,6 +4747,13 @@ const handleClickChangeOrg = (orgId) => { ) : null; + const imagesize = 40; + const imageStyle = { + width: imagesize, + height: imagesize, + pointerEvents: "none", + }; + const organizationsTab = curTab === 7 ? (
@@ -4765,95 +4774,245 @@ const handleClickChangeOrg = (orgId) => { > Add suborganization - -{subOrgs.length > 0 ? ( - -
-

Sub Organizations of the Current Organization

-
- - + - - - - - - - - - {subOrgs.map((data, index) => { - const imagesize = 40; - const imageStyle = { - width: imagesize, - height: imagesize, - pointerEvents: "none", - }; - const image = - data.image === "" ? ( - {data.name} - ) : ( - {data.name} - ); - - var bgColor = "#27292d"; - if (index % 2 === 0) { - bgColor = "#1f2023"; - } - - return ( - - - - - - - - - +
+

+ {" "} + Your Parent Organization +

+
+ + {(() => { + const image = + parentOrg.image === "" ? ( + {parentOrg.name} + ) : ( + {parentOrg.name} ); - })} -
-
+ const bgColor = "#27292d"; + + return ( + + + + + + + + + + + + + + + + + ); + })()} +
+ ) : null + } + + {subOrgs.length > 0 ? ( + + +
+

+ Sub Organizations of the Current Organization +

+
+ + + + + + + + + + + + {subOrgs.map((data, index) => { + const image = + data.image === "" ? ( + {data.name} + ) : ( + {data.name} + ); + + var bgColor = "#27292d"; + if (index % 2 === 0) { + bgColor = "#1f2023"; + } + + return ( + + + + + + + + + ); + })} + + +
+ ) : null + } - -) : ( -
-

No Sub-Organizations found for the Current Organization

-
-)} + style={{ + marginTop: 20, + marginBottom: 20, + backgroundColor: theme.palette.inputColor, + }} +/> -
-

All Tenants

-
+
+

+ All Tenants +

+
{ ? "True" : "False"; - const imagesize = 40; - const imageStyle = { - width: imagesize, - height: imagesize, - pointerEvents: "none", - }; const image = data.image === "" ? ( Date: Fri, 15 Mar 2024 06:55:26 +0000 Subject: [PATCH 9/9] modifed the endopoint --- backend/go-app/main.go | 4 ++-- frontend/src/views/Admin.jsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/go-app/main.go b/backend/go-app/main.go index 97aede9d..ece4b594 100755 --- a/backend/go-app/main.go +++ b/backend/go-app/main.go @@ -4923,8 +4923,8 @@ func initHandlers() { r.HandleFunc("/api/v1/orgs/{orgId}/change", shuffle.HandleChangeUserOrg).Methods("POST", "OPTIONS") // Swaps to the org r.HandleFunc("/api/v1/orgs/{orgId}", shuffle.HandleDeleteOrg).Methods("DELETE", "OPTIONS") - r.HandleFunc("/api/v1/sub_orgs/{orgId}", shuffle.HandleGetSubOrgs).Methods("GET", "OPTIONS") - + r.HandleFunc("/api/v1/orgs/{orgId}/suborgs", shuffle.HandleGetSubOrgs).Methods("GET", "OPTIONS") + // This is a new API that validates if a key has been seen before. // Not sure what the best course of action is for it. r.HandleFunc("/api/v1/environments/{key}/stop", shuffle.HandleStopExecutions).Methods("GET", "POST", "OPTIONS") diff --git a/frontend/src/views/Admin.jsx b/frontend/src/views/Admin.jsx index 15351d38..159465af 100755 --- a/frontend/src/views/Admin.jsx +++ b/frontend/src/views/Admin.jsx @@ -1120,7 +1120,7 @@ If you're interested, please let me know a time that works for you, or set up a return; } - fetch(`${globalUrl}/api/v1/sub_orgs/${orgId}`, { + fetch(`${globalUrl}/api/v1/orgs/${orgId}/suborgs`, { method: "GET", credentials: "include", headers: {