Skip to content

Commit e4e2b00

Browse files
authored
Merge pull request #376 from TheauW/twartel-gubbins-test
fix: gubbins tests
2 parents 2688537 + c93d4cf commit e4e2b00

File tree

15 files changed

+105
-87
lines changed

15 files changed

+105
-87
lines changed

.github/workflows/gubbins-test.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,3 +330,10 @@ jobs:
330330
browser: chrome
331331
config: baseUrl=${{ env.DIRACX_URL }}
332332
project: /tmp/gubbins-web
333+
334+
- name: Upload Cypress screenshots
335+
if: failure()
336+
uses: actions/upload-artifact@v4
337+
with:
338+
name: cypress-screenshots
339+
path: /tmp/gubbins-web/cypress/screenshots

docs/developer/create_application.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ The applicatins created here will be available for DiracX-Web and for all the ex
66

77
### Declare the application
88

9-
In the file `packages/diracx-web-components/src/components/ApplicationList.ts` you can extend the `applicationList` with your new app.
9+
In the file `packages/diracx-web-components/src/components/applicationList.ts` you can extend the `applicationList` with your new app.
1010

1111
You must provide:
1212
- A clear and explicit name
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { DashboardGroup } from "../types/DashboardGroup";
2+
3+
export const defaultDashboard: DashboardGroup[] = [
4+
{
5+
title: "My dashboard",
6+
extended: true,
7+
items: [
8+
{
9+
title: "My Jobs",
10+
type: "Job Monitor",
11+
id: "JobMonitor0",
12+
},
13+
],
14+
},
15+
];

packages/diracx-web-components/src/components/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Application list
2-
export { applicationList } from "./ApplicationList";
2+
export { applicationList } from "./applicationList";
33

44
// Dashboard Layout
55
export * from "./DashboardLayout";

packages/diracx-web-components/src/contexts/ApplicationsProvider.tsx

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
"use client";
22

33
import React, { createContext, useEffect, useState } from "react";
4-
import { applicationList } from "../components/ApplicationList";
4+
import { applicationList } from "../components/applicationList";
5+
import { defaultDashboard } from "../components/defaultDashboard";
56
import { DashboardGroup } from "../types/DashboardGroup";
67
import ApplicationMetadata from "../types/ApplicationMetadata";
78

@@ -33,7 +34,7 @@ interface ApplicationsProviderProps {
3334
export const ApplicationsProvider = ({
3435
children,
3536
appList = applicationList,
36-
defaultUserDashboard,
37+
defaultUserDashboard = defaultDashboard,
3738
}: ApplicationsProviderProps) => {
3839
const loadedDashboard = sessionStorage.getItem("savedDashboard");
3940
const parsedDashboard: DashboardGroup[] = loadedDashboard
@@ -51,21 +52,7 @@ export const ApplicationsProvider = ({
5152
useEffect(() => {
5253
if (userDashboard.length !== 0) return;
5354

54-
setUserDashboard(
55-
defaultUserDashboard || [
56-
{
57-
title: "My dashboard",
58-
extended: true,
59-
items: [
60-
{
61-
title: "My Jobs",
62-
type: "Job Monitor",
63-
id: "JobMonitor0",
64-
},
65-
],
66-
},
67-
],
68-
);
55+
setUserDashboard(defaultUserDashboard);
6956
}, [appList, defaultUserDashboard]);
7057

7158
// Save the dashboard in session storage

packages/diracx-web-components/src/contexts/DiracXWebProviders.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
"use client";
22

3+
import type { ApplicationMetadata, DashboardGroup } from "../types";
4+
5+
import { OIDCSecure } from "../components";
36
import {
47
OIDCConfigurationProvider,
58
ThemeProvider,
@@ -12,13 +15,17 @@ interface DiracXWebProvidersProps {
1215
getPath: () => string;
1316
setPath: (path: string) => void;
1417
getSearchParams: () => URLSearchParams;
18+
appList?: ApplicationMetadata[];
19+
defaultUserDashboard?: DashboardGroup[];
1520
}
1621

1722
export function DiracXWebProviders({
1823
children,
1924
getPath,
2025
setPath,
2126
getSearchParams,
27+
appList,
28+
defaultUserDashboard,
2229
}: DiracXWebProvidersProps) {
2330
return (
2431
<OIDCConfigurationProvider>
@@ -27,8 +34,13 @@ export function DiracXWebProviders({
2734
setPath={setPath}
2835
getSearchParams={getSearchParams}
2936
>
30-
<ApplicationsProvider>
31-
<ThemeProvider>{children}</ThemeProvider>
37+
<ApplicationsProvider
38+
appList={appList}
39+
defaultUserDashboard={defaultUserDashboard}
40+
>
41+
<ThemeProvider>
42+
<OIDCSecure>{children}</OIDCSecure>
43+
</ThemeProvider>
3244
</ApplicationsProvider>
3345
</NavigationProvider>
3446
</OIDCConfigurationProvider>

packages/diracx-web-components/stories/Dashboard.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { Meta, StoryObj } from "@storybook/react";
33
import { Box } from "@mui/material";
44
import { ApplicationsContext } from "../src/contexts/ApplicationsProvider";
55
import { NavigationProvider } from "../src/contexts/NavigationProvider";
6-
import { applicationList } from "../src/components/ApplicationList";
6+
import { applicationList } from "../src/components/applicationList";
77
import { DashboardGroup } from "../src/types/DashboardGroup";
88
import Dashboard from "../src/components/DashboardLayout/Dashboard";
99
import { ThemeProvider } from "../src/contexts/ThemeProvider";

packages/diracx-web/src/app/(dashboard)/layout.tsx

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
import React from "react";
33
import { Box } from "@mui/material";
44
import { DiracXWebProviders } from "@dirac-grid/diracx-web-components/contexts";
5-
import {
6-
OIDCSecure,
7-
Dashboard,
8-
} from "@dirac-grid/diracx-web-components/components";
5+
import { Dashboard } from "@dirac-grid/diracx-web-components/components";
96
import { usePathname, useRouter, useSearchParams } from "next/navigation";
107

118
export default function DashboardLayout({
@@ -25,22 +22,20 @@ export default function DashboardLayout({
2522
}}
2623
getSearchParams={() => searchParams}
2724
>
28-
<OIDCSecure>
29-
<Dashboard>
30-
<Box
31-
sx={{
32-
ml: "1%",
33-
mr: "1%",
34-
display: "flex",
35-
flexDirection: "column",
36-
flexGrow: 1,
37-
overflow: "hidden",
38-
}}
39-
>
40-
{children}
41-
</Box>
42-
</Dashboard>
43-
</OIDCSecure>
25+
<Dashboard>
26+
<Box
27+
sx={{
28+
ml: "1%",
29+
mr: "1%",
30+
display: "flex",
31+
flexDirection: "column",
32+
flexGrow: 1,
33+
overflow: "hidden",
34+
}}
35+
>
36+
{children}
37+
</Box>
38+
</Dashboard>
4439
</DiracXWebProviders>
4540
</section>
4641
);
Lines changed: 21 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
"use client";
22
import React from "react";
33
import { Box } from "@mui/material";
4-
import {
5-
OIDCSecure,
6-
Dashboard,
7-
} from "@dirac-grid/diracx-web-components/components";
8-
import {
9-
ApplicationsProvider,
10-
DiracXWebProviders,
11-
} from "@dirac-grid/diracx-web-components/contexts";
4+
import { Dashboard } from "@dirac-grid/diracx-web-components/components";
5+
import { DiracXWebProviders } from "@dirac-grid/diracx-web-components/contexts";
126
import { usePathname, useRouter, useSearchParams } from "next/navigation";
13-
import { applicationList } from "@/gubbins/ApplicationList";
7+
import { applicationList } from "@/gubbins/applicationList";
148
import { defaultSections } from "@/gubbins/DefaultUserDashboard";
159

1610
// Layout for the dashboard: setup the providers and the dashboard for the applications
@@ -32,32 +26,25 @@ export default function DashboardLayout({
3226
getPath={() => pathname}
3327
setPath={router.push}
3428
getSearchParams={() => searchParams}
29+
// You can optionally pass a list of applications and a default user dashboard
30+
appList={applicationList}
31+
defaultUserDashboard={defaultSections}
3532
>
36-
{/* ApplicationsProvider is the provider for the applications, you can give it customized application list or default user dashboard to override them.
37-
No need to use it if you don't want to customize the applications */}
38-
<ApplicationsProvider
39-
appList={applicationList}
40-
defaultUserDashboard={defaultSections}
41-
>
42-
{/* OIDCSecure is used to make sure the user is authenticated before accessing the dashboard */}
43-
<OIDCSecure>
44-
{/* Dashboard is the main layout for the applications, you can optionally give it a custom logo URL and a drawer width */}
45-
<Dashboard logoURL={customLogoURL} drawerWidth={250}>
46-
<Box
47-
sx={{
48-
ml: "1%",
49-
mr: "1%",
50-
display: "flex",
51-
flexDirection: "column",
52-
flexGrow: 1,
53-
overflow: "hidden",
54-
}}
55-
>
56-
{children}
57-
</Box>
58-
</Dashboard>
59-
</OIDCSecure>
60-
</ApplicationsProvider>
33+
{/* Dashboard is the main layout for the applications, you can optionally give it a custom logo URL and a drawer width */}
34+
<Dashboard logoURL={customLogoURL} drawerWidth={250}>
35+
<Box
36+
sx={{
37+
ml: "1%",
38+
mr: "1%",
39+
display: "flex",
40+
flexDirection: "column",
41+
flexGrow: 1,
42+
overflow: "hidden",
43+
}}
44+
>
45+
{children}
46+
</Box>
47+
</Dashboard>
6148
</DiracXWebProviders>
6249
);
6350
}

0 commit comments

Comments
 (0)