@osdk/create-app 0.17.0-main-20240530094422 → 0.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/CHANGELOG.md +60 -1
  2. package/build/browser/esm-5B4R5BF5.js +248 -0
  3. package/build/browser/esm-5B4R5BF5.js.map +1 -0
  4. package/build/browser/esm-7ZL7DCMH.js +451 -0
  5. package/build/browser/esm-7ZL7DCMH.js.map +1 -0
  6. package/build/browser/esm-WPXIOIG2.js +1170 -0
  7. package/build/browser/esm-WPXIOIG2.js.map +1 -0
  8. package/build/browser/esm-ZCTE2SEE.js +377 -0
  9. package/build/browser/esm-ZCTE2SEE.js.map +1 -0
  10. package/build/browser/esm-ZDRBH2ME.js +901 -0
  11. package/build/browser/esm-ZDRBH2ME.js.map +1 -0
  12. package/build/browser/index.js +26 -19
  13. package/build/browser/index.js.map +1 -1
  14. package/build/cjs/esm-2ZIGIHPI.cjs +379 -0
  15. package/build/cjs/esm-2ZIGIHPI.cjs.map +1 -0
  16. package/build/cjs/esm-JBGUEJ46.cjs +250 -0
  17. package/build/cjs/esm-JBGUEJ46.cjs.map +1 -0
  18. package/build/cjs/esm-RRFVZF4X.cjs +1172 -0
  19. package/build/cjs/esm-RRFVZF4X.cjs.map +1 -0
  20. package/build/cjs/esm-VSENADXB.cjs +903 -0
  21. package/build/cjs/esm-VSENADXB.cjs.map +1 -0
  22. package/build/cjs/esm-YRGJOBTV.cjs +453 -0
  23. package/build/cjs/esm-YRGJOBTV.cjs.map +1 -0
  24. package/build/cjs/index.cjs +26 -20
  25. package/build/cjs/index.cjs.map +1 -1
  26. package/build/esm/esm-5B4R5BF5.js +248 -0
  27. package/build/esm/esm-5B4R5BF5.js.map +1 -0
  28. package/build/esm/esm-7ZL7DCMH.js +451 -0
  29. package/build/esm/esm-7ZL7DCMH.js.map +1 -0
  30. package/build/esm/esm-WPXIOIG2.js +1170 -0
  31. package/build/esm/esm-WPXIOIG2.js.map +1 -0
  32. package/build/esm/esm-ZCTE2SEE.js +377 -0
  33. package/build/esm/esm-ZCTE2SEE.js.map +1 -0
  34. package/build/esm/esm-ZDRBH2ME.js +901 -0
  35. package/build/esm/esm-ZDRBH2ME.js.map +1 -0
  36. package/build/esm/index.js +26 -19
  37. package/build/esm/index.js.map +1 -1
  38. package/build/esm/run.d.ts.map +1 -1
  39. package/build/esm/templates.d.ts +7 -0
  40. package/build/esm/templates.d.ts.map +1 -1
  41. package/package.json +18 -9
  42. package/templates/template-next-static-export/.eslintrc.json +0 -4
  43. package/templates/template-next-static-export/README.md.hbs +0 -35
  44. package/templates/template-next-static-export/_gitignore +0 -36
  45. package/templates/template-next-static-export/next.config.js.hbs +0 -17
  46. package/templates/template-next-static-export/package.json.hbs +0 -25
  47. package/templates/template-next-static-export/public/next.svg +0 -20
  48. package/templates/template-next-static-export/public/palantir.svg +0 -3
  49. package/templates/template-next-static-export/src/app/auth/callback/page.tsx +0 -25
  50. package/templates/template-next-static-export/src/app/globals.css +0 -81
  51. package/templates/template-next-static-export/src/app/icon.svg +0 -20
  52. package/templates/template-next-static-export/src/app/layout.module.css +0 -11
  53. package/templates/template-next-static-export/src/app/layout.tsx +0 -51
  54. package/templates/template-next-static-export/src/app/login/page.tsx +0 -43
  55. package/templates/template-next-static-export/src/app/page.module.css +0 -7
  56. package/templates/template-next-static-export/src/app/page.tsx.hbs +0 -53
  57. package/templates/template-next-static-export/src/lib/client.ts.hbs +0 -31
  58. package/templates/template-next-static-export/src/lib/useAuthenticated.ts +0 -25
  59. package/templates/template-next-static-export/tsconfig.json +0 -27
  60. package/templates/template-react/.eslintrc.cjs +0 -18
  61. package/templates/template-react/README.md.hbs +0 -35
  62. package/templates/template-react/_gitignore +0 -24
  63. package/templates/template-react/index.html +0 -15
  64. package/templates/template-react/package.json.hbs +0 -30
  65. package/templates/template-react/public/palantir.svg +0 -3
  66. package/templates/template-react/public/react.svg +0 -1
  67. package/templates/template-react/src/AuthCallback.tsx +0 -24
  68. package/templates/template-react/src/AuthenticatedRoute.tsx +0 -33
  69. package/templates/template-react/src/Home.module.css +0 -7
  70. package/templates/template-react/src/Home.tsx.hbs +0 -47
  71. package/templates/template-react/src/Layout.module.css +0 -10
  72. package/templates/template-react/src/Layout.tsx +0 -29
  73. package/templates/template-react/src/Login.tsx +0 -40
  74. package/templates/template-react/src/client.ts.hbs +0 -31
  75. package/templates/template-react/src/index.css +0 -81
  76. package/templates/template-react/src/main.tsx +0 -33
  77. package/templates/template-react/src/vite-env.d.ts +0 -1
  78. package/templates/template-react/tsconfig.json +0 -25
  79. package/templates/template-react/tsconfig.node.json +0 -10
  80. package/templates/template-react/vite.config.ts.hbs +0 -19
  81. package/templates/template-tutorial-todo-app/.eslintrc.cjs +0 -18
  82. package/templates/template-tutorial-todo-app/README.md.hbs +0 -33
  83. package/templates/template-tutorial-todo-app/index.html +0 -15
  84. package/templates/template-tutorial-todo-app/package.json.hbs +0 -31
  85. package/templates/template-tutorial-todo-app/public/todo-app.svg +0 -4
  86. package/templates/template-tutorial-todo-app/src/AuthCallback.tsx +0 -24
  87. package/templates/template-tutorial-todo-app/src/AuthenticatedRoute.tsx +0 -33
  88. package/templates/template-tutorial-todo-app/src/CreateProjectButton.tsx +0 -33
  89. package/templates/template-tutorial-todo-app/src/CreateProjectDialog.tsx +0 -56
  90. package/templates/template-tutorial-todo-app/src/CreateTaskButton.tsx +0 -35
  91. package/templates/template-tutorial-todo-app/src/CreateTaskDialog.tsx +0 -52
  92. package/templates/template-tutorial-todo-app/src/DeleteProjectButton.tsx +0 -34
  93. package/templates/template-tutorial-todo-app/src/DeleteProjectDialog.tsx +0 -46
  94. package/templates/template-tutorial-todo-app/src/Dialog.module.css +0 -5
  95. package/templates/template-tutorial-todo-app/src/Dialog.tsx +0 -19
  96. package/templates/template-tutorial-todo-app/src/Home.module.css +0 -35
  97. package/templates/template-tutorial-todo-app/src/Home.tsx +0 -62
  98. package/templates/template-tutorial-todo-app/src/Layout.module.css +0 -16
  99. package/templates/template-tutorial-todo-app/src/Layout.tsx +0 -21
  100. package/templates/template-tutorial-todo-app/src/Login.module.css +0 -5
  101. package/templates/template-tutorial-todo-app/src/Login.tsx +0 -42
  102. package/templates/template-tutorial-todo-app/src/ProjectSelect.tsx +0 -40
  103. package/templates/template-tutorial-todo-app/src/TaskList.module.css +0 -6
  104. package/templates/template-tutorial-todo-app/src/TaskList.tsx +0 -38
  105. package/templates/template-tutorial-todo-app/src/TaskListItem.module.css +0 -3
  106. package/templates/template-tutorial-todo-app/src/TaskListItem.tsx +0 -37
  107. package/templates/template-tutorial-todo-app/src/client.ts.hbs +0 -31
  108. package/templates/template-tutorial-todo-app/src/index.css +0 -80
  109. package/templates/template-tutorial-todo-app/src/main.tsx +0 -33
  110. package/templates/template-tutorial-todo-app/src/mocks.ts +0 -137
  111. package/templates/template-tutorial-todo-app/src/useProjectTasks.ts +0 -55
  112. package/templates/template-tutorial-todo-app/src/useProjects.ts +0 -43
  113. package/templates/template-tutorial-todo-app/src/vite-env.d.ts +0 -1
  114. package/templates/template-tutorial-todo-app/tsconfig.json +0 -25
  115. package/templates/template-tutorial-todo-app/tsconfig.node.json +0 -10
  116. package/templates/template-tutorial-todo-app/vite.config.ts.hbs +0 -19
  117. package/templates/template-vue/.vscode/extensions.json +0 -3
  118. package/templates/template-vue/README.md.hbs +0 -35
  119. package/templates/template-vue/_gitignore +0 -24
  120. package/templates/template-vue/index.html +0 -15
  121. package/templates/template-vue/package.json.hbs +0 -22
  122. package/templates/template-vue/public/palantir.svg +0 -3
  123. package/templates/template-vue/public/vue.svg +0 -1
  124. package/templates/template-vue/src/AuthCallback.vue +0 -22
  125. package/templates/template-vue/src/Home.vue.hbs +0 -38
  126. package/templates/template-vue/src/Layout.vue +0 -26
  127. package/templates/template-vue/src/Login.vue +0 -36
  128. package/templates/template-vue/src/client.ts.hbs +0 -31
  129. package/templates/template-vue/src/main.ts +0 -35
  130. package/templates/template-vue/src/style.css +0 -81
  131. package/templates/template-vue/src/vite-env.d.ts +0 -1
  132. package/templates/template-vue/tsconfig.json +0 -25
  133. package/templates/template-vue/tsconfig.node.json +0 -10
  134. package/templates/template-vue/vite.config.ts.hbs +0 -24
@@ -1,47 +0,0 @@
1
- import client from "./client";
2
- import css from "./Home.module.css";
3
- import Layout from "./Layout";
4
-
5
- function Home() {
6
- const objectApiNames = Object.keys(client.ontology.objects);
7
- const actionApiNames = Object.keys(client.ontology.actions);
8
- const queryApiNames = Object.keys(client.ontology.queries);
9
-
10
- return (
11
- <Layout>
12
- <h1>{{osdkPackage}}</h1>
13
- <p>
14
- Welcome to your Ontology SDK! Try using any of the following methods
15
- now.
16
- </p>
17
- <div className={css.methods}>
18
- <div>
19
- <h2>Objects ({objectApiNames.length})</h2>
20
- {objectApiNames.map((objectApiName) => (
21
- <pre key={objectApiName}>
22
- client.ontology.objects.{objectApiName}
23
- </pre>
24
- ))}
25
- </div>
26
- <div>
27
- <h2>Actions ({actionApiNames.length})</h2>
28
- {actionApiNames.map((actionApiName) => (
29
- <pre key={actionApiName}>
30
- client.ontology.actions.{actionApiName}
31
- </pre>
32
- ))}
33
- </div>
34
- <div>
35
- <h2>Queries ({queryApiNames.length})</h2>
36
- {queryApiNames.map((queryApiName) => (
37
- <pre key={queryApiName}>
38
- client.ontology.queries.{queryApiName}
39
- </pre>
40
- ))}
41
- </div>
42
- </div>
43
- </Layout>
44
- );
45
- }
46
-
47
- export default Home;
@@ -1,10 +0,0 @@
1
- .logo {
2
- height: 6em;
3
- padding: 1.5em;
4
- will-change: filter;
5
- transition: filter 300ms;
6
- }
7
-
8
- .logo:hover {
9
- filter: drop-shadow(0 0 2em #646cffaa);
10
- }
@@ -1,29 +0,0 @@
1
- import palantirLogo from "/palantir.svg";
2
- import reactLogo from "/react.svg";
3
- import React from "react";
4
- import css from "./Layout.module.css";
5
-
6
- interface LayoutProps {
7
- children?: React.ReactNode;
8
- }
9
-
10
- function Layout({ children }: LayoutProps) {
11
- return (
12
- <>
13
- <div>
14
- <a
15
- href="https://www.palantir.com/docs/foundry/ontology-sdk/overview/"
16
- target="_blank"
17
- >
18
- <img src={palantirLogo} className={css.logo} alt="Palantir logo" />
19
- </a>
20
- <a href="https://react.dev" target="_blank">
21
- <img src={reactLogo} className={css.logo} alt="React logo" />
22
- </a>
23
- </div>
24
- {children}
25
- </>
26
- );
27
- }
28
-
29
- export default Layout;
@@ -1,40 +0,0 @@
1
- import { useCallback, useState } from "react";
2
- import { Navigate } from "react-router-dom";
3
- import client from "./client";
4
- import Layout from "./Layout";
5
-
6
- function Login() {
7
- const [isLoggingIn, setIsLoggingIn] = useState(false);
8
- const [error, setError] = useState<string | undefined>(undefined);
9
- const token = client.auth.token;
10
-
11
- const handleLogin = useCallback(async () => {
12
- setIsLoggingIn(true);
13
- try {
14
- // Initiate the OAuth flow, which will redirect the user to log into Foundry
15
- // Once the login has completed, the user will be redirected back to the route defined via the
16
- // FOUNDRY_REDIRECT_URL variable in .env.development
17
- await client.auth.signIn();
18
- } catch (e: unknown) {
19
- console.error(e);
20
- setError((e as Error).message ?? e);
21
- }
22
- }, []);
23
-
24
- // If the token exists but a user tries to load /login, redirect to the home page instead
25
- if (token != null) {
26
- return <Navigate to="/" replace={true} />;
27
- }
28
-
29
- return (
30
- <Layout>
31
- <h1>Ontology SDK</h1>
32
- <button onClick={handleLogin}>
33
- {isLoggingIn ? "Logging in…" : "Log in "}
34
- </button>
35
- {error && <div>Unable to log in: {error}</div>}
36
- </Layout>
37
- );
38
- }
39
-
40
- export default Login;
@@ -1,31 +0,0 @@
1
- import { FoundryClient, PublicClientAuth } from "{{osdkPackage}}";
2
-
3
- const url = import.meta.env.VITE_FOUNDRY_API_URL;
4
- const clientId = import.meta.env.VITE_FOUNDRY_CLIENT_ID;
5
- const redirectUrl = import.meta.env.VITE_FOUNDRY_REDIRECT_URL;
6
- checkEnv(url, "VITE_FOUNDRY_API_URL");
7
- checkEnv(clientId, "VITE_FOUNDRY_CLIENT_ID");
8
- checkEnv(redirectUrl, "VITE_FOUNDRY_REDIRECT_URL");
9
-
10
- function checkEnv(
11
- value: string | undefined,
12
- name: string,
13
- ): asserts value is string {
14
- if (value == null) {
15
- throw new Error(`Missing environment variable: ${name}`);
16
- }
17
- }
18
-
19
- /**
20
- * Initialize the client to interact with the Ontology SDK
21
- */
22
- const client = new FoundryClient({
23
- url,
24
- auth: new PublicClientAuth({
25
- clientId,
26
- url,
27
- redirectUrl,
28
- }),
29
- });
30
-
31
- export default client;
@@ -1,81 +0,0 @@
1
- :root {
2
- font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
3
- line-height: 1.5;
4
- font-weight: 400;
5
-
6
- color-scheme: light dark;
7
- color: rgba(255, 255, 255, 0.87);
8
- background-color: #242424;
9
-
10
- font-synthesis: none;
11
- text-rendering: optimizeLegibility;
12
- -webkit-font-smoothing: antialiased;
13
- -moz-osx-font-smoothing: grayscale;
14
- }
15
-
16
- #root-container {
17
- display: flex;
18
- flex: 1;
19
- align-items: center;
20
- }
21
-
22
- #root {
23
- max-width: 1280px;
24
- margin: 0 auto;
25
- padding: 2rem;
26
- text-align: center;
27
- }
28
-
29
- a {
30
- font-weight: 500;
31
- color: #646cff;
32
- text-decoration: inherit;
33
- }
34
- a:hover {
35
- color: #535bf2;
36
- }
37
-
38
- body {
39
- margin: 0;
40
- display: flex;
41
- flex-direction: column;
42
- min-width: 320px;
43
- min-height: 100vh;
44
- }
45
-
46
- h1 {
47
- font-size: 3.2em;
48
- line-height: 1.1;
49
- }
50
-
51
- button {
52
- border-radius: 8px;
53
- border: 1px solid transparent;
54
- padding: 0.6em 1.2em;
55
- font-size: 1em;
56
- font-weight: 500;
57
- font-family: inherit;
58
- background-color: #1a1a1a;
59
- cursor: pointer;
60
- transition: border-color 0.25s;
61
- }
62
- button:hover {
63
- border-color: #646cff;
64
- }
65
- button:focus,
66
- button:focus-visible {
67
- outline: 4px auto -webkit-focus-ring-color;
68
- }
69
-
70
- @media (prefers-color-scheme: light) {
71
- :root {
72
- color: #213547;
73
- background-color: #ffffff;
74
- }
75
- a:hover {
76
- color: #747bff;
77
- }
78
- button {
79
- background-color: #f9f9f9;
80
- }
81
- }
@@ -1,33 +0,0 @@
1
- import ReactDOM from "react-dom/client";
2
- import { createBrowserRouter, RouterProvider } from "react-router-dom";
3
- import AuthCallback from "./AuthCallback";
4
- import AuthenticatedRoute from "./AuthenticatedRoute";
5
- import Home from "./Home";
6
- import Login from "./Login";
7
- import "./index.css";
8
-
9
- const router = createBrowserRouter([
10
- {
11
- path: "/",
12
- element: <AuthenticatedRoute />,
13
- children: [
14
- {
15
- path: "/",
16
- element: <Home />,
17
- },
18
- ],
19
- },
20
- {
21
- path: "/login",
22
- element: <Login />,
23
- },
24
- {
25
- // This is the route defined in your application's redirect URL
26
- path: "/auth/callback",
27
- element: <AuthCallback />,
28
- },
29
- ]);
30
-
31
- ReactDOM.createRoot(document.getElementById("root")!).render(
32
- <RouterProvider router={router} />,
33
- );
@@ -1 +0,0 @@
1
- /// <reference types="vite/client" />
@@ -1,25 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2020",
4
- "useDefineForClassFields": true,
5
- "lib": ["ES2020", "DOM", "DOM.Iterable"],
6
- "module": "ESNext",
7
- "skipLibCheck": true,
8
-
9
- /* Bundler mode */
10
- "moduleResolution": "bundler",
11
- "allowImportingTsExtensions": true,
12
- "resolveJsonModule": true,
13
- "isolatedModules": true,
14
- "noEmit": true,
15
- "jsx": "react-jsx",
16
-
17
- /* Linting */
18
- "strict": true,
19
- "noUnusedLocals": true,
20
- "noUnusedParameters": true,
21
- "noFallthroughCasesInSwitch": true
22
- },
23
- "include": ["src"],
24
- "references": [{ "path": "./tsconfig.node.json" }]
25
- }
@@ -1,10 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "composite": true,
4
- "skipLibCheck": true,
5
- "module": "ESNext",
6
- "moduleResolution": "bundler",
7
- "allowSyntheticDefaultImports": true
8
- },
9
- "include": ["vite.config.ts"]
10
- }
@@ -1,19 +0,0 @@
1
- import react from "@vitejs/plugin-react";
2
- import { defineConfig } from "vite";
3
-
4
- // https://vitejs.dev/config/
5
- export default defineConfig({
6
- plugins: [react()],
7
- server: {
8
- port: 8080,
9
- {{#if corsProxy}}
10
- proxy: {
11
- "^(/multipass/api|/api)": {
12
- target: "{{foundryUrl}}",
13
- changeOrigin: true,
14
- secure: true,
15
- },
16
- },
17
- {{/if}}
18
- },
19
- });
@@ -1,18 +0,0 @@
1
- module.exports = {
2
- root: true,
3
- env: { browser: true, es2020: true },
4
- extends: [
5
- "eslint:recommended",
6
- "plugin:@typescript-eslint/recommended",
7
- "plugin:react-hooks/recommended",
8
- ],
9
- ignorePatterns: ["dist", ".eslintrc.cjs"],
10
- parser: "@typescript-eslint/parser",
11
- plugins: ["react-refresh"],
12
- rules: {
13
- "react-refresh/only-export-components": [
14
- "warn",
15
- { allowConstantExport: true },
16
- ],
17
- },
18
- };
@@ -1,33 +0,0 @@
1
- # {{project}}
2
-
3
- This project was generated with `@osdk/create-app` and is intended to be used alongside the Developer Console tutorial for creating a Todo App against a reference Ontology.
4
-
5
- ## Developing
6
-
7
- Run the following command or equivalent with your preferred package manager to start a local development server on `http://localhost:8080`:
8
-
9
- ```sh
10
- npm run dev
11
- ```
12
-
13
- Development configuration is stored in `.env.development`.
14
-
15
- {{#if corsProxy}}
16
- In order to make API requests to Foundry, a CORS proxy has been set up for local development which may be removed if the stack is configured to allow `http://localhost:8080` to load resources. The configured OAuth client must also allow `http://localhost:8080/auth/callback` as a redirect URL.
17
- {{else}}
18
- In order to make API requests to Foundry, CORS must be configured for the stack to allow `http://localhost:8080` to load resources. The configured OAuth client must also allow `http://localhost:8080/auth/callback` as a redirect URL.
19
- {{/if}}
20
-
21
- ## Deploying
22
-
23
- Run the following command or equivalent with your preferred package manager to create a production build of your application:
24
-
25
- ```sh
26
- npm run build
27
- ```
28
-
29
- Production configuration is stored in `.env.production`.
30
-
31
- If you did not fill in the URL your production application will be hosted on you will need to fill in the `VITE_FOUNDRY_REDIRECT_URL` in `.env.production`.
32
-
33
- In order to make API requests to Foundry, CORS must be configured for the stack to allow the production origin to load resources. The configured OAuth client must also allow the production origin auth callback as a redirect URL.
@@ -1,15 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <link rel="icon" type="image/svg+xml" href="/todo-app.svg" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
- <title>Ontology SDK Tutorial - Todo App</title>
8
- </head>
9
- <body>
10
- <div id="root-container">
11
- <div id="root"></div>
12
- </div>
13
- <script type="module" src="/src/main.tsx"></script>
14
- </body>
15
- </html>
@@ -1,31 +0,0 @@
1
- {
2
- "name": "{{project}}",
3
- "private": true,
4
- "version": "0.0.0",
5
- "type": "module",
6
- "scripts": {
7
- "dev": "vite",
8
- "build": "tsc && vite build",
9
- "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
10
- "preview": "vite preview"
11
- },
12
- "dependencies": {
13
- "{{osdkPackage}}": "latest",
14
- "react": "^18",
15
- "react-dom": "^18",
16
- "react-router-dom": "^6.23.1",
17
- "swr": "^2.2.5"
18
- },
19
- "devDependencies": {
20
- "@types/react": "^18",
21
- "@types/react-dom": "^18",
22
- "@typescript-eslint/eslint-plugin": "^7.8.0",
23
- "@typescript-eslint/parser": "^7.8.0",
24
- "@vitejs/plugin-react": "^4.2.0",
25
- "eslint": "^8.57.0",
26
- "eslint-plugin-react-hooks": "^4.6.2",
27
- "eslint-plugin-react-refresh": "^0.4.6",
28
- "typescript": "^5.2.2",
29
- "vite": "^5.2.11"
30
- }
31
- }
@@ -1,4 +0,0 @@
1
- <svg width="128" height="128" viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg">
2
- <rect width="128" height="128" rx="16" fill="#FBB360"/>
3
- <path fill-rule="evenodd" clip-rule="evenodd" d="M28 82V94H40V82H28ZM22 70H46C49.3 70 52 72.7 52 76V100C52 103.3 49.3 106 46 106H22C18.7 106 16 103.3 16 100V76C16 72.7 18.7 70 22 70ZM76 34H106C109.3 34 112 36.7 112 40C112 43.3 109.3 46 106 46H76C72.7 46 70 43.3 70 40C70 36.7 72.7 34 76 34ZM52 22C55.3 22 58 24.7 58 28C58 29.68 57.34 31.18 56.26 32.26L38.26 56.26C37.18 57.34 35.68 58 34 58C32.32 58 30.82 57.34 29.74 56.26L17.74 44.26C16.66 43.18 16 41.68 16 40C16 36.7 18.7 34 22 34C23.68 34 25.18 34.66 26.26 35.74L34 43.54L47.74 23.74C48.82 22.66 50.32 22 52 22ZM76 82H106C109.3 82 112 84.7 112 88C112 91.3 109.3 94 106 94H76C72.7 94 70 91.3 70 88C70 84.7 72.7 82 76 82Z" fill="#77450D"/>
4
- </svg>
@@ -1,24 +0,0 @@
1
- import { useEffect, useState } from "react";
2
- import { useNavigate } from "react-router-dom";
3
- import client from "./client";
4
-
5
- /**
6
- * Component to render at `/auth/callback`
7
- * This calls signIn() again to save the token, and then navigates the user back to the home page.
8
- */
9
- function AuthCallback() {
10
- const [error, setError] = useState<string | undefined>(undefined);
11
- const navigate = useNavigate();
12
-
13
- // This effect conflicts with React 18 strict mode in development
14
- // https://react.dev/learn/synchronizing-with-effects#how-to-handle-the-effect-firing-twice-in-development
15
- useEffect(() => {
16
- client.auth
17
- .signIn()
18
- .then(() => navigate("/", { replace: true }))
19
- .catch((e: unknown) => setError((e as Error).message ?? e));
20
- }, [navigate]);
21
- return <div>{error != null ? error : "Authenticating…"}</div>;
22
- }
23
-
24
- export default AuthCallback;
@@ -1,33 +0,0 @@
1
- import { useEffect, useState } from "react";
2
- import { Outlet, useNavigate } from "react-router-dom";
3
- import client from "./client";
4
-
5
- /**
6
- * A component that can be used to wrap routes that require authentication.
7
- * Nested routes may assume that a valid token is present.
8
- */
9
- function AuthenticatedRoute() {
10
- const navigate = useNavigate();
11
- const [token, setToken] = useState(client.auth.token);
12
- useEffect(() => {
13
- if (client.auth.token == null || client.auth.token.isExpired) {
14
- client.auth
15
- .refresh()
16
- .then(() => {
17
- setToken(client.auth.token);
18
- })
19
- .catch(() => {
20
- // If we cannot refresh the token (i.e. the user is not logged in) we redirect to the login page
21
- navigate("/login");
22
- });
23
- }
24
- }, [navigate]);
25
-
26
- if (token == null || token.isExpired) {
27
- return null;
28
- }
29
-
30
- return <Outlet />;
31
- }
32
-
33
- export default AuthenticatedRoute;
@@ -1,33 +0,0 @@
1
- import { useCallback, useState } from "react";
2
- import CreateProjectDialog from "./CreateProjectDialog";
3
- import useProjects from "./useProjects";
4
-
5
- interface CreateProjectButtonProps {
6
- onProjectCreated?: (projectId: string) => void;
7
- }
8
-
9
- function CreateProjectButton({ onProjectCreated }: CreateProjectButtonProps) {
10
- const { isLoading: isLoadingProjects, isError: isErrorProjects } =
11
- useProjects();
12
-
13
- const [isOpen, setIsOpen] = useState(false);
14
- const handleOpen = useCallback(() => setIsOpen(true), []);
15
- const handleClose = useCallback(() => setIsOpen(false), []);
16
-
17
- if (isLoadingProjects || isErrorProjects) {
18
- return null;
19
- }
20
-
21
- return (
22
- <>
23
- <button onClick={handleOpen}>Create Project</button>
24
- <CreateProjectDialog
25
- isOpen={isOpen}
26
- onClose={handleClose}
27
- onProjectCreated={onProjectCreated}
28
- />
29
- </>
30
- );
31
- }
32
-
33
- export default CreateProjectButton;
@@ -1,56 +0,0 @@
1
- import { ChangeEvent, useCallback, useEffect, useState } from "react";
2
- import Dialog from "./Dialog";
3
- import useProjects from "./useProjects";
4
-
5
- interface CreateProjectDialogProps {
6
- isOpen: boolean;
7
- onClose: () => void;
8
- onProjectCreated?: (projectId: string) => void;
9
- }
10
-
11
- function CreateProjectDialog({
12
- isOpen,
13
- onClose,
14
- onProjectCreated,
15
- }: CreateProjectDialogProps) {
16
- const { createProject } = useProjects();
17
-
18
- const [name, setName] = useState<string>("New project");
19
- const handleChange = useCallback(
20
- (e: ChangeEvent<HTMLInputElement>) => setName(e.target.value),
21
- [],
22
- );
23
-
24
- useEffect(() => setName("New project"), [isOpen]);
25
-
26
- const [isCreating, setIsCreating] = useState(false);
27
- const handleSubmit = useCallback(async () => {
28
- setIsCreating(true);
29
- try {
30
- const projectId = await createProject(name);
31
- onProjectCreated?.(projectId);
32
- } finally {
33
- setIsCreating(false);
34
- onClose();
35
- }
36
- }, [onProjectCreated, onClose, createProject, name]);
37
-
38
- return (
39
- <Dialog
40
- isOpen={isOpen}
41
- buttons={[
42
- <button disabled={isCreating} onClick={handleSubmit}>
43
- Create project
44
- </button>,
45
- <button disabled={isCreating} onClick={onClose}>
46
- Cancel
47
- </button>,
48
- ]}
49
- >
50
- <label>
51
- Project name: <input type="text" value={name} onChange={handleChange} />
52
- </label>
53
- </Dialog>
54
- );
55
- }
56
- export default CreateProjectDialog;
@@ -1,35 +0,0 @@
1
- import { useCallback, useState } from "react";
2
- import CreateTaskDialog from "./CreateTaskDialog";
3
- import { MockProject } from "./mocks";
4
- import { useProjectTasks } from "./useProjectTasks";
5
-
6
- interface CreateTaskButtonProps {
7
- project: MockProject;
8
- }
9
-
10
- function CreateTaskButton({ project }: CreateTaskButtonProps) {
11
- const { isLoading: isLoadingTasks, isError: isErrorTasks } = useProjectTasks(
12
- project,
13
- );
14
-
15
- const [isOpen, setIsOpen] = useState(false);
16
- const handleOpen = useCallback(() => setIsOpen(true), []);
17
- const handleClose = useCallback(() => setIsOpen(false), []);
18
-
19
- if (isLoadingTasks || isErrorTasks) {
20
- return null;
21
- }
22
-
23
- return (
24
- <>
25
- <button onClick={handleOpen}>Create Task</button>
26
- <CreateTaskDialog
27
- project={project}
28
- isOpen={isOpen}
29
- onClose={handleClose}
30
- />
31
- </>
32
- );
33
- }
34
-
35
- export default CreateTaskButton;