-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
2,822 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module.exports = { | ||
root: true, | ||
env: { browser: true, es2020: true }, | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:@typescript-eslint/recommended', | ||
'plugin:react-hooks/recommended', | ||
], | ||
ignorePatterns: ['dist', '.eslintrc.cjs'], | ||
parser: '@typescript-eslint/parser', | ||
plugins: ['react-refresh'], | ||
rules: { | ||
'react-refresh/only-export-components': [ | ||
'warn', | ||
{ allowConstantExport: true }, | ||
], | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# React + TypeScript + Vite | ||
|
||
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. | ||
|
||
Currently, two official plugins are available: | ||
|
||
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh | ||
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh | ||
|
||
## Expanding the ESLint configuration | ||
|
||
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules: | ||
|
||
- Configure the top-level `parserOptions` property like this: | ||
|
||
```js | ||
parserOptions: { | ||
ecmaVersion: 'latest', | ||
sourceType: 'module', | ||
project: ['./tsconfig.json', './tsconfig.node.json'], | ||
tsconfigRootDir: __dirname, | ||
}, | ||
``` | ||
|
||
- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked` | ||
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked` | ||
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Vite + React + TS</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/main.tsx"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"name": "frontend", | ||
"private": true, | ||
"version": "0.0.0", | ||
"type": "module", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "tsc && vite build", | ||
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", | ||
"preview": "vite preview" | ||
}, | ||
"dependencies": { | ||
"@auth0/auth0-react": "^2.2.3", | ||
"@emotion/react": "^11.11.1", | ||
"@emotion/styled": "^11.11.0", | ||
"@fontsource/inter": "^5.0.15", | ||
"@mui/icons-material": "^5.14.16", | ||
"@mui/joy": "^5.0.0-beta.14", | ||
"@mui/material": "^5.14.17", | ||
"@tanstack/react-router": "^0.0.1-beta.209", | ||
"@tanstack/router-devtools": "^0.0.1-alpha.0", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0" | ||
}, | ||
"devDependencies": { | ||
"@types/react": "^18.2.15", | ||
"@types/react-dom": "^18.2.7", | ||
"@typescript-eslint/eslint-plugin": "^6.0.0", | ||
"@typescript-eslint/parser": "^6.0.0", | ||
"@vitejs/plugin-react": "^4.0.3", | ||
"eslint": "^8.45.0", | ||
"eslint-plugin-react-hooks": "^4.6.0", | ||
"eslint-plugin-react-refresh": "^0.4.3", | ||
"prettier": "^3.0.3", | ||
"typescript": "^5.0.2", | ||
"vite": "^4.4.5" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import "./App.css"; | ||
import { useAuth0, withAuthenticationRequired } from "@auth0/auth0-react"; | ||
import Sidebar from "./components/Sidebar.tsx"; | ||
import Box from "@mui/joy/Box"; | ||
import { | ||
Outlet, | ||
RootRoute, | ||
Route, | ||
Router, | ||
RouterProvider, | ||
} from "@tanstack/react-router"; | ||
import { Home } from "./routes"; | ||
import { Projects } from "./routes/Projects.tsx"; | ||
import { Agents, AllHosts, Deploy, Groups } from "./routes/hosts"; | ||
|
||
const rootRoute = new RootRoute({ | ||
component: withAuthenticationRequired(Root), | ||
}); | ||
|
||
const homeRoute = new Route({ | ||
getParentRoute: () => rootRoute, | ||
component: Home, | ||
path: "/", | ||
}); | ||
|
||
const projectsRoute = new Route({ | ||
getParentRoute: () => rootRoute, | ||
component: Projects, | ||
path: "/projects", | ||
}); | ||
|
||
const hostsRoute = new Route({ | ||
getParentRoute: () => rootRoute, | ||
path: "/hosts", | ||
}); | ||
|
||
const hostsAllRoute = new Route({ | ||
getParentRoute: () => hostsRoute, | ||
path: "/", | ||
component: AllHosts, | ||
}); | ||
|
||
const hostsGroupsRoute = new Route({ | ||
getParentRoute: () => hostsRoute, | ||
path: "/groups", | ||
component: Groups, | ||
}); | ||
|
||
const hostsAgentsRoute = new Route({ | ||
getParentRoute: () => hostsRoute, | ||
path: "/agents", | ||
component: Agents, | ||
}); | ||
|
||
const hostsDeployRoute = new Route({ | ||
getParentRoute: () => hostsRoute, | ||
path: "/deploy", | ||
component: Deploy, | ||
}); | ||
|
||
const settingsRoute = new Route({ | ||
getParentRoute: () => rootRoute, | ||
path: "/settings", | ||
component: () => <p>Settings route</p>, | ||
}); | ||
|
||
const routeTree = rootRoute.addChildren([ | ||
homeRoute, | ||
projectsRoute, | ||
hostsRoute, | ||
hostsAllRoute, | ||
hostsGroupsRoute, | ||
hostsAgentsRoute, | ||
hostsDeployRoute, | ||
settingsRoute, | ||
]); | ||
const router = new Router({ routeTree }); | ||
|
||
declare module "@tanstack/react-router" { | ||
interface Register { | ||
router: typeof router; | ||
} | ||
} | ||
|
||
function Root() { | ||
return ( | ||
<Box sx={{ display: "flex", minHeight: "100dvh" }}> | ||
<Sidebar /> | ||
<Outlet /> | ||
</Box> | ||
); | ||
} | ||
|
||
function App() { | ||
const auth0 = useAuth0(); | ||
return <RouterProvider router={router} context={{ auth0 }} />; | ||
} | ||
|
||
export default App; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import DarkModeRoundedIcon from "@mui/icons-material/DarkModeRounded"; | ||
import LightModeIcon from "@mui/icons-material/LightMode"; | ||
import { IconButtonProps, useColorScheme } from "@mui/joy"; | ||
import { useEffect, useState } from "react"; | ||
import IconButton from "@mui/joy/IconButton"; | ||
|
||
export default function ColorSchemeToggle({ | ||
onClick, | ||
sx, | ||
...props | ||
}: IconButtonProps) { | ||
const { mode, setMode } = useColorScheme(); | ||
const [mounted, setMounted] = useState(false); | ||
useEffect(() => { | ||
setMounted(true); | ||
}, []); | ||
if (!mounted) { | ||
return ( | ||
<IconButton | ||
size="sm" | ||
variant="outlined" | ||
color="neutral" | ||
{...props} | ||
sx={sx} | ||
disabled | ||
/> | ||
); | ||
} | ||
return ( | ||
<IconButton | ||
id="toggle-mode" | ||
size="sm" | ||
variant="outlined" | ||
color="neutral" | ||
{...props} | ||
onClick={(event) => { | ||
if (mode === "light") { | ||
setMode("dark"); | ||
} else { | ||
setMode("light"); | ||
} | ||
onClick?.(event); | ||
}} | ||
sx={[ | ||
{ | ||
"& > *:first-child": { | ||
display: mode === "dark" ? "none" : "initial", | ||
}, | ||
"& > *:last-child": { | ||
display: mode === "light" ? "none" : "initial", | ||
}, | ||
}, | ||
...(Array.isArray(sx) ? sx : [sx]), | ||
]} | ||
> | ||
<DarkModeRoundedIcon /> | ||
<LightModeIcon /> | ||
</IconButton> | ||
); | ||
} |
Oops, something went wrong.