Skip to content

Commit 4e17864

Browse files
Validates client config (#1181 and #1180)
- Provides a route to validate the client config file. A comprehensive one for developers (<url>/config/developer), and a simpler one for users (<url>/config/user) - It will also update the client dependencies. --------- Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 parent e6e5208 commit 4e17864

31 files changed

+1142
-189
lines changed

.codeclimate.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ plugins:
1010
count_threshold: 3
1111
languages:
1212
typescript:
13-
mass_threshold: 45
13+
mass_threshold: 50
1414
javascript:
1515
python:
1616
python_version: 3

client/eslint.config.mjs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import jsxA11Y from "eslint-plugin-jsx-a11y";
22
import react from "eslint-plugin-react";
33
import jest from "eslint-plugin-jest";
4+
import reactHooks from "eslint-plugin-react-hooks";
45
import typescriptEslint from "@typescript-eslint/eslint-plugin";
56
import globals from "globals";
67
import tsParser from "@typescript-eslint/parser";
@@ -21,7 +22,7 @@ export default [{
2122
ignores: [
2223
"**/api/",
2324
"**/build/",
24-
"**/config/",
25+
"client/config/",
2526
"**/node_modules/",
2627
"**/script/",
2728
"**/coverage/",
@@ -40,8 +41,9 @@ export default [{
4041
plugins: {
4142
"jsx-a11y": jsxA11Y,
4243
react,
44+
"react-hooks": reactHooks,
4345
jest,
44-
"@typescript-eslint": typescriptEslint,
46+
"@typescript-eslint": typescriptEslint
4547
},
4648

4749
languageOptions: {
@@ -86,16 +88,19 @@ export default [{
8688
"@typescript-eslint/no-unused-vars": [
8789
"error",
8890
{
89-
"caughtErrorsIgnorePattern": "^_",
91+
"caughtErrorsIgnorePattern": "^_",
9092
}
9193
],
94+
"react-hooks/rules-of-hooks": "error",
95+
"react-hooks/exhaustive-deps": "error",
9296
"no-console": "error",
9397
"import/first": "error",
9498
"react/prop-types": "off",
9599
"linebreak-style": 0,
96100
"import/no-unresolved": "off",
97101
"import/extensions": "off",
98102
"no-use-before-define": "off",
103+
"no-unreachable": "error",
99104
},
100105
}, {
101106
files: ["**/*.ts", "**/*.tsx"],

client/jest.config.json

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,11 @@
44
"transform": {
55
"^.+\\.tsx?$": "ts-jest"
66
},
7-
"transformIgnorePatterns": [
8-
"/node_modules/(?![d3-shape|recharts]).+\\.js$"
9-
],
7+
"transformIgnorePatterns": ["/node_modules/(?![d3-shape|recharts]).+\\.js$"],
108
"collectCoverage": true,
11-
"coverageReporters": [
12-
"text",
13-
"cobertura",
14-
"clover",
15-
"lcov",
16-
"json"
17-
],
9+
"coverageReporters": ["text", "cobertura", "clover", "lcov", "json"],
1810
"testTimeout": 15000,
19-
"collectCoverageFrom": [
20-
"src/**/*.{ts,tsx}"
21-
],
11+
"collectCoverageFrom": ["src/**/*.{ts,tsx}"],
2212
"coveragePathIgnorePatterns": [
2313
"node_modules",
2414
"build",
@@ -27,21 +17,15 @@
2717
"src/store/store.ts",
2818
"src/preview/util/gitlabDriver.ts"
2919
],
30-
"modulePathIgnorePatterns": [
31-
"test/e2e",
32-
"mocks",
33-
"config"
34-
],
20+
"modulePathIgnorePatterns": ["test/e2e", "mocks", "config"],
3521
"coverageDirectory": "<rootDir>/coverage/",
3622
"globals": {
3723
"window.ENV.SERVER_HOSTNAME": "localhost",
3824
"window.ENV.SERVER_PORT": 3500
3925
},
4026
"verbose": true,
4127
"testRegex": "/test/.*\\.test.tsx?$",
42-
"modulePaths": [
43-
"<rootDir>/src/"
44-
],
28+
"modulePaths": ["<rootDir>/src/"],
4529
"moduleNameMapper": {
4630
"^test/(.*)$": "<rootDir>/test/$1",
4731
"\\.(css|less|scss)$": "<rootDir>/test/preview/__mocks__/styleMock.ts"

client/package.json

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,40 @@
11
{
22
"name": "@into-cps-association/dtaas-web",
3-
"version": "0.8.1",
3+
"version": "0.8.2",
44
"description": "Web client for Digital Twin as a Service (DTaaS)",
55
"main": "index.tsx",
66
"author": "prasadtalasila <prasad.talasila@gmail.com> (http://prasad.talasila.in/)",
77
"contributors": [
8-
"Omar Suleiman",
98
"Asger Busk Breinholm",
10-
"Mathias Brændgaard",
11-
"Emre Temel",
129
"Cesar Vela",
10+
"Emre Temel",
11+
"Enok Maj",
12+
"Mathias Brændgaard",
13+
"Omar Suleiman",
1314
"Vanessa Scherma"
1415
],
1516
"license": "SEE LICENSE IN <LICENSE.md>",
1617
"private": false,
1718
"type": "module",
1819
"scripts": {
20+
"analyze": "source-map-explorer 'build/static/js/*.js'",
1921
"build": "npx react-scripts build",
2022
"clean": "npx rimraf build/ dist/ node_modules/ coverage/ playwright-report/ test-results/ test.svg src.svg src/util/gitlab.json",
2123
"config:dev": "npx shx cp config/dev.js public/env.js && npx shx cp config/dev.js build/env.js",
2224
"config:local": "npx shx cp config/local.js public/env.js && npx shx cp config/local.js build/env.js",
2325
"config:prod": "npx shx cp config/prod.js public/env.js && npx shx cp config/prod.js build/env.js",
2426
"config:test": "npx shx cp config/test.js public/env.js && npx shx cp config/test.js build/env.js",
2527
"develop": "npx react-scripts start",
26-
"format": "prettier --ignore-path ../.gitignore --write \"**/*.{ts,tsx,css,scss}\"",
28+
"format": "prettier --ignore-path ../.gitignore --write \"**/*.{ts,tsx,css,scss,json}\"",
2729
"graph": "npx madge --image src.svg src && npx madge --image test.svg test",
2830
"start": "serve -s build -l 4000",
2931
"stop": "npx kill-port 4000",
3032
"syntax": "npx eslint . --fix",
31-
"test:all": "yarn test:unit && yarn test:int && yarn test:e2e",
33+
"test:all": "yarn test:unit && yarn test:int && yarn test:e2e && yarn test:preview:unit && yarn test:preview:int",
3234
"test:e2e:ext": "cross-env ext=true yarn test:e2e",
33-
"test:e2e": "yarn config:test && playwright test -c ./playwright.config.ts",
35+
"test:e2e": "yarn config:test && yarn build && playwright test -c ./playwright.config.ts",
3436
"test:coverage:int-unit": "npx istanbul-combine -d coverage/all -r lcov -r json -r text coverage/unit/coverage-final.json coverage/int/coverage-final.json coverage/preview/unit/coverage-final.json coverage/preview/int/coverage-final.json",
35-
"test:int": "jest -c ./jest.config.json jest --coverage --coverageDirectory=coverage/int ../test/integration --setupFilesAfterEnv ./test/integration/jest.setup.ts",
37+
"test:int": "jest -c ./jest.config.json --coverage --coverageDirectory=coverage/int ../test/integration --setupFilesAfterEnv ./test/integration/jest.setup.ts",
3638
"test:unit": "jest -c ./jest.config.json --coverageDirectory=coverage/unit ../test/unit --setupFilesAfterEnv ./test/unit/jest.setup.ts",
3739
"test:preview:int": "jest -c ./jest.config.json --coverageDirectory=coverage/preview/int ../test/preview/integration --setupFilesAfterEnv ./test/preview/integration/jest.setup.ts",
3840
"test:preview:unit": "jest -c ./jest.config.json --coverageDirectory=coverage/preview/unit ../test/preview/unit --setupFilesAfterEnv ./test/preview/unit/jest.setup.ts"
@@ -60,8 +62,8 @@
6062
"@types/react-syntax-highlighter": "^15.5.13",
6163
"@types/remarkable": "^2.0.8",
6264
"@types/styled-components": "^5.1.32",
63-
"@typescript-eslint/eslint-plugin": "^8.7.0",
64-
"@typescript-eslint/parser": "^8.7.0",
65+
"@typescript-eslint/eslint-plugin": "^8.26.1",
66+
"@typescript-eslint/parser": "^8.26.1",
6567
"cross-env": "^7.0.3",
6668
"dotenv": "^16.1.4",
6769
"eslint": "^8.2.0",
@@ -71,6 +73,8 @@
7173
"eslint-plugin-jest": "^28.8.3",
7274
"eslint-plugin-jsx-a11y": "^6.8.0",
7375
"eslint-plugin-react": "^7.33.2",
76+
"eslint-plugin-react-hooks": "5.1.0",
77+
"http-status-codes": "2.3.0",
7478
"jest-fetch-mock": "^3.0.3",
7579
"katex": "^0.16.11",
7680
"markdown-it-katex": "^2.0.3",
@@ -93,7 +97,8 @@
9397
"resize-observer-polyfill": "^1.5.1",
9498
"serve": "^14.2.1",
9599
"styled-components": "^6.1.1",
96-
"typescript": "5.1.6"
100+
"typescript": "5.1.6",
101+
"zod": "3.24.1"
97102
},
98103
"devDependencies": {
99104
"@babel/core": "7.25.8",

client/playwright.config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ export default defineConfig({
2020
? undefined
2121
: {
2222
command: 'yarn start',
23+
url: BASE_URI,
2324
},
2425
retries: process.env.CI ? 0 : 1, // Disable retries on Github actions for now as setup always fails
25-
timeout: 60 * 1000,
26+
timeout: process.env.CI ? 1000 : 30 * 1000,
2627
globalTimeout: 10 * 60 * 1000,
2728
testDir: './test/e2e/tests',
2829
testMatch: /.*\.test\.ts/,
@@ -50,6 +51,7 @@ export default defineConfig({
5051
use: {
5152
baseURL: BASE_URI,
5253
trace: 'on-first-retry', // Wil not record trace on Github actions because of no retries
54+
headless: true,
5355
},
5456
projects: [
5557
// Setup project

client/src/page/LayoutPublic.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import AppBar from '@mui/material/AppBar';
44
import Footer from 'page/Footer';
55
import Typography from '@mui/material/Typography';
66
import Box from '@mui/material/Box';
7-
import { Container } from '@mui/material';
7+
import { Breakpoint, Container } from '@mui/material';
88
import LinkButtons from 'components/LinkButtons';
99
import toolbarLinkValues from 'util/toolbarUtil';
1010

@@ -26,7 +26,10 @@ const DTappBar = () => (
2626
</AppBar>
2727
);
2828

29-
function LayoutPublic(props: { children: React.ReactNode }) {
29+
function LayoutPublic(props: {
30+
children: React.ReactNode;
31+
containerMaxWidth?: Breakpoint;
32+
}) {
3033
return (
3134
<Box
3235
sx={{
@@ -38,7 +41,10 @@ function LayoutPublic(props: { children: React.ReactNode }) {
3841
>
3942
<DTappBar />
4043
<Toolbar />
41-
<Container component="main" maxWidth="xs">
44+
<Container
45+
component="main"
46+
maxWidth={props.containerMaxWidth ? props.containerMaxWidth : 'xs'}
47+
>
4248
{props.children}
4349
</Container>
4450

client/src/route/auth/Signin.tsx

Lines changed: 56 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as React from 'react';
22
import Avatar from '@mui/material/Avatar';
33
import Box from '@mui/material/Box';
44
import LockOutlinedIcon from '@mui/icons-material/LockOutlined';
5-
65
import { useAuth } from 'react-oidc-context';
76
import Button from '@mui/material/Button';
87

@@ -13,6 +12,15 @@ function SignIn() {
1312
auth.signinRedirect();
1413
};
1514

15+
return (
16+
<BoxForSignIn>
17+
{avatar}
18+
{signInButton(startAuthProcess)}
19+
</BoxForSignIn>
20+
);
21+
}
22+
23+
function BoxForSignIn(props: { children: React.ReactNode }) {
1624
return (
1725
<Box
1826
sx={{
@@ -22,46 +30,55 @@ function SignIn() {
2230
alignItems: 'center',
2331
}}
2432
>
25-
<Avatar sx={{ m: 1, bgcolor: 'secondary.main' }}>
26-
<LockOutlinedIcon />
27-
</Avatar>
28-
<Button
29-
onClick={startAuthProcess}
30-
variant="contained"
31-
sx={{
32-
display: 'inline-flex',
33-
alignItems: 'center',
34-
padding: '10px 20px',
35-
backgroundColor: '#fc6d27',
36-
color: 'white',
37-
border: 'none',
38-
borderRadius: '5px',
39-
fontSize: '16px',
40-
fontWeight: 'bold',
41-
textDecoration: 'none',
42-
textTransform: 'none',
43-
'&:hover': {
44-
backgroundColor: '#fc6d27',
45-
textDecoration: 'none',
46-
},
47-
}}
48-
startIcon={
49-
<img
50-
src={
51-
'https://gitlab.com/gitlab-com/gitlab-artwork/-/raw/master/logo/logo-square.png'
52-
}
53-
alt="GitLab logo"
54-
style={{
55-
height: '20px',
56-
marginRight: '10px',
57-
}}
58-
/>
59-
}
60-
>
61-
Sign In with GitLab
62-
</Button>
33+
{props.children}
6334
</Box>
6435
);
6536
}
6637

38+
const avatar: JSX.Element = (
39+
<Avatar sx={{ m: 1, bgcolor: 'secondary.main' }}>
40+
<LockOutlinedIcon />
41+
</Avatar>
42+
);
43+
44+
const signInButton = (startAuthProcess: () => void) => (
45+
<Button
46+
onClick={startAuthProcess}
47+
variant="contained"
48+
sx={{
49+
display: 'inline-flex',
50+
alignItems: 'center',
51+
padding: '10px 20px',
52+
backgroundColor: '#fc6d27',
53+
color: 'white',
54+
border: 'none',
55+
borderRadius: '5px',
56+
fontSize: '16px',
57+
fontWeight: 'bold',
58+
textDecoration: 'none',
59+
textTransform: 'none',
60+
'&:hover': {
61+
backgroundColor: '#fc6d27',
62+
textDecoration: 'none',
63+
},
64+
}}
65+
startIcon={startIcon}
66+
>
67+
Sign In with GitLab
68+
</Button>
69+
);
70+
71+
const startIcon = (
72+
<img
73+
src={
74+
'https://gitlab.com/gitlab-com/gitlab-artwork/-/raw/master/logo/logo-square.png'
75+
}
76+
alt="GitLab logo"
77+
style={{
78+
height: '20px',
79+
marginRight: '10px',
80+
}}
81+
/>
82+
);
83+
6784
export default SignIn;

0 commit comments

Comments
 (0)