diff --git a/packages/diracx-web-components/src/components/applications/JobMonitor.tsx b/packages/diracx-web-components/src/components/applications/JobMonitor.tsx index 2bd7930b..3518d5da 100644 --- a/packages/diracx-web-components/src/components/applications/JobMonitor.tsx +++ b/packages/diracx-web-components/src/components/applications/JobMonitor.tsx @@ -5,12 +5,17 @@ import ApplicationHeader from "@/components/ui/ApplicationHeader"; /** * Build the Job Monitor application + * @param headerSize - The size of the header, optional * @returns Job Monitor content */ -export default function JobMonitor() { +export default function JobMonitor({ + headerSize, +}: { + headerSize?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6"; +}) { return (
- +
); diff --git a/packages/diracx-web-components/src/components/applications/LoginForm.tsx b/packages/diracx-web-components/src/components/applications/LoginForm.tsx index 02a14743..5ef40512 100644 --- a/packages/diracx-web-components/src/components/applications/LoginForm.tsx +++ b/packages/diracx-web-components/src/components/applications/LoginForm.tsx @@ -24,9 +24,14 @@ import { useSearchParamsUtils } from "@/hooks/searchParamsUtils"; /** * Login form + * @param logoURL the URL of the logo, optional * @returns a form */ -export function LoginForm() { +export function LoginForm({ + logoURL = "/DIRAC-logo-minimal.png", +}: { + logoURL?: string; +}) { const theme = useMUITheme(); const router = useRouter(); const { data, error, isLoading } = useMetadata(); @@ -139,12 +144,7 @@ export function LoginForm() { paddingBottom: "10%", }} > - DIRAC logo + DIRAC logo {singleVO ? ( - +

Hello {accessTokenPayload["preferred_username"]}

To start with, select an application in the side bar

diff --git a/packages/diracx-web-components/src/components/layout/Dashboard.tsx b/packages/diracx-web-components/src/components/layout/Dashboard.tsx index 7a7bff6c..2e665a60 100644 --- a/packages/diracx-web-components/src/components/layout/Dashboard.tsx +++ b/packages/diracx-web-components/src/components/layout/Dashboard.tsx @@ -15,13 +15,15 @@ import { useMUITheme } from "@/hooks/theme"; interface DashboardProps { children: React.ReactNode; + drawerWidth?: number; + logoURL?: string; } /** * Build a side bar on the left containing the available sections as well as a top bar. * The side bar is expected to collapse if displayed on a small screen * - * @param props - children + * @param props - children, drawerWidth, logoURL * @return an dashboard layout */ export default function Dashboard(props: DashboardProps) { @@ -33,7 +35,7 @@ export default function Dashboard(props: DashboardProps) { }; /** Drawer width */ - const drawerWidth = 240; + const drawerWidth = props.drawerWidth || 240; return ( @@ -87,12 +89,14 @@ export default function Dashboard(props: DashboardProps) { mobileOpen={mobileOpen} width={drawerWidth} handleDrawerToggle={handleDrawerToggle} + logoURL={props.logoURL} /> void; }) { const [appType, setAppType] = React.useState(""); + const applicationList = React.useContext(ApplicationsContext)[2]; return ( @@ -15,14 +22,14 @@ export default function ApplicationHeader({ type }: { type: string }) { {appTitle && ( {appTitle} )} - + {type} diff --git a/packages/diracx-web-components/src/components/ui/DashboardDrawer.tsx b/packages/diracx-web-components/src/components/ui/DashboardDrawer.tsx index afcfd492..c726a371 100644 --- a/packages/diracx-web-components/src/components/ui/DashboardDrawer.tsx +++ b/packages/diracx-web-components/src/components/ui/DashboardDrawer.tsx @@ -34,6 +34,7 @@ interface DashboardDrawerProps { mobileOpen: boolean; width: number; handleDrawerToggle: ReactEventHandler; + logoURL?: string; } /** @@ -69,6 +70,8 @@ export default function DashboardDrawer(props: DashboardDrawerProps) { // Each section has an associated icon and path. const [userSections, setSections] = useContext(ApplicationsContext); + const logoURL = props.logoURL || "/DIRAC-logo.png"; + const theme = useMUITheme(); useEffect(() => { @@ -369,12 +372,7 @@ export default function DashboardDrawer(props: DashboardDrawerProps) { backgroundColor: theme.palette.background.default, }} > - DIRAC logo + DIRAC logo {/* Map over user sections and render them as list items in the drawer. */} diff --git a/packages/diracx-web-components/src/contexts/ApplicationsProvider.tsx b/packages/diracx-web-components/src/contexts/ApplicationsProvider.tsx index 195bcf6c..17be24be 100644 --- a/packages/diracx-web-components/src/contexts/ApplicationsProvider.tsx +++ b/packages/diracx-web-components/src/contexts/ApplicationsProvider.tsx @@ -1,22 +1,38 @@ -import { Dashboard, FolderCopy, Monitor } from "@mui/icons-material"; import React, { createContext, useEffect, useState } from "react"; +import { Dashboard, FolderCopy, Monitor } from "@mui/icons-material"; 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"; +import ApplicationConfig from "@/types/ApplicationConfig"; // Create a context for the userSections state export const ApplicationsContext = createContext< - [UserSection[], React.Dispatch>] ->([[], () => {}]); + [ + UserSection[], + React.Dispatch>, + ApplicationConfig[], + ] +>([[], () => {}, []]); -// Create the ApplicationsProvider component +/** + * Provides the applications context to its children components. + * + * @param children - The child components to be wrapped by the provider. + * @param appList - The list of application configurations. + * @param defaultSections - The default user sections. + * @returns The applications provider. + */ export const ApplicationsProvider = ({ children, + appList = applicationList, + defaultSections, }: { children: React.ReactNode; + appList?: ApplicationConfig[]; + defaultSections?: UserSection[]; }) => { const [userSections, setSections] = useState([]); @@ -36,9 +52,8 @@ export const ApplicationsProvider = ({ section.items = section.items.map((item: any) => { return { ...item, - //get icon from ApplicationList - icon: applicationList.find((app) => app.name === item.type) - ?.icon, + //get icon from appList + icon: appList.find((app) => app.name === item.type)?.icon, }; }); return section; @@ -49,40 +64,42 @@ export const ApplicationsProvider = ({ console.error("Error parsing user sections : ", uncrushed, e); } } else { - setSections([ - { - title: "Dashboard", - extended: true, - items: [ - { - title: "Dashboard", - type: "Dashboard", - id: "Dashboard0", - icon: Dashboard, - }, - { - title: "Job Monitor", - type: "Job Monitor", - id: "JobMonitor0", - icon: Monitor, - }, - ], - }, - { - title: "Other", - extended: false, - items: [ - { - title: "File Catalog", - type: "File Catalog", - id: "FileCatatlog0", - icon: FolderCopy, - }, - ], - }, - ]); + setSections( + defaultSections || [ + { + title: "Dashboard", + extended: true, + items: [ + { + title: "Dashboard", + type: "Dashboard", + id: "Dashboard0", + icon: Dashboard, + }, + { + title: "Job Monitor", + type: "Job Monitor", + id: "JobMonitor0", + icon: Monitor, + }, + ], + }, + { + title: "Other", + extended: false, + items: [ + { + title: "File Catalog", + type: "File Catalog", + id: "FileCatalog0", + icon: FolderCopy, + }, + ], + }, + ], + ); } - }, [getParam]); + }, [getParam, appList, defaultSections]); useEffect(() => { if (!isAuthenticated) { @@ -104,7 +121,7 @@ export const ApplicationsProvider = ({ }, [isAuthenticated, setParam, userSections]); return ( - + {children} );