diff --git a/.eslintrc b/.eslintrc index e0bd67cb03c31030d95c0cf6c3372b828f9c0b3d..cda9e7fbb1cdd50c5ddf1df75da20b3abbe419ac 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,18 +1,30 @@ { - "plugins": ["react", "import", "cypress"], + "plugins": [ + "react", + "react-hooks", + "@typescript-eslint", + "import", + "cypress", + "prettier" + ], "extends": [ "eslint:recommended", - "plugin:cypress/recommended", - "plugin:@typescript-eslint/eslint-recommended", + "plugin:react/recommended", + "plugin:react/jsx-runtime", + "plugin:react-hooks/recommended", "plugin:@typescript-eslint/recommended", - "prettier" + "plugin:cypress/recommended", + "plugin:prettier/recommended" ], "settings": { "react": { "version": "detect" }, "import/parsers": { - "@typescript-eslint/parser": [".ts", ".tsx", ".js"] + "@typescript-eslint/parser": [ + ".ts", + ".tsx" + ] }, "import/resolver": { "typescript": { @@ -26,83 +38,93 @@ "node": true }, "rules": { - "block-scoped-var": "error", - "consistent-this": ["error", "self"], - "constructor-super": "off", + "react/prop-types": "off", + "no-duplicate-imports": "warn", + "consistent-this": [ + "error", + "self" + ], "default-case": "error", "dot-notation": "error", - "eqeqeq": ["error", "always", { "null": "ignore" }], - "guard-for-in": "error", - "import/no-unresolved": [2, { "caseSensitive": false }], - "no-array-constructor": "error", - "no-caller": "error", - "no-catch-shadow": "error", + "eqeqeq": [ + "error", + "always", + { + "null": "ignore" + } + ], + "import/no-unresolved": [ + 2, + { + "caseSensitive": false + } + ], "no-console": [ - "warn", + "error", { - "allow": ["warn", "error", "info", "debug"] + "allow": [ + "warn", + "error", + "info", + "debug" + ] } ], - "no-constant-condition": "warn", "no-eval": "error", - "no-extend-native": "error", - "no-extra-bind": "error", "no-implied-eval": "error", - "no-iterator": "error", - "no-label-var": "error", - "no-labels": "error", "no-lone-blocks": "error", - "no-loop-func": "error", - "no-nested-ternary": "off", - "no-new-func": "error", - "no-new-object": "error", - "no-new-wrappers": "error", - "no-new": "error", + "no-nested-ternary": "error", + "no-object-constructor": "error", "no-octal-escape": "error", - "no-proto": "error", "no-script-url": "error", "no-self-compare": "error", "no-sequences": "error", "no-undef-init": "error", "no-unused-expressions": "error", - "no-unused-vars": [ + "operator-assignment": [ "error", - { "vars": "all", "args": "none", "ignoreRestSiblings": true } + "always" + ], + "quotes": [ + "error", + "double", + { + "avoidEscape": true + } ], - "operator-assignment": ["error", "always"], - "quotes": ["error", "double", { "avoidEscape": true }], "radix": "error", - "spaced-comment": "error", "yoda": "error", - "react/display-name": "off", "react/jsx-boolean-value": "warn", - "react/jsx-no-bind": "off", - "react/jsx-no-duplicate-props": "warn", - "react/jsx-no-undef": "warn", - "react/jsx-uses-react": "off", - "react/jsx-uses-vars": "error", "react/no-danger": "warn", - "react/no-did-mount-set-state": "warn", - "react/no-did-update-set-state": "warn", - "react/no-direct-mutation-state": "warn", - "react/no-multi-comp": ["warn", { "ignoreStateless": true }], - "react/no-unknown-property": "error", + "react/no-multi-comp": [ + "warn", + { + "ignoreStateless": true + } + ], "react/prefer-es6-class": "warn", - "react/prop-types": "off", - "react/react-in-jsx-scope": "off", - "react/self-closing-comp": "warn", - "curly": ["error", "all"] + "react/self-closing-comp": "error", + "curly": [ + "error", + "all" + ] }, "overrides": [ { - "files": ["**/*.stories.*"], + "files": [ + "**/*.stories.*" + ], "rules": { "import/no-anonymous-default-export": "off", "@typescript-eslint/no-var-requires": "off" } }, { - "files": ["**/mocks/mockAPI.js", "**/index.js", "cypress.config.js"], + "files": [ + "**/mocks/mockAPI.js", + "**/index.js", + "cypress.config.js" + ], "rules": { "@typescript-eslint/no-unused-vars": "off", "@typescript-eslint/no-var-requires": "off" diff --git a/.prettierrc b/.prettierrc index f555b99199a3b603afa7aca08a242d7e643466f4..05808086bbc918b51117ed02c9c105fd538c3a1e 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,4 +1,7 @@ { + "singleQuote": false, "trailingComma": "none", - "singleAttributePerLine": true + "singleAttributePerLine": true, + "tabWidth": 2, + "semi": true } diff --git a/package-lock.json b/package-lock.json index 43abe1d378a3037b373b53d1623995f7f341a30d..7c6a4763a67230935b7ccbe837557e153a0a012d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -50,7 +50,9 @@ "eslint-import-resolver-typescript": "^3.6.3", "eslint-plugin-cypress": "^2.15.1", "eslint-plugin-import": "^2.30.0", + "eslint-plugin-prettier": "^5.2.1", "eslint-plugin-react": "^7.37.1", + "eslint-plugin-react-hooks": "^5.0.0", "https-browserify": "^1.0.0", "msw": "^1.2.1", "msw-storybook-addon": "^1.10.0", @@ -4035,6 +4037,19 @@ "node": ">=14" } }, + "node_modules/@pkgr/core": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/@pkgr/core/-/core-0.1.1.tgz", + "integrity": "sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.20.0 || ^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/unts" + } + }, "node_modules/@pmmmwh/react-refresh-webpack-plugin": { "version": "0.5.11", "dev": true, @@ -12886,6 +12901,8 @@ }, "node_modules/eslint-config-prettier": { "version": "9.1.0", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-9.1.0.tgz", + "integrity": "sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==", "dev": true, "license": "MIT", "bin": { @@ -13145,6 +13162,20 @@ } } }, + "node_modules/eslint-config-react-app/node_modules/eslint-plugin-react-hooks": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.6.2.tgz", + "integrity": "sha512-QzliNJq4GinDBcD8gPB5v0wh6g8q3SUi6EFF0x8N/BL9PoVs0atuGc47ozMRyOWAKdwaZ5OnbOEa3WR+dSGKuQ==", + "dev": true, + "license": "MIT", + "peer": true, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "eslint": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0" + } + }, "node_modules/eslint-config-react-app/node_modules/eslint-scope": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", @@ -13483,6 +13514,37 @@ "eslint": "^3 || ^4 || ^5 || ^6 || ^7 || ^8" } }, + "node_modules/eslint-plugin-prettier": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-5.2.1.tgz", + "integrity": "sha512-gH3iR3g4JfF+yYPaJYkN7jEl9QbweL/YfkoRlNnuIEHEz1vHVlCmWOS+eGGiRuzHQXdJFCOTxRgvju9b8VUmrw==", + "dev": true, + "license": "MIT", + "dependencies": { + "prettier-linter-helpers": "^1.0.0", + "synckit": "^0.9.1" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint-plugin-prettier" + }, + "peerDependencies": { + "@types/eslint": ">=8.0.0", + "eslint": ">=8.0.0", + "eslint-config-prettier": "*", + "prettier": ">=3.0.0" + }, + "peerDependenciesMeta": { + "@types/eslint": { + "optional": true + }, + "eslint-config-prettier": { + "optional": true + } + } + }, "node_modules/eslint-plugin-react": { "version": "7.37.1", "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.37.1.tgz", @@ -13516,16 +13578,16 @@ } }, "node_modules/eslint-plugin-react-hooks": { - "version": "4.6.2", - "resolved": "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.6.2.tgz", - "integrity": "sha512-QzliNJq4GinDBcD8gPB5v0wh6g8q3SUi6EFF0x8N/BL9PoVs0atuGc47ozMRyOWAKdwaZ5OnbOEa3WR+dSGKuQ==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-5.0.0.tgz", + "integrity": "sha512-hIOwI+5hYGpJEc4uPRmz2ulCjAGD/N13Lukkh8cLV0i2IRk/bdZDYjgLVHj+U9Z704kLIdIO6iueGvxNur0sgw==", "dev": true, - "peer": true, + "license": "MIT", "engines": { "node": ">=10" }, "peerDependencies": { - "eslint": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0" + "eslint": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0 || ^9.0.0" } }, "node_modules/eslint-plugin-react/node_modules/doctrine": { @@ -14269,6 +14331,13 @@ "version": "3.1.3", "license": "MIT" }, + "node_modules/fast-diff": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.3.0.tgz", + "integrity": "sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==", + "dev": true, + "license": "Apache-2.0" + }, "node_modules/fast-glob": { "version": "3.3.2", "dev": true, @@ -22406,6 +22475,19 @@ "url": "https://github.com/prettier/prettier?sponsor=1" } }, + "node_modules/prettier-linter-helpers": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", + "integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-diff": "^1.1.2" + }, + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/pretty-bytes": { "version": "5.6.0", "dev": true, @@ -27703,6 +27785,23 @@ "dev": true, "license": "BSD-3-Clause" }, + "node_modules/synckit": { + "version": "0.9.2", + "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.9.2.tgz", + "integrity": "sha512-vrozgXDQwYO72vHjUb/HnFbQx1exDjoKzqx23aXEg2a9VIg2TSFZ8FmeZpTjUCFMYw7mpX4BE2SFu8wI7asYsw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@pkgr/core": "^0.1.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/unts" + } + }, "node_modules/syntax-error": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/syntax-error/-/syntax-error-1.4.0.tgz", @@ -33148,6 +33247,12 @@ "dev": true, "optional": true }, + "@pkgr/core": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/@pkgr/core/-/core-0.1.1.tgz", + "integrity": "sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA==", + "dev": true + }, "@pmmmwh/react-refresh-webpack-plugin": { "version": "0.5.11", "dev": true, @@ -39316,6 +39421,8 @@ }, "eslint-config-prettier": { "version": "9.1.0", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-9.1.0.tgz", + "integrity": "sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==", "dev": true, "requires": {} }, @@ -39459,6 +39566,14 @@ "@typescript-eslint/experimental-utils": "^5.0.0" } }, + "eslint-plugin-react-hooks": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.6.2.tgz", + "integrity": "sha512-QzliNJq4GinDBcD8gPB5v0wh6g8q3SUi6EFF0x8N/BL9PoVs0atuGc47ozMRyOWAKdwaZ5OnbOEa3WR+dSGKuQ==", + "dev": true, + "peer": true, + "requires": {} + }, "eslint-scope": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", @@ -39694,6 +39809,16 @@ "object.fromentries": "^2.0.7" } }, + "eslint-plugin-prettier": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-5.2.1.tgz", + "integrity": "sha512-gH3iR3g4JfF+yYPaJYkN7jEl9QbweL/YfkoRlNnuIEHEz1vHVlCmWOS+eGGiRuzHQXdJFCOTxRgvju9b8VUmrw==", + "dev": true, + "requires": { + "prettier-linter-helpers": "^1.0.0", + "synckit": "^0.9.1" + } + }, "eslint-plugin-react": { "version": "7.37.1", "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.37.1.tgz", @@ -39739,11 +39864,10 @@ } }, "eslint-plugin-react-hooks": { - "version": "4.6.2", - "resolved": "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.6.2.tgz", - "integrity": "sha512-QzliNJq4GinDBcD8gPB5v0wh6g8q3SUi6EFF0x8N/BL9PoVs0atuGc47ozMRyOWAKdwaZ5OnbOEa3WR+dSGKuQ==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-5.0.0.tgz", + "integrity": "sha512-hIOwI+5hYGpJEc4uPRmz2ulCjAGD/N13Lukkh8cLV0i2IRk/bdZDYjgLVHj+U9Z704kLIdIO6iueGvxNur0sgw==", "dev": true, - "peer": true, "requires": {} }, "eslint-plugin-testing-library": { @@ -40150,6 +40274,12 @@ "fast-deep-equal": { "version": "3.1.3" }, + "fast-diff": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.3.0.tgz", + "integrity": "sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==", + "dev": true + }, "fast-glob": { "version": "3.3.2", "dev": true, @@ -45589,6 +45719,15 @@ "integrity": "sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==", "dev": true }, + "prettier-linter-helpers": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", + "integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==", + "dev": true, + "requires": { + "fast-diff": "^1.1.2" + } + }, "pretty-bytes": { "version": "5.6.0", "dev": true @@ -49489,6 +49628,16 @@ "version": "2.0.17", "dev": true }, + "synckit": { + "version": "0.9.2", + "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.9.2.tgz", + "integrity": "sha512-vrozgXDQwYO72vHjUb/HnFbQx1exDjoKzqx23aXEg2a9VIg2TSFZ8FmeZpTjUCFMYw7mpX4BE2SFu8wI7asYsw==", + "dev": true, + "requires": { + "@pkgr/core": "^0.1.0", + "tslib": "^2.6.2" + } + }, "syntax-error": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/syntax-error/-/syntax-error-1.4.0.tgz", diff --git a/package.json b/package.json index b182e131368e2050d257e893c330d6989a0e29c3..c11677571dc985022cc53281543e3794a7fd9515 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,9 @@ "eslint-import-resolver-typescript": "^3.6.3", "eslint-plugin-cypress": "^2.15.1", "eslint-plugin-import": "^2.30.0", + "eslint-plugin-prettier": "^5.2.1", "eslint-plugin-react": "^7.37.1", + "eslint-plugin-react-hooks": "^5.0.0", "https-browserify": "^1.0.0", "msw": "^1.2.1", "msw-storybook-addon": "^1.10.0", diff --git a/src/App.js b/src/App.js index bdbab914242eff577a0f79b7d0aabd71d712e628..50b4dc1c2815a780725a7c46f0ead4a87d8fbecf 100644 --- a/src/App.js +++ b/src/App.js @@ -1,8 +1,7 @@ import { useContext, useEffect } from "react"; import { Navigate, Route, Routes, BrowserRouter } from "react-router-dom"; -import { StyledEngineProvider } from "@mui/material"; +import { StyledEngineProvider, CssBaseline } from "@mui/material"; import { ThemeProvider } from "@mui/material/styles"; -import { CssBaseline } from "@mui/material"; import { theme } from "./style/Theme"; import { IOCListView } from "./views/IOC/IOCListView"; import NavigationMenu from "./components/navigation/NavigationMenu"; @@ -15,13 +14,12 @@ import { HelpView } from "./views/help/HelpView"; import { SnackbarProvider } from "notistack"; import TokenRenew from "./components/auth/TokenRenew"; import { NotFoundView } from "./components/navigation/NotFoundView"; -import { AppErrorBoundary } from "@ess-ics/ce-ui-common"; +import { AppErrorBoundary, GlobalAppBarContext } from "@ess-ics/ce-ui-common"; import { LoginView } from "./views/login/LoginView"; import { JobLogAccessControl } from "./views/jobs/JobLogAccessControl"; import { RecordListView } from "./views/records/RecordListView"; import { RecordDetailsView } from "./views/records/RecordDetailsView"; import { TestErrorView } from "./views/TestErrorView"; -import { GlobalAppBarContext } from "@ess-ics/ce-ui-common"; import { applicationTitle } from "./components/common/Helper"; import { CreateIOCAccessControl } from "./views/IOC/CreateIOCAccessControl"; import { UserDetailsAccessControl } from "./views/UserPage/UserDetailsAccessControl"; diff --git a/src/components/IOC/IOCDelete/IOCDelete.js b/src/components/IOC/IOCDelete/IOCDelete.js index b7b4c11f664c737faeb97c6fec07a113204dbb7f..f88a0267fc1bf9c18c1382333159a3f9adb96b82 100644 --- a/src/components/IOC/IOCDelete/IOCDelete.js +++ b/src/components/IOC/IOCDelete/IOCDelete.js @@ -2,11 +2,10 @@ import { useState, useEffect, useCallback, useContext, useMemo } from "react"; import { useNavigate } from "react-router-dom"; import { useCustomSnackbar } from "../../common/snackbar"; import { Box, Button, Grid, Tooltip, Typography } from "@mui/material"; -import { ConfirmDangerActionDialog } from "@ess-ics/ce-ui-common"; +import { ConfirmDangerActionDialog, useAPIMethod } from "@ess-ics/ce-ui-common"; import Alert from "@mui/material/Alert"; import AccessControl from "../../auth/AccessControl"; import { apiContext } from "../../../api/DeployApi"; -import { useAPIMethod } from "@ess-ics/ce-ui-common"; export default function IOCDelete({ ioc, buttonDisabled, setButtonDisabled }) { const navigate = useNavigate(); diff --git a/src/components/common/Status/StatusBadge.js b/src/components/common/Status/StatusBadge.js index ba4f700d43135383f5889140ebe91087e4472be8..cd203a349189b12a82e54c3073d01511571f078d 100644 --- a/src/components/common/Status/StatusBadge.js +++ b/src/components/common/Status/StatusBadge.js @@ -17,27 +17,32 @@ const commonStyles = { fontSize: "20px" }; -export const StatusBadge = ({ status, theme, children }) => ( - <Stack sx={{ position: "relative" }}> - {children} - {status === STATUS.warning || +export const StatusBadge = ({ status, theme, children }) => { + const showWarning = + status === STATUS.warning || status === STATUS.inactiveWarning || - status === STATUS.disabledWarning ? ( - <WarningAmberIcon - sx={{ fill: theme.palette.warning.main, ...commonStyles }} - /> - ) : ( - <> - {status === STATUS.alert || - status === STATUS.inactiveAlert || - status === STATUS.disabledAlert ? ( - <ErrorOutlineIcon - sx={{ fill: theme.palette.error.main, ...commonStyles }} - /> - ) : null} - </> - )} - </Stack> -); + status === STATUS.disabledWarning; + + const showError = + status === STATUS.alert || + status === STATUS.inactiveAlert || + status === STATUS.disabledAlert; + + return ( + <Stack sx={{ position: "relative" }}> + {children} + {showWarning && ( + <WarningAmberIcon + sx={{ fill: theme.palette.warning.main, ...commonStyles }} + /> + )} + {showError && ( + <ErrorOutlineIcon + sx={{ fill: theme.palette.error.main, ...commonStyles }} + /> + )} + </Stack> + ); +}; StatusBadge.propTypes = propTypes; diff --git a/src/components/common/User/UserOperationList.js b/src/components/common/User/UserOperationList.js index 11212e325f03c7625cde2e09ce4de541941368a8..52345558afae0eb9a9167cd1bb27e5d862839520 100644 --- a/src/components/common/User/UserOperationList.js +++ b/src/components/common/User/UserOperationList.js @@ -1,7 +1,6 @@ -import { useCallback, useContext } from "react"; +import { useCallback, useContext, useEffect } from "react"; import { Card, CardHeader } from "@mui/material"; import { initRequestParams } from "../Helper"; -import { useEffect } from "react"; import { JobTable } from "../../Job"; import { apiContext } from "../../../api/DeployApi"; import { useAPIMethod, usePagination, usePolling } from "@ess-ics/ce-ui-common"; diff --git a/src/components/navigation/LoginSuggester/LoginSuggester.js b/src/components/navigation/LoginSuggester/LoginSuggester.js index f0c012e5d0d8e3152a8ce28e0c88cc8f500ae1bb..f8632a178faf9f22ecaf38d475e598e7c39e4d41 100644 --- a/src/components/navigation/LoginSuggester/LoginSuggester.js +++ b/src/components/navigation/LoginSuggester/LoginSuggester.js @@ -1,9 +1,7 @@ import { useContext, useEffect, useCallback, useState } from "react"; -import { CookiesProvider } from "react-cookie"; -import { useCookies } from "react-cookie"; +import { CookiesProvider, useCookies } from "react-cookie"; import { userContext } from "@ess-ics/ce-ui-common"; import { useEffectOnMount } from "../../../hooks/MountEffects"; -// import { useRedirect } from "../../../hooks/Redirect"; import { useNavigate } from "react-router-dom"; export function LoginSuggester({ children }) { diff --git a/src/components/navigation/NavigationMenu/NavigationMenu.js b/src/components/navigation/NavigationMenu/NavigationMenu.js index 2a62989ad121c560af169e8ffc19975b7c11f949..b461e4c2376383b5372e629c9bcb14d9a853d05d 100644 --- a/src/components/navigation/NavigationMenu/NavigationMenu.js +++ b/src/components/navigation/NavigationMenu/NavigationMenu.js @@ -4,7 +4,9 @@ import { IconMenuButton, EssIconLogo, BodyBox, - useUniqueKeys + useUniqueKeys, + useAPIMethod, + MaintenanceModeBanner } from "@ess-ics/ce-ui-common"; import { Assignment, @@ -28,7 +30,6 @@ import { Link } from "react-router-dom"; import { CCCEControlSymbol } from "../../../icons/CCCEControlSymbol"; import { CreateIOCButton } from "./CreateIOCButton"; import { theme } from "../../../style/Theme"; -import { useAPIMethod, MaintenanceModeBanner } from "@ess-ics/ce-ui-common"; import { apiContext } from "../../../api/DeployApi"; function MenuListItem({ url, icon, text, tooltip }) { diff --git a/src/views/IOC/IOCDetailsContainer.js b/src/views/IOC/IOCDetailsContainer.js index 90b225416a54d37ec675df87eb73526814fa1111..a36e7240354726fb971a7d6aa1c41dda7cadeab0 100644 --- a/src/views/IOC/IOCDetailsContainer.js +++ b/src/views/IOC/IOCDetailsContainer.js @@ -49,23 +49,25 @@ export function IOCDetailsContainer({ id }) { } }, [urlState, user]); + if (error) { + return ( + <NotFoundView + message={error?.message} + status={error?.status} + /> + ); + } + + if (loading || !ioc) { + return <LinearProgress color="primary" />; + } + return ( - <> - {error ? ( - <NotFoundView - message={error?.message} - status={error?.status} - /> - ) : ioc ? ( - <IOCDetailsView - ioc={ioc} - getIOC={getIOC} - abortGetIOC={abortGetIOC} - loading={loading} - /> - ) : ( - <LinearProgress color="primary" /> - )} - </> + <IOCDetailsView + ioc={ioc} + getIOC={getIOC} + abortGetIOC={abortGetIOC} + loading={loading} + /> ); } diff --git a/src/views/help/HelpView.js b/src/views/help/HelpView.js index a8fa16967705ce43bcb06129edc604bab55eeaa8..46b392ab01762a1c1b6f6ee803825b31ffbb8777 100644 --- a/src/views/help/HelpView.js +++ b/src/views/help/HelpView.js @@ -1,7 +1,6 @@ import { useContext, useEffect } from "react"; -import { RootPaper, Help } from "@ess-ics/ce-ui-common"; +import { RootPaper, Help, GlobalAppBarContext } from "@ess-ics/ce-ui-common"; import { Stack, Typography } from "@mui/material"; -import { GlobalAppBarContext } from "@ess-ics/ce-ui-common"; import { applicationTitle } from "../../components/common/Helper"; import env from "../../config/env"; diff --git a/src/views/host/details/HostDetailsContainer.js b/src/views/host/details/HostDetailsContainer.js index 3c30a771970065ed9b101b8a1b6171e8cbe02cc6..6d066eef08ab2e893e9e7d3a08733843f9d43f9d 100644 --- a/src/views/host/details/HostDetailsContainer.js +++ b/src/views/host/details/HostDetailsContainer.js @@ -46,19 +46,24 @@ export function HostDetailsContainer({ hostId }) { } }, [fetchError, alertError]); + if (error) { + return ( + <NotFoundView + message={error?.message} + status={error?.status} + /> + ); + } + + if (!host || !alert) { + return <LinearProgress color="primary" />; + } + return ( - <> - {error ? ( - <NotFoundView /> - ) : host && alert ? ( - <HostDetailsView - host={host} - alert={alert} - hostId={hostId} - /> - ) : ( - <LinearProgress color="primary" /> - )} - </> + <HostDetailsView + host={host} + alert={alert} + hostId={hostId} + /> ); } diff --git a/src/views/jobs/JobDetailsContainer.js b/src/views/jobs/JobDetailsContainer.js index 8bd54e9e6f0f4af243df49413c36846896ac41e2..4bc8bc56c99d37d5ea973d20df8cfa43863f44a8 100644 --- a/src/views/jobs/JobDetailsContainer.js +++ b/src/views/jobs/JobDetailsContainer.js @@ -36,15 +36,18 @@ export function JobDetailsContainer({ id }) { usePolling(getJob, job?.finishedAt, POLL_DEPLOYMENT_INTERVAL); - return ( - <> - {notFoundError ? ( - <NotFoundView /> - ) : job ? ( - <JobDetailsView job={job} /> - ) : ( - <LinearProgress color="primary" /> - )} - </> - ); + if (notFoundError) { + return ( + <NotFoundView + message={notFoundError?.message} + status={notFoundError?.status} + /> + ); + } + + if (!job) { + return <LinearProgress color="primary" />; + } + + return <JobDetailsView job={job} />; } diff --git a/src/views/jobs/JobListView.js b/src/views/jobs/JobListView.js index a8565f318a8afcbe547d898a0d028a08f5656ebb..9449ba16236be7433047ed0e8f03391e4461c5f0 100644 --- a/src/views/jobs/JobListView.js +++ b/src/views/jobs/JobListView.js @@ -1,4 +1,4 @@ -import { useContext, useCallback, useMemo } from "react"; +import { useContext, useCallback, useMemo, useEffect } from "react"; import { Box } from "@mui/material"; import { RootPaper, @@ -7,7 +7,6 @@ import { usePolling } from "@ess-ics/ce-ui-common"; import { initRequestParams } from "../../components/common/Helper"; -import { useEffect } from "react"; import useUrlState from "@ahooksjs/use-url-state"; import { serialize, diff --git a/src/views/records/RecordDetailsView.js b/src/views/records/RecordDetailsView.js index 9db71d3e648faffad9954ff279846bd2aab7528e..d6340fba41f610e9c58066e7bb2195ca61edfa36 100644 --- a/src/views/records/RecordDetailsView.js +++ b/src/views/records/RecordDetailsView.js @@ -6,17 +6,19 @@ import { KeyValueTable, GlobalAppBarContext, InternalLink, - EmptyValue + EmptyValue, + useAPIMethod, + formatDateAndTime } from "@ess-ics/ce-ui-common"; import { RecordBadge } from "../../components/records/RecordBadge"; -import { applicationTitle } from "../../components/common/Helper"; -import { useParams } from "react-router-dom"; -import { useNavigate } from "react-router-dom"; -import { onFetchEntityError } from "../../components/common/Helper"; +import { + applicationTitle, + onFetchEntityError +} from "../../components/common/Helper"; +import { useParams, useNavigate } from "react-router-dom"; import NotFoundView from "../../components/navigation/NotFoundView/NotFoundView"; import { apiContext } from "../../api/DeployApi"; -import { useAPIMethod, formatDateAndTime } from "@ess-ics/ce-ui-common"; export function RecordDetailsView() { const { name } = useParams(); @@ -124,39 +126,43 @@ export function RecordDetailsView() { return subset; }, []); - return decodedName.includes(";") ? ( - <NotFoundView /> - ) : ( - <RootPaper> - {error ? ( - <NotFoundView /> - ) : recordLoading || !dataReady ? ( + if (decodedName.includes(";") || error) { + return <NotFoundView />; + } + + if (recordLoading || !dataReady) { + return ( + <RootPaper> <LinearProgress color="primary" /> - ) : ( - <> - <IconButton - color="inherit" - onClick={handleClick} - size="large" - > - <ArrowBackIcon /> - </IconButton> - {record && ( - <> - <RecordBadge - record={record} - sx={{ mt: 2.5 }} - /> - <KeyValueTable - obj={getSubset(record)} - variant="overline" - sx={{ border: 0 }} - valueOptions={{ headerName: "" }} - /> - </> - )} - </> - )} + </RootPaper> + ); + } + + return ( + <RootPaper> + <> + <IconButton + color="inherit" + onClick={handleClick} + size="large" + > + <ArrowBackIcon /> + </IconButton> + {record && ( + <> + <RecordBadge + record={record} + sx={{ mt: 2.5 }} + /> + <KeyValueTable + obj={getSubset(record)} + variant="overline" + sx={{ border: 0 }} + valueOptions={{ headerName: "" }} + /> + </> + )} + </> </RootPaper> ); }