From 71feb8c3d424a8519f6ad4fb79efd9ac938d6c80 Mon Sep 17 00:00:00 2001 From: lindot11 Date: Tue, 21 Nov 2023 21:16:50 +0100 Subject: [PATCH] Added refactored format-check script to run in pre-commit removed typo added repo to test pre-commit test pre-commit with typo undo typo and uncomment mdlint test pre-commit with typo remove type test pre-commit uncomment format-check test dummy format test dummy commit dummies to git for test git diff test pre-commit eslint pre-commit config to replace custom pre-commit added directory lib to hooks test pre-commit yarn install yarn install logic to pre-commit prettified pre-commit-config added pre-push hooks test dummy pre-push test pre-push yarn jest test pre-push yarn jest test again test pre-push again test again TEST CORRECTLY test manual push another manual test test all pre-commit hooks added default hooks added pre-push test for lib test git hooks dir test git hooks dir test dir with dummie undo hook dir back to before test git hooks test git hooks test git hooks test git hooks test git hooks test git hooks test git hooks test git hooks test git hooks test git hooks test git hooks test git hooks reset after test test git hooks test git hooks test git hooks reset after test test git hooks reset after test test git hooks test git hooks reset after test test git hooks reset after test reset after test reset after test reset after test reset after test test script for git hooks done githook test and log for documentation reset after test reset after test reset after test reset after test reset after test reset after test reset after test reset after test test git hooks reset after test test git hooks reset after test test git hooks reset after test improved test went back to original test test git hooks final test script reset after test test git hooks reset after test reset after test reset after test reset after test reset after test test and log done added new githook script and updated guide comment out lib test hook stage markdownlint changes log githook run accept prettified changes updated run log removed logs and test from repo updated configure-git-hooks script and docs updated hook to use markdownlint/markdownlint removed unnecessary readme added prettier config to client undo change non trailling commas for client and lib undo trailing commas to test code cov Revert "undo trailing commas to test code cov" This reverts commit e5bf3195d4a8edd2559c7787cf9f8f7e5f95eef2. undo trailling commas to test codecov undo trailling commas in lib undo single quote prettier test undo semiconlons test remove trailling commas lib set traillingcomma all undo prettierrc accept prettier lib improves codecov accept prettier client improves codecov Swap ml-workspace container and improve docs (#300) - Replaces ml-workspace container with ml-workspace-minimal container. This change potentially improves the speed of user workspace. - Adds guide book to help with non-standard installation scenarios. - Adds MongoDB installation to services.js --------- Co-authored-by: nichlaes Corrects docker commands and updates docs (#304) - Corrects docker run commands to always restart the containers - Updates diagrams in docs to include MongoDB - Adds yarn clean command to package.json of services. uncomment prettier replace deprecated code_blocks uncomment markdownlint fixed table mdl error ignore url line length mdl redo mdl hook ignore table line length and use .markdownlint.yaml instead replaced by pre-commit framework adhere to code climate linelength Adds scope to library tabs (#235 and #321) - Shows the right directory for each tab in Library page - Adds second level tabs to Library page. These tabs separate private and common assets --------- Co-authored-by: caesarv16 <816590@unizar.es> Co-authored-by: s88004 markdownlint disable codeblock test test deprecated code_blocks in codeclimate shortened comment to adhere to line_length --- .git-hooks/pre-commit | 30 - .git-hooks/pre-push | 31 - .gitignore | 5 +- .markdownlint.yaml | 12 +- .pre-commit-config.yaml | 66 +- client/.prettierrc | 4 + client/LICENSE.md | 8 +- client/public/static/css/MaterialIcon.css | 4 +- client/public/static/font/README.md | 22 - client/src/components/tab/TabComponent.tsx | 72 +- client/src/index.tsx | 4 +- client/src/route/auth/AccountTabs.tsx | 6 +- .../src/route/digitaltwins/DigitalTwins.tsx | 14 +- client/src/route/library/Library.tsx | 44 +- client/src/route/library/LibraryTabData.ts | 14 +- client/test/README.md | 1 - client/test/e2e/playwright/Auth.test.ts | 4 +- client/test/e2e/playwright/Menu.test.ts | 4 +- client/test/e2e/playwright/auth.setup.ts | 2 +- client/test/integration/authRedux.test.tsx | 4 +- .../unitTests/Components/Linkbuttons.test.tsx | 6 +- .../Components/PrivateRoute.test.tsx | 2 +- .../Components/TabComponent.test.tsx | 100 ++- .../test/unitTests/Page/LayoutPublic.test.tsx | 2 +- client/test/unitTests/Page/page.testUtils.tsx | 2 +- .../unitTests/Routes/DigitalTwins.test.tsx | 9 +- client/test/unitTests/Routes/Library.test.tsx | 8 +- client/test/unitTests/Routes/SignIn.test.tsx | 6 +- client/test/unitTests/Util/Store.test.ts | 6 +- client/test/unitTests/Util/envUtil.test.ts | 12 +- .../test/unitTests/auth/AuthProvider.test.tsx | 2 +- client/test/unitTests/testUtils.tsx | 49 +- deploy/install.sh | 7 +- deploy/services/package.json | 3 + deploy/services/services.js | 48 +- deploy/services/services.yml | 5 + .../two-machine => services}/yarn.lock | 0 deploy/single-script-install.sh | 7 +- deploy/vagrant/make_boxes/dtaas/README.md | 3 +- deploy/vagrant/make_boxes/dtaas/user.sh | 3 +- docs/admin/client/CLIENT.md | 4 +- docs/admin/client/auth.md | 9 +- docs/admin/guides/add_service.md | 113 +++ docs/admin/guides/add_user.md | 81 ++ .../admin/guides/common_workspace_readonly.md | 40 + .../guides/hosting_site_without_https.md | 6 + docs/admin/guides/link_service.md | 42 ++ .../guides/open_terminal_in_workspace.gif | Bin 0 -> 85953 bytes docs/admin/guides/update_basepath.md | 78 ++ docs/admin/host.md | 64 +- docs/admin/overview.md | 2 +- docs/admin/services.md | 1 + docs/admin/trial.md | 21 +- docs/admin/vagrant/base-box.md | 4 +- docs/admin/vagrant/basebox.png | Bin 71505 -> 77603 bytes docs/admin/vagrant/single-machine.png | Bin 221978 -> 224841 bytes docs/admin/vagrant/two-machine-use-legend.png | Bin 102062 -> 107217 bytes docs/admin/vagrant/two-machine.png | Bin 211639 -> 217955 bytes docs/admin/vagrant/two-machines.md | 10 +- docs/bugs.md | 9 +- docs/developer/system/DTaaS.drawio | 698 +++++++++++++++++- .../digital-twins/lifecycle-four-stages.png | Bin 40921 -> 52085 bytes docs/user/examples/incubator/README.md | 4 +- mkdocs-github.yml | 7 + mkdocs.yml | 7 + script/configure-git-hooks.sh | 6 +- script/docker.sh | 3 +- servers/config/gateway/README.md | 13 +- servers/execution/runner/LICENSE.md | 8 +- servers/execution/runner/README.md | 36 +- servers/lib/DEVELOPER.md | 25 +- servers/lib/LICENSE.md | 8 +- servers/lib/README.md | 9 +- servers/lib/test/starttraefik.bash | 11 +- 74 files changed, 1574 insertions(+), 376 deletions(-) delete mode 100755 .git-hooks/pre-commit delete mode 100755 .git-hooks/pre-push create mode 100644 client/.prettierrc delete mode 100644 client/public/static/font/README.md rename deploy/{vagrant/two-machine => services}/yarn.lock (100%) create mode 100644 docs/admin/guides/add_service.md create mode 100644 docs/admin/guides/add_user.md create mode 100644 docs/admin/guides/common_workspace_readonly.md create mode 100644 docs/admin/guides/hosting_site_without_https.md create mode 100644 docs/admin/guides/link_service.md create mode 100644 docs/admin/guides/open_terminal_in_workspace.gif create mode 100644 docs/admin/guides/update_basepath.md diff --git a/.git-hooks/pre-commit b/.git-hooks/pre-commit deleted file mode 100755 index ab11d029b..000000000 --- a/.git-hooks/pre-commit +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env sh - -TOP_DIR="$(pwd)" -export TOP_DIR - -if git diff --cached --name-only | grep "^client/" >/dev/null; then - cd client || exit - yarn install - yarn format && yarn syntax -else - printf "No changes in the client directory. Skipping pre-commit hook.\n\n" -fi - -cd "$TOP_DIR" || exit -if git diff --cached --name-only | grep "^servers/execution/runner/" >/dev/null; then - cd "servers/execution/runner" || exit - yarn install - yarn format && yarn syntax -else - printf "No changes in the servers/execution/runner directory. Skipping pre-commit hook.\n\n" -fi - -cd "$TOP_DIR" || exit -if git diff --cached --name-only | grep "^servers/lib/" >/dev/null; then - cd "servers/lib" || exit - yarn install - yarn format && yarn syntax -else - printf "No changes in the servers/lib directory. Skipping pre-commit hook.\n\n" -fi \ No newline at end of file diff --git a/.git-hooks/pre-push b/.git-hooks/pre-push deleted file mode 100755 index f0de92346..000000000 --- a/.git-hooks/pre-push +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env sh - -BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD) -TOP_DIR="$(pwd)" -export TOP_DIR - -if git diff --name-only origin/"$BRANCH_NAME"...HEAD -- | grep "^client/" >/dev/null; then - cd client || exit - yarn install - yarn jest . --coverage=false -else - printf "No changes in the client directory. Skipping pre-push hook.\n\n" -fi - -cd "$TOP_DIR" || exit -if git diff --name-only origin/"$BRANCH_NAME"...HEAD -- | grep "^servers/execution/runner/" >/dev/null; then - cd "servers/execution/runner" || exit - yarn install - yarn test:nocov -else - printf "No changes in the servers/execution/runner/ directory. Skipping pre-push hook.\n\n" -fi - -# cd "$TOP_DIR" || exit -# if git diff --name-only origin/"$BRANCH_NAME"...HEAD | grep "^servers/lib/" >/dev/null; then -# cd "servers/lib" || exit -# yarn install -# yarn test:nocov -# else -# printf "No changes in the servers/lib/ directory. Skipping pre-push hook.\n\n" -# fi diff --git a/.gitignore b/.gitignore index 082bb4729..9704be111 100644 --- a/.gitignore +++ b/.gitignore @@ -158,4 +158,7 @@ src.svg test.svg # config files -runner.yml \ No newline at end of file +runner.yml + +# Jupter Lab +.workspace diff --git a/.markdownlint.yaml b/.markdownlint.yaml index 5b9cfa6c5..0b754b190 100644 --- a/.markdownlint.yaml +++ b/.markdownlint.yaml @@ -1,7 +1,7 @@ -# Default state for all rules default: true - -# MD013/line-length - Line length -MD013: - line_length: 80 - tables: false +MD033: false +MD013: + code_blocks: false + tables: true +MD046: + style: "fenced" \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d17707538..6cb5f3ccc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,68 @@ +default_install_hook_types: [pre-commit, pre-push] + repos: + - repo: local + hooks: + - id: yarn-install-client + name: yarn install client + entry: bash + language: system + files: "^client/.*" + args: ["-c", "cd client && yarn install"] + - id: yarn-install-runner + name: yarn install runner + entry: bash + language: system + files: "^servers/execution/runner/.*" + args: ["-c", "cd servers/execution/runner && yarn install"] + - id: yarn-install-lib + name: yarn install lib + entry: bash + language: system + files: "^servers/lib/.*" + args: ["-c", "cd servers/lib && yarn install"] + + - id: yarn-jest-client + name: yarn jest client + entry: bash + language: system + files: "^client/.*" + args: ["-c", "cd client && yarn jest . --coverage=false"] + stages: [pre-push] + - id: yarn-test-runner + name: yarn test runner + entry: bash + language: system + files: "^servers/execution/runner/.*" + args: ["-c", "cd servers/execution/runner && yarn test:nocov"] + stages: [pre-push] + # - id: yarn-test-lib + # name: yarn test lib + # entry: bash + # language: system + # files: "^servers/lib/.*" + # args: ["-c", "cd servers/lib && yarn jest . --coverage=false"] + # stages: [pre-push] + + - repo: https://github.com/pre-commit/mirrors-prettier + rev: v3.1.0 + hooks: + - id: prettier + args: ["--ignore-path", "../.gitignore", "--write"] + files: '^(client|servers/execution/runner|servers/lib)/.*\.(ts|tsx|css|scss)$' + stages: [pre-commit] + + - repo: https://github.com/pre-commit/mirrors-eslint + rev: v8.54.0 + hooks: + - id: eslint + args: ["--fix"] + files: "^(client|servers/execution/runner|servers/lib)/.*" + stages: [pre-commit] + - repo: https://github.com/igorshubovych/markdownlint-cli - rev: v0.32.2 + rev: v0.37.0 hooks: - id: markdownlint - args: ["--fix"] + files: '^(client|servers/execution/runner|servers/lib)/.*\.md$' + stages: [pre-commit] \ No newline at end of file diff --git a/client/.prettierrc b/client/.prettierrc new file mode 100644 index 000000000..a20502b7f --- /dev/null +++ b/client/.prettierrc @@ -0,0 +1,4 @@ +{ + "singleQuote": true, + "trailingComma": "all" +} diff --git a/client/LICENSE.md b/client/LICENSE.md index c0ad1333c..c23748f41 100644 --- a/client/LICENSE.md +++ b/client/LICENSE.md @@ -20,10 +20,10 @@ * The INTO-CPS tool suite software and the INTO-CPS Association * Public License (ICAPL) are obtained from the INTO-CPS Association, either -* from the above address, from the URLs: http://www.into-cps.org or +* from the above address, from the URLs: or * in the INTO-CPS tool suite distribution. * GNU version 3 is obtained from: -* http://www.gnu.org/copyleft/gpl.html. +* . * This program is distributed WITHOUT ANY WARRANTY; without * even the implied warranty of MERCHANTABILITY or FITNESS @@ -291,11 +291,11 @@ This Agreement is governed by the laws of Denmark. The place of jurisdiction for all disagreements related to this Agreement, is Aarhus, Denmark. The EPL 1.0 license definition has been obtained from: -http://www.eclipse.org/legal/epl-v10.html. +. It is also reproduced in the INTO-CPS distribution. The GPL Version 3 license definition has been obtained from -http://www.gnu.org/copyleft/gpl.html. +. It is also reproduced in the INTO-CPS distribution. --- End of Definition of INTO-CPS Association Public License --- diff --git a/client/public/static/css/MaterialIcon.css b/client/public/static/css/MaterialIcon.css index 5d7418a3f..6700ea0f1 100644 --- a/client/public/static/css/MaterialIcon.css +++ b/client/public/static/css/MaterialIcon.css @@ -4,7 +4,9 @@ font-family: 'Material Icons'; font-style: normal; font-weight: 400; - src: local('Material Icons'), local('MaterialIcons-Regular'), + src: + local('Material Icons'), + local('MaterialIcons-Regular'), url(/static/font/MaterialIcons-Regular.woff2) format('woff2'), url(/static/font/MaterialIcons-Regular.woff) format('woff'), url(/static/font/MaterialIcons-Regular.ttf) format('truetype'); diff --git a/client/public/static/font/README.md b/client/public/static/font/README.md deleted file mode 100644 index 7fa35e599..000000000 --- a/client/public/static/font/README.md +++ /dev/null @@ -1,22 +0,0 @@ -The recommended way to use the Material Icons font is by linking to the web font hosted on Google Fonts: - -```html - - - - - - - - - - - - -``` - - diff --git a/client/src/components/tab/TabComponent.tsx b/client/src/components/tab/TabComponent.tsx index f61bccabb..bbcec27c2 100644 --- a/client/src/components/tab/TabComponent.tsx +++ b/client/src/components/tab/TabComponent.tsx @@ -1,31 +1,65 @@ import * as React from 'react'; -import { Paper } from '@mui/material'; import TabRender, { TabData } from './subcomponents/TabRender'; import { Tab, TabList, TabPanel, Tabs } from './subcomponents/TabStyles'; -function TabComponent(props: { tabs: TabData[] }) { +export function constructURL(assetType: string, scope: string, libURL: string) { + let assetTab = assetType.toLowerCase(); + let scopeTab = scope.toLowerCase(); + + assetTab = assetTab === 'digital twins' ? 'digital_twins' : assetTab; + scopeTab = scopeTab === 'private' ? '' : `${scopeTab}/`; + + return `${libURL}tree/${scopeTab}${assetTab}`; +} + +function renderScopeTabList(scope: TabData[][], subIndex: number): JSX.Element { return ( - - - - {props.tabs.map((tab, index) => ( - {tab.label} - ))} - - {props.tabs.map((tab, index) => ( + + {scope && + scope[subIndex] && + scope[subIndex].map((tab, index) => {tab.label})} + + ); +} + +function renderScopeTabPanels( + scope: TabData[][], + subIndex: number +): JSX.Element { + return ( + <> + {scope && + scope[subIndex] && + scope[subIndex].map((tab, index) => ( {tab} ))} - - + + ); +} + +export function TabComponent(props: { + assetType: TabData[]; + scope: TabData[][]; +}): JSX.Element { + return ( + + + {props.assetType.map((tab, index) => ( + {tab.label} + ))} + {' '} + {props.assetType.map((subtab, subIndex) => ( + + {subtab} + + {renderScopeTabList(props.scope, subIndex)} + {renderScopeTabPanels(props.scope, subIndex)} + + + ))} + ); } diff --git a/client/src/index.tsx b/client/src/index.tsx index 40b8c7369..7db8206ed 100644 --- a/client/src/index.tsx +++ b/client/src/index.tsx @@ -57,7 +57,7 @@ const router = createBrowserRouter( ], { basename: `/${useURLbasename()}`, - } + }, ); const root = document.getElementById('root'); @@ -68,7 +68,7 @@ if (root) { - + , ); } else { throw Error("Couldn't find root element"); diff --git a/client/src/route/auth/AccountTabs.tsx b/client/src/route/auth/AccountTabs.tsx index cfa69082c..753604027 100644 --- a/client/src/route/auth/AccountTabs.tsx +++ b/client/src/route/auth/AccountTabs.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import TabComponent from 'components/tab/TabComponent'; import { TabData } from 'components/tab/subcomponents/TabRender'; -const tabs: TabData[] = [ +const accountTab: TabData[] = [ { label: 'Profile', body: <>Profile - potentially visible to other users., @@ -13,8 +13,10 @@ const tabs: TabData[] = [ }, ]; +const scope: TabData[][] = []; + function AccountTabs() { - return ; + return ; } export default AccountTabs; diff --git a/client/src/route/digitaltwins/DigitalTwins.tsx b/client/src/route/digitaltwins/DigitalTwins.tsx index b774c837c..c6f4580f2 100644 --- a/client/src/route/digitaltwins/DigitalTwins.tsx +++ b/client/src/route/digitaltwins/DigitalTwins.tsx @@ -10,22 +10,22 @@ import tabs from './DigitalTwinTabData'; function DTContent() { const DTurl = useURLforDT(); - const tabData: TabData[] = tabs.map((tab, i) => ({ + const DTTab: TabData[] = tabs.map((tab) => ({ label: tab.label, body: ( <> {tab.body} - {i === 0 && ( - <> -