diff --git a/src/contexts/ApplicationsProvider.tsx b/src/contexts/ApplicationsProvider.tsx
index 3860992f..9f9cc45b 100644
--- a/src/contexts/ApplicationsProvider.tsx
+++ b/src/contexts/ApplicationsProvider.tsx
@@ -1,9 +1,11 @@
import { Dashboard, FolderCopy, Monitor } from "@mui/icons-material";
import React, { createContext, useEffect, useState } from "react";
import JSONCrush from "jsoncrush";
+import { useOidc } from "@axa-fr/react-oidc";
import { useSearchParamsUtils } from "@/hooks/searchParamsUtils";
import { applicationList } from "@/components/applications/ApplicationList";
import { UserSection } from "@/types/UserSection";
+import { useOIDCContext } from "@/hooks/oidcConfiguration";
// Create a context for the userSections state
export const ApplicationsContext = createContext<
@@ -18,6 +20,9 @@ const ApplicationsProvider: React.FC<{ children: React.ReactNode }> = ({
const { getParam, setParam } = useSearchParamsUtils();
+ const { configuration } = useOIDCContext();
+ const { isAuthenticated } = useOidc(configuration?.scope);
+
useEffect(() => {
// get user sections from searchParams
const sectionsParams = getParam("sections");
@@ -52,14 +57,12 @@ const ApplicationsProvider: React.FC<{ children: React.ReactNode }> = ({
type: "Dashboard",
id: "Dashboard0",
icon: Dashboard,
- path: "/",
},
{
title: "Job Monitor",
type: "Job Monitor",
id: "JobMonitor0",
icon: Monitor,
- path: "/jobmonitor",
},
],
},
@@ -72,7 +75,6 @@ const ApplicationsProvider: React.FC<{ children: React.ReactNode }> = ({
type: "File Catalog",
id: "FileCatatlog0",
icon: FolderCopy,
- path: "/filecatalog",
},
],
},
@@ -81,6 +83,9 @@ const ApplicationsProvider: React.FC<{ children: React.ReactNode }> = ({
}, [getParam]);
useEffect(() => {
+ if (!isAuthenticated) {
+ return;
+ }
// save user sections to searchParams (but not icons)
const newSections = userSections.map((section) => {
return {
@@ -94,7 +99,7 @@ const ApplicationsProvider: React.FC<{ children: React.ReactNode }> = ({
};
});
setParam("sections", JSONCrush.crush(JSON.stringify(newSections)));
- }, [setParam, userSections]);
+ }, [isAuthenticated, setParam, userSections]);
return (
diff --git a/src/hooks/theme.tsx b/src/hooks/theme.tsx
index 10bd83ef..049d9bd1 100644
--- a/src/hooks/theme.tsx
+++ b/src/hooks/theme.tsx
@@ -37,6 +37,29 @@ export const useMUITheme = () => {
});
muiTheme.components = {
+ MuiCssBaseline: {
+ styleOverrides: `
+ ::-webkit-scrollbar {
+ width: 10px;
+ border-radius: 5px;
+ }
+ ::-webkit-scrollbar-track {
+ background: ${theme === "dark" ? "#333" : "#f1f1f1"};
+ }
+ ::-webkit-scrollbar-thumb {
+ background: ${theme === "dark" ? "#888" : "#ccc"};
+ border-radius: 5px;
+ }
+ ::-webkit-scrollbar-thumb:hover {
+ background: ${theme === "dark" ? "#555" : "#999"};
+ }
+ @supports not selector(::-webkit-scrollbar) {
+ html {
+ scrollbar-color: ${theme === "dark" ? "#888 #333" : "#ccc #f1f1f1"};
+ }
+ }
+ `,
+ },
MuiButton: {
styleOverrides: {
contained: {
diff --git a/src/types/UserSection.ts b/src/types/UserSection.ts
index 45334321..a5ac13be 100644
--- a/src/types/UserSection.ts
+++ b/src/types/UserSection.ts
@@ -7,6 +7,6 @@ export type UserSection = {
type: string;
id: string;
icon: React.ComponentType;
- path: string;
+ data?: any;
}[];
};
diff --git a/test/unit-tests/Dashboard.test.tsx b/test/unit-tests/Dashboard.test.tsx
index 39b4686c..22991083 100644
--- a/test/unit-tests/Dashboard.test.tsx
+++ b/test/unit-tests/Dashboard.test.tsx
@@ -10,6 +10,12 @@ jest.mock("@axa-fr/react-oidc", () => ({
useOidc: jest.fn(),
}));
+// In your test file or a Jest setup file
+jest.mock("jsoncrush", () => ({
+ crush: jest.fn().mockImplementation((data) => `crushed-${data}`),
+ uncrush: jest.fn().mockImplementation((data) => data.replace("crushed-", "")),
+}));
+
describe("", () => {
beforeEach(() => {
// Mock the return value for each test
diff --git a/test/unit-tests/JobDataTable.test.tsx b/test/unit-tests/JobDataTable.test.tsx
index 815875a6..cdef924d 100644
--- a/test/unit-tests/JobDataTable.test.tsx
+++ b/test/unit-tests/JobDataTable.test.tsx
@@ -9,6 +9,8 @@ jest.mock("@axa-fr/react-oidc", () => ({
useOidcAccessToken: jest.fn(),
}));
+const params = new URLSearchParams();
+
jest.mock("next/navigation", () => {
return {
usePathname: () => ({
@@ -17,15 +19,18 @@ jest.mock("next/navigation", () => {
useRouter: () => ({
push: jest.fn(),
}),
- useSearchParams: () => ({
- has: () => false,
- getAll: () => [],
- }),
+ useSearchParams: () => params,
};
});
jest.mock("swr", () => jest.fn());
+// In your test file or a Jest setup file
+jest.mock("jsoncrush", () => ({
+ crush: jest.fn().mockImplementation((data) => `crushed-${data}`),
+ uncrush: jest.fn().mockImplementation((data) => data.replace("crushed-", "")),
+}));
+
describe("", () => {
it("displays loading state", () => {
(useSWR as jest.Mock).mockReturnValue({ data: null, error: null });
diff --git a/test/unit-tests/LoginForm.test.tsx b/test/unit-tests/LoginForm.test.tsx
index 26a69ff0..3e255844 100644
--- a/test/unit-tests/LoginForm.test.tsx
+++ b/test/unit-tests/LoginForm.test.tsx
@@ -73,11 +73,19 @@ jest.mock("@axa-fr/react-oidc", () => ({
}),
}));
-jest.mock("next/navigation", () => ({
- useRouter: () => ({
- push: jest.fn(),
- }),
-}));
+const params = new URLSearchParams();
+
+jest.mock("next/navigation", () => {
+ return {
+ usePathname: () => ({
+ pathname: "",
+ }),
+ useRouter: () => ({
+ push: jest.fn(),
+ }),
+ useSearchParams: () => params,
+ };
+});
describe("LoginForm", () => {
// Should render a text field to select the VO