Skip to content

Commit

Permalink
Allow access to the '/pricing' page only for admins
Browse files Browse the repository at this point in the history
  • Loading branch information
tahierhussain committed Feb 4, 2025
1 parent dbd24b2 commit f703d18
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
9 changes: 7 additions & 2 deletions frontend/src/components/navigations/top-nav-bar/TopNavBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
getBaseUrl,
homePagePath,
onboardCompleted,
UNSTRACT_ADMIN,
} from "../../../helpers/GetStaticData.js";
import useLogout from "../../../hooks/useLogout.js";
import "../../../layouts/page-layout/PageLayout.css";
Expand Down Expand Up @@ -132,7 +133,7 @@ function TopNavBar({ isSimpleLayout, topNavBarOptions }) {
const { role } = sessionDetails;
const isReviewer = role === "unstract_reviewer";
const isSupervisor = role === "unstract_supervisor";
const isAdmin = role === "unstract_admin";
const isAdmin = role === UNSTRACT_ADMIN;

setShowOnboardBanner(
!onboardCompleted(sessionDetails?.adapters) &&
Expand Down Expand Up @@ -297,7 +298,11 @@ function TopNavBar({ isSimpleLayout, topNavBarOptions }) {
});
}

if (isUnstract && UnstractPricingMenuLink) {
if (
isUnstract &&
UnstractPricingMenuLink &&
sessionDetails?.role === UNSTRACT_ADMIN
) {
menuItems.push({
key: "7",
label: <UnstractPricingMenuLink orgName={orgName} />,
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/helpers/GetStaticData.js
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,8 @@ const TRIAL_PLAN = "TRIAL";

const homePagePath = cloudHomePagePath || "tools";

const UNSTRACT_ADMIN = "unstract_admin";

export {
CONNECTOR_TYPE_MAP,
O_AUTH_PROVIDERS,
Expand Down Expand Up @@ -639,4 +641,5 @@ export {
generateCoverageKey,
TRIAL_PLAN,
homePagePath,
UNSTRACT_ADMIN,
};
8 changes: 8 additions & 0 deletions frontend/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,14 @@ body {
padding-left: 6px;
}

.pad-top-20 {
padding-top: 20px;
}

.pad-bottom-20 {
padding-bottom: 20px;
}

.cur-pointer {
cursor: pointer;
}
Expand Down
7 changes: 5 additions & 2 deletions frontend/src/routes/useMainAppRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import { CustomTools } from "../pages/CustomTools.jsx";
import { CustomToolsHelper } from "../components/helpers/custom-tools/CustomToolsHelper.js";
import { ToolIdePage } from "../pages/ToolIdePage.jsx";
import { OutputAnalyzerPage } from "../pages/OutputAnalyzerPage.jsx";
import { deploymentTypes } from "../helpers/GetStaticData.js";
import { deploymentTypes, UNSTRACT_ADMIN } from "../helpers/GetStaticData.js";
import { useSessionStore } from "../store/session-store.js";

let RequirePlatformAdmin;
let PlatformAdminPage;
Expand Down Expand Up @@ -94,6 +95,8 @@ try {
}

function useMainAppRoutes() {
const { role } = useSessionStore((state) => state?.sessionDetails);

const routes = (
<>
<Route path=":orgName" element={<FullPageLayout />}>
Expand All @@ -108,7 +111,7 @@ function useMainAppRoutes() {
{UnstractUsagePage && (
<Route path="dashboard" element={<UnstractUsagePage />} />
)}
{UnstractSubscriptionPage && (
{UnstractSubscriptionPage && role === UNSTRACT_ADMIN && (
<Route path="pricing" element={<UnstractSubscriptionPage />} />
)}
<Route path="profile" element={<ProfilePage />} />
Expand Down

0 comments on commit f703d18

Please sign in to comment.