Skip to content

Commit

Permalink
Merge pull request #234 from aldbr/main_FEAT_add-username-and-dirac-v…
Browse files Browse the repository at this point in the history
…ersion

feat(library): add profile details (username, vo, group, properties)
  • Loading branch information
aldbr authored Oct 17, 2024
2 parents 5919fc1 + 9a71c8e commit 99df937
Show file tree
Hide file tree
Showing 55 changed files with 1,221 additions and 668 deletions.
420 changes: 362 additions & 58 deletions package-lock.json

Large diffs are not rendered by default.

26 changes: 21 additions & 5 deletions packages/diracx-web-components/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,35 @@
{
"extends": [
"next/core-web-vitals",
"prettier",
"plugin:import/recommended",
"plugin:import/typescript",
"plugin:storybook/recommended"
"plugin:storybook/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
"prettier"
],
"globals": {
"JSX": "readonly"
},
"plugins": ["import"],
"plugins": ["import", "@typescript-eslint", "react"],
"rules": {
"import/order": ["error"],
"import/no-unused-modules": ["error"],
"import/no-useless-path-segments": ["error"],
"import/no-unresolved": ["off"]
"import/no-unresolved": ["off"],
"react/prop-types": "off",
"react/react-in-jsx-scope": "off"
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2021,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"settings": {
"react": {
"version": "detect"
}
}
}
8 changes: 4 additions & 4 deletions packages/diracx-web-components/components/ApplicationList.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Dashboard, FolderCopy, Monitor } from "@mui/icons-material";
import ApplicationConfig from "@/types/ApplicationConfig";
import JobMonitor from "./JobMonitor/JobMonitor";
import UserDashboard from "./UserDashboard/UserDashboard";
import BaseApp from "./BaseApp/BaseApp";
import ApplicationMetadata from "@/types/ApplicationMetadata";

export const applicationList: ApplicationConfig[] = [
{ name: "Dashboard", component: UserDashboard, icon: Dashboard },
export const applicationList: ApplicationMetadata[] = [
{ name: "Base Application", component: BaseApp, icon: Dashboard },
{
name: "Job Monitor",
component: JobMonitor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ import React from "react";
import { StoryObj, Meta } from "@storybook/react";
import { ThemeProvider as MUIThemeProvider } from "@mui/material/styles";
import { Paper } from "@mui/material";
import { Apps } from "@mui/icons-material";
import { useOidcAccessToken } from "../../mocks/react-oidc.mock";
import { useMUITheme } from "../../hooks/theme";
import { ApplicationsContext } from "../../contexts/ApplicationsProvider";
import { NavigationProvider } from "../../contexts/NavigationProvider";
import UserDashboard from "./UserDashboard";
import BaseApp from "./BaseApp";

const meta = {
title: "User Dashboard/UserDashboard",
component: UserDashboard,
title: "Base Application",
component: BaseApp,
parameters: {
layout: "centered",
},
Expand Down Expand Up @@ -49,7 +50,7 @@ const meta = {
{
id: "example",
title: "App Name",
icon: React.Component,
icon: Apps,
type: "test",
},
],
Expand All @@ -69,7 +70,7 @@ const meta = {
useOidcAccessToken.mockRestore();
};
},
} satisfies Meta<typeof UserDashboard>;
} satisfies Meta<typeof BaseApp>;

export default meta;
type Story = StoryObj<typeof meta>;
Expand All @@ -82,7 +83,7 @@ export const LoggedIn: Story = {
useOidcAccessToken.mockReturnValue({
accessTokenPayload: { preferred_username: "John Doe" },
});
return <UserDashboard {...props} />;
return <BaseApp {...props} />;
},
};

Expand All @@ -94,6 +95,6 @@ export const LoggedOff: Story = {
useOidcAccessToken.mockReturnValue({
accessTokenPayload: null,
});
return <UserDashboard {...props} />;
return <BaseApp {...props} />;
},
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"use client";
import React from "react";
import { useOidcAccessToken } from "@axa-fr/react-oidc/";
import { useOIDCContext } from "@/hooks/oidcConfiguration";
import ApplicationHeader from "@/components/shared/ApplicationHeader";
Expand All @@ -9,7 +8,7 @@ import ApplicationHeader from "@/components/shared/ApplicationHeader";
*
* @returns User Dashboard content
*/
export default function UserDashboard({
export default function BaseApplication({
headerSize,
}: {
/** The size of the header, optional, will default to h4 */
Expand Down
1 change: 1 addition & 0 deletions packages/diracx-web-components/components/BaseApp/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as BaseApp } from "./BaseApp";
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ApplicationsContext } from "../../contexts/ApplicationsProvider";
import { NavigationProvider } from "../../contexts/NavigationProvider";
import { useOidc, useOidcAccessToken } from "../../mocks/react-oidc.mock";
import { applicationList } from "../ApplicationList";
import { DashboardGroup } from "../../types/DashboardGroup";
import Dashboard from "./Dashboard";

const meta = {
Expand All @@ -22,7 +23,9 @@ const meta = {
},
decorators: [
(Story) => {
const [sections, setSections] = React.useState([
const [userDashboard, setUserDashboard] = React.useState<
DashboardGroup[]
>([
{
title: "Group Title",
extended: true,
Expand All @@ -47,7 +50,7 @@ const meta = {
}}
>
<ApplicationsContext.Provider
value={[sections, setSections, applicationList]}
value={[userDashboard, setUserDashboard, applicationList]}
>
<Box sx={{ height: "50vh" }}>
<Story />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import { Menu } from "@mui/icons-material";
import Toolbar from "@mui/material/Toolbar";
import Stack from "@mui/material/Stack";
import { ThemeProvider as MUIThemeProvider } from "@mui/material/styles";
import { useMUITheme } from "@/hooks/theme";
import { ProfileButton } from "./ProfileButton";
import { ThemeToggleButton } from "./ThemeToggleButton";
import DashboardDrawer from "./DashboardDrawer";
import { useMUITheme } from "@/hooks/theme";

interface DashboardProps {
/** The content to be displayed in the main area */
Expand All @@ -23,7 +23,7 @@ interface DashboardProps {
}

/**
* Build a side bar on the left containing the available sections as well as a top bar.
* Build a side bar on the left containing the available groups as well as a top bar.
* The side bar is expected to collapse if displayed on a small screen
*
* @param props - children, drawerWidth, logoURL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useMUITheme } from "../../hooks/theme";
import { useOidc, useOidcAccessToken } from "../../mocks/react-oidc.mock";
import { ApplicationsContext } from "../../contexts/ApplicationsProvider";
import { applicationList } from "../ApplicationList";
import { DashboardGroup } from "../../types";
import DashboardDrawer from "./DashboardDrawer";

const meta = {
Expand All @@ -20,7 +21,9 @@ const meta = {
decorators: [
(Story) => {
const theme = useMUITheme();
const [sections, setSections] = React.useState([
const [userDashboard, setUserDashboard] = React.useState<
DashboardGroup[]
>([
{
title: "Group Title",
extended: true,
Expand All @@ -36,7 +39,7 @@ const meta = {
]);
return (
<ApplicationsContext.Provider
value={[sections, setSections, applicationList]}
value={[userDashboard, setUserDashboard, applicationList]}
>
<MUIThemeProvider theme={theme}>
<Box sx={{ width: "240px", height: "50vh" }}>
Expand Down
Loading

0 comments on commit 99df937

Please sign in to comment.