Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions frontend/dashboard-2/.env.mock
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_ENABLE_MOCKING=true
9 changes: 9 additions & 0 deletions frontend/dashboard-2/.env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
VITE_USE_AUTH_GATEWAY = "{{ USE_AUTH_GATEWAY }}"
VITE_KEYCLOAK_URL = "{{ KEYCLOAK_URL }}"
VITE_KEYCLOAK_REALM = "{{ KEYCLOAK_REALM }}"
VITE_KEYCLOAK_CLIENT = "{{ KEYCLOAK_CLIENT }}"
VITE_KEYCLOAK_SCOPE = "{{ KEYCLOAK_SCOPE }}"
VITE_GRAPH_URL = "{{ GRAPH_URL }}"
VITE_GRAPH_WS_URL = "{{ GRAPH_WS_URL }}"
VITE_AUTH_GATEWAY_LOGIN_URL = "{{ AUTH_GATEWAY_LOGIN_URL }}"
VITE_LOGOUT_URL = "{{ LOGOUT_URL }}"
1 change: 1 addition & 0 deletions frontend/dashboard-2/.env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_ENABLE_MOCKING = true
Empty file.
15 changes: 15 additions & 0 deletions frontend/dashboard-2/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Workflows Dashboard</title>
<script>
window.__USE_AUTH_GATEWAY__ = "{{ USE_AUTH_GATEWAY }}";
</script>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
33 changes: 33 additions & 0 deletions frontend/dashboard-2/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "dashboard-2",
"private": true,
"version": "2.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"mock": "vite --mode mock",
"build": "tsc -b && vite build",
"lint": "eslint .",
"preview": "vite preview"
},
"dependencies": {
"keycloak-js": "^26.2.4",
"msw": "^2.15.0",
"react-router-dom": "^7.18.4",
"workflows-ui": "../workflows-ui",
"workflows-apollo": "../workflows-apollo"
},
"devDependencies": {
"babel-plugin-relay": "21.0.1",
"vite-plugin-relay": "2.1.0"
},
"peerDependencies": {
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
"msw": {
"workerDirectory": [
"public"
]
}
}
7 changes: 7 additions & 0 deletions frontend/dashboard-2/relay.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"src": "./src",
"language": "typescript",
"schema": "../relay-workflows-lib/workflows.graphql",
"exclude": ["**/node_modules/**", "**/__mocks__/**", "**/__generated__/**"],
"eagerEsModules": true
}
27 changes: 27 additions & 0 deletions frontend/dashboard-2/src/ErrorPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { useRouteError, isRouteErrorResponse } from "react-router-dom";
Comment thread
Oli-Jones475 marked this conversation as resolved.
Resolved

export default function ErrorPage() {
const error = useRouteError();
let errorMessage: string;

if (isRouteErrorResponse(error)) {
errorMessage = (error.data as Error).message || error.statusText;
} else if (error instanceof Error) {
errorMessage = error.message;
} else if (typeof error == "string") {
errorMessage = error;
} else {
console.error(error);
errorMessage = "Unknown error";
}

return (
<div id="error-page">
<h1>Oops!</h1>
<p>Sorry, an unexpected error has occurred.</p>
<p>
<i>{errorMessage}</i>
</p>
</div>
);
}
29 changes: 29 additions & 0 deletions frontend/dashboard-2/src/main.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import { RouterProvider } from "react-router-dom";
import {
ThemeProvider,
DiamondDSTheme,
} from "@diamondlightsource/sci-react-ui";
import { WorkflowsApolloProvider } from "workflows-apollo";
import { ExampleComponent } from "workflows-ui";
import { createBrowserRouter } from "react-router-dom";

const root = createRoot(document.getElementById("root") as Element);

root.render(
<WorkflowsApolloProvider>
<StrictMode>
<ThemeProvider theme={DiamondDSTheme} defaultMode="light">
<RouterProvider
router={createBrowserRouter([
{
path: "/",
element: <ExampleComponent />,
},
])}
/>
</ThemeProvider>
</StrictMode>
</WorkflowsApolloProvider>,
);
17 changes: 17 additions & 0 deletions frontend/dashboard-2/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/// <reference types="vite/client" />

interface ImportMetaEnv {
readonly VITE_KEYCLOAK_URL: string;
readonly VITE_KEYCLOAK_REALM: string;
readonly VITE_KEYCLOAK_CLIENT: string;
readonly VITE_KEYCLOAK_SCOPE: string;
readonly VITE_GRAPH_URL: string;
readonly VITE_GRAPH_WS_URL: string;
readonly VITE_USE_AUTH_GATEWAY: string;
readonly VITE_AUTH_GATEWAY_LOGIN_URL: string;
readonly VITE_LOGOUT_URL: string;
}

interface importMeta {
readonly env: ImportMetaEnv;
}
27 changes: 27 additions & 0 deletions frontend/dashboard-2/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "Bundler",
"allowImportingTsExtensions": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,
"jsx": "react-jsx",

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true,

"types": ["vitest/globals", "node"]
},
"include": ["src", "tests"]
}
7 changes: 7 additions & 0 deletions frontend/dashboard-2/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"files": [],
"references": [
{ "path": "./tsconfig.app.json" },
{ "path": "./tsconfig.node.json" }
]
}
25 changes: 25 additions & 0 deletions frontend/dashboard-2/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"compilerOptions": {
"target": "ES2022",
"lib": ["ES2023"],
"module": "ESNext",
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "Bundler",
"allowImportingTsExtensions": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true,

"types": ["vitest/globals"]
},
"include": ["vite.config.ts", "vitest.config.ts", "vitest.setup.ts"]
}
8 changes: 8 additions & 0 deletions frontend/dashboard-2/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import relay from "vite-plugin-relay";
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";

// https://vite.dev/config/
export default defineConfig({
plugins: [relay, react()],
});
12 changes: 12 additions & 0 deletions frontend/dashboard-2/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { defineConfig } from "vitest/config";
import viteConfig from "./vite.config.ts";

export default defineConfig({
...viteConfig,
mode: "test",
test: {
setupFiles: ["./vitest.setup.ts"],
globals: true,
environment: "jsdom",
},
});
17 changes: 17 additions & 0 deletions frontend/dashboard-2/vitest.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class ResizeObserverMock {
observe() {}
unobserve() {}
disconnect() {}
}

vi.stubGlobal("ResizeObserver", ResizeObserverMock);

vi.mock("relay-workflows-lib", async () => ({
...(await vi.importActual("relay-workflows-lib")),
WorkflowsNavbar: vi.fn(),
}));

vi.mock("@diamondlightsource/sci-react-ui", async () => ({
...(await vi.importActual("@diamondlightsource/sci-react-ui")),
Breadcrumbs: () => vi.fn(),
}));
Loading
Loading