From b99565dc90fbfda53f7f394f575e98a443d0fdfe Mon Sep 17 00:00:00 2001 From: "lalitdeore12@gmail.com" Date: Tue, 28 Oct 2025 19:45:35 +0530 Subject: [PATCH] fix minor ui issue --- backend/go-app/main.go | 28 ++++++++++++++++++++++++ frontend/src/components/CloudSyncTab.jsx | 4 +++- frontend/src/components/LeftSideBar.jsx | 5 +++-- frontend/src/context/ContextApi.jsx | 3 +++ frontend/src/views/Admin2.jsx | 13 +++++++++-- 5 files changed, 48 insertions(+), 5 deletions(-) diff --git a/backend/go-app/main.go b/backend/go-app/main.go index 78dde288..5f54465a 100755 --- a/backend/go-app/main.go +++ b/backend/go-app/main.go @@ -4956,6 +4956,17 @@ func handleCloudSetup(resp http.ResponseWriter, request *http.Request) { resp.Write(b) } else { + + // Delete cache for the sync features + cacheKey := fmt.Sprintf("org_sync_features_%s", org.Id) + shuffle.DeleteCache(ctx, cacheKey) + + subscriptionCacheKey := fmt.Sprintf("org_subscriptions_%s", org.Id) + shuffle.DeleteCache(ctx, subscriptionCacheKey) + + licenseCacheKey := fmt.Sprintf("org_licensed_%s", org.Id) + shuffle.DeleteCache(ctx, licenseCacheKey) + resp.WriteHeader(200) resp.Write([]byte(fmt.Sprintf(`{"success": true, "reason": "Successfully disabled cloud sync for org."}`))) } @@ -5047,6 +5058,23 @@ func handleCloudSetup(resp http.ResponseWriter, request *http.Request) { shuffle.SetCache(ctx, cacheKey, featuresBytes, 1800) } + subscriptionCacheKey := fmt.Sprintf("org_subscriptions_%s", org.Id) + subscriptionsBytes, err := json.Marshal(responseData.Subscriptions) + if err != nil { + log.Printf("[ERROR] Failed to marshal Subscriptions for cache: %s", err) + } else { + shuffle.SetCache(ctx, subscriptionCacheKey, subscriptionsBytes, 1800) + } + + licenseCacheKey := fmt.Sprintf("org_licensed_%s", org.Id) + licensedBytes, err := json.Marshal(responseData.Licensed) + if err != nil { + log.Printf("[ERROR] Failed to marshal Licensed for cache: %s", err) + } else { + + shuffle.SetCache(ctx, licenseCacheKey, licensedBytes, 1800) + } + org.SyncConfig = shuffle.SyncConfig{ Apikey: responseData.SessionKey, Interval: responseData.IntervalSeconds, diff --git a/frontend/src/components/CloudSyncTab.jsx b/frontend/src/components/CloudSyncTab.jsx index 88df2610..75011dbf 100644 --- a/frontend/src/components/CloudSyncTab.jsx +++ b/frontend/src/components/CloudSyncTab.jsx @@ -49,7 +49,7 @@ const CloudSyncTab = (props) => { const itemColor = "white"; const isCloud = window?.location?.host === "localhost:3002" || window?.location?.host === "shuffler.io"; - const { themeMode, brandColor } = useContext(Context); + const { themeMode, brandColor, setUpdateOrg } = useContext(Context); const theme = getTheme(themeMode, brandColor); useEffect(() => { getSettings(); }, []); @@ -457,6 +457,8 @@ const CloudSyncTab = (props) => { setLoading(false); if (response.status === 200) { console.log("Cloud sync success?"); + handleGetOrg(userdata.active_org.id); + setUpdateOrg(true); } else { console.log("Cloud sync fail?"); } diff --git a/frontend/src/components/LeftSideBar.jsx b/frontend/src/components/LeftSideBar.jsx index ab256f75..cacef366 100644 --- a/frontend/src/components/LeftSideBar.jsx +++ b/frontend/src/components/LeftSideBar.jsx @@ -64,7 +64,7 @@ const ExpandMoreAndLessIcon = "/icons/expandMoreIcon.svg"; const LeftSideBar = ({ userdata, serverside, globalUrl, notifications, }) => { const navigate = useNavigate(); - const {setLeftSideBarOpenByClick, leftSideBarOpenByClick, setSearchBarModalOpen, searchBarModalOpen, logoutUrl, themeMode, handleThemeChange, isDocSearchModalOpen, setIsDocSearchModalOpen, supportEmail} = useContext(Context); + const {setLeftSideBarOpenByClick, leftSideBarOpenByClick, updateOrg, setUpdateOrg, setSearchBarModalOpen, searchBarModalOpen, logoutUrl, themeMode, handleThemeChange, isDocSearchModalOpen, setIsDocSearchModalOpen, supportEmail} = useContext(Context); const [expandLeftNav, setExpandLeftNav] = useState(false); const [activeOrgName, setActiveOrgName] = useState( userdata?.active_org?.name || "Select Organziation" @@ -956,6 +956,7 @@ const LeftSideBar = ({ userdata, serverside, globalUrl, notifications, }) => { .then((org) => { if (!fetched && org) { setActiveOrgData(org); + setUpdateOrg(false); if (!isCloud) { if (org?.cloud_sync && org?.subscriptions[0]?.name?.toLowerCase().includes("enterprise") && org?.subscriptions[0]?.active) { setIsProdStatusOn(true); @@ -972,7 +973,7 @@ const LeftSideBar = ({ userdata, serverside, globalUrl, notifications, }) => { return () => { fetched = true; }; - }, [userdata?.active_org?.id, globalUrl]); + }, [userdata?.active_org?.id, globalUrl, updateOrg]); return (
{ const [windowWidth, setWindowWidth] = useState(serverside === true ? 100 : window.innerWidth); const [brandColor, setBrandColor] = useState(() => localStorage.getItem("brandColor") || "#ff8544"); const [brandName, setBrandName] = useState(()=> localStorage.getItem("brandName") || "Shuffle"); + const [updateOrg, setUpdateOrg] = useState(false); const [themeMode, setThemeMode] = useState( () => localStorage.getItem("theme") || "dark" @@ -117,6 +118,8 @@ export const AppContext = (props) => { setBrandColor, brandName, setBrandName, + updateOrg, + setUpdateOrg, }}> {props.children} diff --git a/frontend/src/views/Admin2.jsx b/frontend/src/views/Admin2.jsx index fcb675bc..fc2fe2e8 100644 --- a/frontend/src/views/Admin2.jsx +++ b/frontend/src/views/Admin2.jsx @@ -5,14 +5,14 @@ import { Context } from '../context/ContextApi.jsx'; const Admin2 = (props) => { // Destructure props if needed - const { userdata, globalUrl, serverside, checkLogin, notifications, setNotifications, stripeKey, isLoaded, isLoggedIn} = props; + const { userdata, globalUrl, serverside, checkLogin, notifications, setNotifications, stripeKey, isLoaded, } = props; const [selectedTab, setSelectedTab] = useState('editdetails'); const [selectedStatus, setSelectedStatus] = React.useState([]); const [selectedOrganization, setSelectedOrganization] = useState({}); const [organizationFeatures, setOrganizationFeatures] = useState({}); const [orgRequest, setOrgRequest] = React.useState(true); const [isOrgLoaded, setIsOrgLoaded] = React.useState(false); - const {brandName} = useContext(Context) + const {brandName, updateOrg, setUpdateOrg} = useContext(Context) const isCloud = window.location.host === "localhost:3002" || window.location.host === "shuffler.io"; if (document !== undefined) { @@ -47,6 +47,8 @@ const Admin2 = (props) => { window.location.href = "/workflows"; }, 3000); } else { + + setUpdateOrg(false); if ( responseJson.sync_features === undefined || responseJson.sync_features === null @@ -163,6 +165,13 @@ const Admin2 = (props) => { }); }; + useEffect(() => { + if (updateOrg && userdata?.active_org?.id !== undefined && userdata?.active_org?.id !== null && userdata?.active_org?.id.length > 0) { + handleGetOrg(userdata.active_org.id); + setUpdateOrg(false); + } + + }, [updateOrg]); useEffect(() => { const urlSearchParams = new URLSearchParams(window.location.search);