@osdk/create-app 0.17.0-beta.3 → 0.17.0-beta.4

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 (147) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/browser/index.js +9 -13
  3. package/build/browser/index.js.map +1 -1
  4. package/build/cjs/index.cjs +9 -14
  5. package/build/cjs/index.cjs.map +1 -1
  6. package/build/esm/index.js +9 -13
  7. package/build/esm/index.js.map +1 -1
  8. package/build/esm/run.d.ts.map +1 -1
  9. package/package.json +15 -6
  10. package/templates/template-next-static-export/.eslintrc.json +0 -4
  11. package/templates/template-next-static-export/README.md.hbs +0 -35
  12. package/templates/template-next-static-export/_gitignore +0 -36
  13. package/templates/template-next-static-export/next.config.js.hbs +0 -17
  14. package/templates/template-next-static-export/package.json.hbs +0 -25
  15. package/templates/template-next-static-export/public/next.svg +0 -20
  16. package/templates/template-next-static-export/public/palantir.svg +0 -3
  17. package/templates/template-next-static-export/src/app/auth/callback/page.tsx +0 -25
  18. package/templates/template-next-static-export/src/app/globals.css +0 -81
  19. package/templates/template-next-static-export/src/app/icon.svg +0 -20
  20. package/templates/template-next-static-export/src/app/layout.module.css +0 -11
  21. package/templates/template-next-static-export/src/app/layout.tsx +0 -51
  22. package/templates/template-next-static-export/src/app/login/page.tsx +0 -45
  23. package/templates/template-next-static-export/src/app/page.module.css +0 -7
  24. package/templates/template-next-static-export/src/app/page.tsx.hbs +0 -53
  25. package/templates/template-next-static-export/src/lib/client.ts.hbs +0 -31
  26. package/templates/template-next-static-export/src/lib/useAuthenticated.ts +0 -25
  27. package/templates/template-next-static-export/tsconfig.json +0 -27
  28. package/templates/template-react/.eslintrc.cjs +0 -18
  29. package/templates/template-react/README.md.hbs +0 -35
  30. package/templates/template-react/_gitignore +0 -24
  31. package/templates/template-react/index.html +0 -15
  32. package/templates/template-react/package.json.hbs +0 -30
  33. package/templates/template-react/public/palantir.svg +0 -3
  34. package/templates/template-react/public/react.svg +0 -1
  35. package/templates/template-react/src/AuthCallback.tsx +0 -24
  36. package/templates/template-react/src/AuthenticatedRoute.tsx +0 -33
  37. package/templates/template-react/src/Home.module.css +0 -7
  38. package/templates/template-react/src/Home.tsx.hbs +0 -47
  39. package/templates/template-react/src/Layout.module.css +0 -10
  40. package/templates/template-react/src/Layout.tsx +0 -29
  41. package/templates/template-react/src/Login.tsx +0 -42
  42. package/templates/template-react/src/client.ts.hbs +0 -31
  43. package/templates/template-react/src/index.css +0 -81
  44. package/templates/template-react/src/main.tsx +0 -36
  45. package/templates/template-react/src/vite-env.d.ts +0 -1
  46. package/templates/template-react/tsconfig.json +0 -25
  47. package/templates/template-react/tsconfig.node.json +0 -10
  48. package/templates/template-react/vite.config.ts.hbs +0 -19
  49. package/templates/template-tutorial-todo-aip-app/.eslintrc.cjs +0 -18
  50. package/templates/template-tutorial-todo-aip-app/README.md.hbs +0 -34
  51. package/templates/template-tutorial-todo-aip-app/index.html +0 -15
  52. package/templates/template-tutorial-todo-aip-app/package.json.hbs +0 -31
  53. package/templates/template-tutorial-todo-aip-app/public/aip-icon.svg +0 -3
  54. package/templates/template-tutorial-todo-aip-app/public/todo-aip-app.svg +0 -19
  55. package/templates/template-tutorial-todo-aip-app/src/AuthCallback.tsx +0 -24
  56. package/templates/template-tutorial-todo-aip-app/src/AuthenticatedRoute.tsx +0 -33
  57. package/templates/template-tutorial-todo-aip-app/src/CreateProjectButton.module.css +0 -3
  58. package/templates/template-tutorial-todo-aip-app/src/CreateProjectButton.tsx +0 -36
  59. package/templates/template-tutorial-todo-aip-app/src/CreateProjectDialog.module.css +0 -15
  60. package/templates/template-tutorial-todo-aip-app/src/CreateProjectDialog.tsx +0 -74
  61. package/templates/template-tutorial-todo-aip-app/src/CreateTaskButton.module.css +0 -3
  62. package/templates/template-tutorial-todo-aip-app/src/CreateTaskButton.tsx +0 -38
  63. package/templates/template-tutorial-todo-aip-app/src/CreateTaskDialog.module.css +0 -66
  64. package/templates/template-tutorial-todo-aip-app/src/CreateTaskDialog.tsx +0 -140
  65. package/templates/template-tutorial-todo-aip-app/src/DeleteProjectButton.module.css +0 -3
  66. package/templates/template-tutorial-todo-aip-app/src/DeleteProjectButton.tsx +0 -37
  67. package/templates/template-tutorial-todo-aip-app/src/DeleteProjectDialog.module.css +0 -3
  68. package/templates/template-tutorial-todo-aip-app/src/DeleteProjectDialog.tsx +0 -57
  69. package/templates/template-tutorial-todo-aip-app/src/Dialog.module.css +0 -11
  70. package/templates/template-tutorial-todo-aip-app/src/Dialog.tsx +0 -19
  71. package/templates/template-tutorial-todo-aip-app/src/Home.module.css +0 -28
  72. package/templates/template-tutorial-todo-aip-app/src/Home.tsx +0 -64
  73. package/templates/template-tutorial-todo-aip-app/src/Layout.module.css +0 -16
  74. package/templates/template-tutorial-todo-aip-app/src/Layout.tsx +0 -23
  75. package/templates/template-tutorial-todo-aip-app/src/Login.module.css +0 -5
  76. package/templates/template-tutorial-todo-aip-app/src/Login.tsx +0 -44
  77. package/templates/template-tutorial-todo-aip-app/src/ProjectDetails.module.css +0 -53
  78. package/templates/template-tutorial-todo-aip-app/src/ProjectDetails.tsx +0 -88
  79. package/templates/template-tutorial-todo-aip-app/src/ProjectSelect.tsx +0 -40
  80. package/templates/template-tutorial-todo-aip-app/src/TaskList.module.css +0 -7
  81. package/templates/template-tutorial-todo-aip-app/src/TaskList.tsx +0 -44
  82. package/templates/template-tutorial-todo-aip-app/src/TaskListItem.module.css +0 -35
  83. package/templates/template-tutorial-todo-aip-app/src/TaskListItem.tsx +0 -58
  84. package/templates/template-tutorial-todo-aip-app/src/client.ts.hbs +0 -31
  85. package/templates/template-tutorial-todo-aip-app/src/index.css +0 -75
  86. package/templates/template-tutorial-todo-aip-app/src/main.tsx +0 -36
  87. package/templates/template-tutorial-todo-aip-app/src/mocks.ts +0 -186
  88. package/templates/template-tutorial-todo-aip-app/src/useProjectTasks.ts +0 -75
  89. package/templates/template-tutorial-todo-aip-app/src/useProjects.ts +0 -57
  90. package/templates/template-tutorial-todo-aip-app/src/vite-env.d.ts +0 -1
  91. package/templates/template-tutorial-todo-aip-app/tsconfig.json +0 -25
  92. package/templates/template-tutorial-todo-aip-app/tsconfig.node.json +0 -10
  93. package/templates/template-tutorial-todo-aip-app/vite.config.ts.hbs +0 -19
  94. package/templates/template-tutorial-todo-app/.eslintrc.cjs +0 -18
  95. package/templates/template-tutorial-todo-app/README.md.hbs +0 -33
  96. package/templates/template-tutorial-todo-app/index.html +0 -15
  97. package/templates/template-tutorial-todo-app/package.json.hbs +0 -31
  98. package/templates/template-tutorial-todo-app/public/todo-app.svg +0 -4
  99. package/templates/template-tutorial-todo-app/src/AuthCallback.tsx +0 -24
  100. package/templates/template-tutorial-todo-app/src/AuthenticatedRoute.tsx +0 -33
  101. package/templates/template-tutorial-todo-app/src/CreateProjectButton.tsx +0 -33
  102. package/templates/template-tutorial-todo-app/src/CreateProjectDialog.tsx +0 -56
  103. package/templates/template-tutorial-todo-app/src/CreateTaskButton.tsx +0 -35
  104. package/templates/template-tutorial-todo-app/src/CreateTaskDialog.tsx +0 -52
  105. package/templates/template-tutorial-todo-app/src/DeleteProjectButton.tsx +0 -34
  106. package/templates/template-tutorial-todo-app/src/DeleteProjectDialog.tsx +0 -46
  107. package/templates/template-tutorial-todo-app/src/Dialog.module.css +0 -10
  108. package/templates/template-tutorial-todo-app/src/Dialog.tsx +0 -19
  109. package/templates/template-tutorial-todo-app/src/Home.module.css +0 -34
  110. package/templates/template-tutorial-todo-app/src/Home.tsx +0 -63
  111. package/templates/template-tutorial-todo-app/src/Layout.module.css +0 -16
  112. package/templates/template-tutorial-todo-app/src/Layout.tsx +0 -21
  113. package/templates/template-tutorial-todo-app/src/Login.module.css +0 -5
  114. package/templates/template-tutorial-todo-app/src/Login.tsx +0 -44
  115. package/templates/template-tutorial-todo-app/src/ProjectSelect.tsx +0 -40
  116. package/templates/template-tutorial-todo-app/src/TaskList.module.css +0 -6
  117. package/templates/template-tutorial-todo-app/src/TaskList.tsx +0 -38
  118. package/templates/template-tutorial-todo-app/src/TaskListItem.module.css +0 -13
  119. package/templates/template-tutorial-todo-app/src/TaskListItem.tsx +0 -40
  120. package/templates/template-tutorial-todo-app/src/client.ts.hbs +0 -31
  121. package/templates/template-tutorial-todo-app/src/index.css +0 -75
  122. package/templates/template-tutorial-todo-app/src/main.tsx +0 -36
  123. package/templates/template-tutorial-todo-app/src/mocks.ts +0 -137
  124. package/templates/template-tutorial-todo-app/src/useProjectTasks.ts +0 -60
  125. package/templates/template-tutorial-todo-app/src/useProjects.ts +0 -43
  126. package/templates/template-tutorial-todo-app/src/vite-env.d.ts +0 -1
  127. package/templates/template-tutorial-todo-app/tsconfig.json +0 -25
  128. package/templates/template-tutorial-todo-app/tsconfig.node.json +0 -10
  129. package/templates/template-tutorial-todo-app/vite.config.ts.hbs +0 -19
  130. package/templates/template-vue/.vscode/extensions.json +0 -3
  131. package/templates/template-vue/README.md.hbs +0 -35
  132. package/templates/template-vue/_gitignore +0 -24
  133. package/templates/template-vue/index.html +0 -15
  134. package/templates/template-vue/package.json.hbs +0 -22
  135. package/templates/template-vue/public/palantir.svg +0 -3
  136. package/templates/template-vue/public/vue.svg +0 -1
  137. package/templates/template-vue/src/AuthCallback.vue +0 -22
  138. package/templates/template-vue/src/Home.vue.hbs +0 -38
  139. package/templates/template-vue/src/Layout.vue +0 -26
  140. package/templates/template-vue/src/Login.vue +0 -36
  141. package/templates/template-vue/src/client.ts.hbs +0 -31
  142. package/templates/template-vue/src/main.ts +0 -35
  143. package/templates/template-vue/src/style.css +0 -81
  144. package/templates/template-vue/src/vite-env.d.ts +0 -1
  145. package/templates/template-vue/tsconfig.json +0 -25
  146. package/templates/template-vue/tsconfig.node.json +0 -10
  147. package/templates/template-vue/vite.config.ts.hbs +0 -24
@@ -1,37 +0,0 @@
1
- import { useCallback, useState } from "react";
2
- import css from "./DeleteProjectButton.module.css";
3
- import DeleteProjectDialog from "./DeleteProjectDialog";
4
- import type { MockProject } from "./mocks";
5
- import useProjects from "./useProjects";
6
-
7
- interface DeleteProjectButtonProps {
8
- project: MockProject;
9
- }
10
-
11
- function DeleteProjectButton({ project }: DeleteProjectButtonProps) {
12
- const { isLoading: isLoadingProjects, isError: isErrorProjects } =
13
- useProjects();
14
-
15
- const [isOpen, setIsOpen] = useState(false);
16
- const handleOpen = useCallback(() => setIsOpen(true), []);
17
- const handleClose = useCallback(() => setIsOpen(false), []);
18
-
19
- if (isLoadingProjects || isErrorProjects) {
20
- return null;
21
- }
22
-
23
- return (
24
- <>
25
- <button onClick={handleOpen} className={css.button}>
26
- Delete Project
27
- </button>
28
- <DeleteProjectDialog
29
- project={project}
30
- isOpen={isOpen}
31
- onClose={handleClose}
32
- />
33
- </>
34
- );
35
- }
36
-
37
- export default DeleteProjectButton;
@@ -1,3 +0,0 @@
1
- .button {
2
- border: 1px solid #ccc;
3
- }
@@ -1,57 +0,0 @@
1
- import { useCallback, useState } from "react";
2
- import css from "./DeleteProjectDialog.module.css";
3
- import Dialog from "./Dialog";
4
- import type { MockProject } from "./mocks";
5
- import useProjects from "./useProjects";
6
-
7
- interface DeleteProjectDialogProps {
8
- project: MockProject;
9
- isOpen: boolean;
10
- onClose: () => void;
11
- }
12
-
13
- function DeleteProjectDialog({
14
- project,
15
- isOpen,
16
- onClose,
17
- }: DeleteProjectDialogProps) {
18
- const { deleteProject } = useProjects();
19
-
20
- const [isDeleting, setIsDeleting] = useState(false);
21
- const handleSubmit = useCallback(async () => {
22
- setIsDeleting(true);
23
- try {
24
- await deleteProject(project);
25
- } finally {
26
- setIsDeleting(false);
27
- onClose();
28
- }
29
- }, [deleteProject, onClose, project]);
30
-
31
- return (
32
- <Dialog
33
- isOpen={isOpen}
34
- buttons={[
35
- <button
36
- disabled={isDeleting}
37
- onClick={onClose}
38
- key="cancel"
39
- className={css.button}
40
- >
41
- Cancel
42
- </button>,
43
- <button
44
- disabled={isDeleting}
45
- onClick={handleSubmit}
46
- key="delete"
47
- className={css.button}
48
- >
49
- Delete
50
- </button>,
51
- ]}
52
- >
53
- Are you sure you want to delete this project?
54
- </Dialog>
55
- );
56
- }
57
- export default DeleteProjectDialog;
@@ -1,11 +0,0 @@
1
- .buttons {
2
- display: flex;
3
- gap: 1em;
4
- margin-top: 1em;
5
- justify-content: flex-end;
6
- }
7
-
8
- .dialog {
9
- border: 1px solid black;
10
- border-radius: 10px;
11
- }
@@ -1,19 +0,0 @@
1
- import { PropsWithChildren } from "react";
2
- import css from "./Dialog.module.css";
3
-
4
- interface DialogProps {
5
- isOpen: boolean;
6
- buttons?: React.ReactElement[];
7
- }
8
-
9
- function Dialog({ children, isOpen, buttons }: PropsWithChildren<DialogProps>) {
10
- return (
11
- <dialog open={isOpen} className={css.dialog}>
12
- {children}
13
- {buttons != null && buttons.length > 0 && (
14
- <div className={css.buttons}>{buttons}</div>
15
- )}
16
- </dialog>
17
- );
18
- }
19
- export default Dialog;
@@ -1,28 +0,0 @@
1
- .tutorialBannerWrapper {
2
- display: flex;
3
- margin: 2em;
4
- }
5
-
6
- .tutorialBanner {
7
- flex: 1;
8
- width: 0;
9
- background: rgba(121, 97, 219, 0.7);
10
- color: #ffffff;
11
- border-radius: 1em;
12
- padding: 1em;
13
- box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
14
- }
15
-
16
- .tutorialBannerTitle {
17
- margin-top: 0;
18
- font-weight: 600;
19
- }
20
-
21
- .projectSelect {
22
- display: flex;
23
- align-items: center;
24
- gap: 1em;
25
- margin: 2em;
26
- font-weight: 600;
27
- }
28
-
@@ -1,64 +0,0 @@
1
- import { useCallback, useEffect, useState } from "react";
2
- import CreateProjectButton from "./CreateProjectButton";
3
- import DeleteProjectButton from "./DeleteProjectButton";
4
- import css from "./Home.module.css";
5
- import Layout from "./Layout";
6
- import type { MockProject } from "./mocks";
7
- import { ProjectDetails } from "./ProjectDetails";
8
- import ProjectSelect from "./ProjectSelect";
9
- import useProjects from "./useProjects";
10
-
11
- function Home() {
12
- const [projectId, setProjectId] = useState<string | undefined>(undefined);
13
- const { projects } = useProjects();
14
-
15
- const project = projects?.find((p) => p.id === projectId);
16
-
17
- const handleSelectProject = useCallback(
18
- (p: MockProject) => setProjectId(p.id),
19
- [],
20
- );
21
-
22
- useEffect(() => {
23
- if (project == null && projects != null && projects.length > 0) {
24
- setProjectId(projects[0].id);
25
- }
26
- }, [project, projects]);
27
-
28
- const handleOnProjectCreated = useCallback(
29
- (projectId: string | undefined) => {
30
- setProjectId(projectId);
31
- },
32
- [],
33
- );
34
-
35
- return (
36
- <Layout>
37
- <div className={css.tutorialBannerWrapper}>
38
- <div className={css.tutorialBanner}>
39
- <p className={css.tutorialBannerTitle}>
40
- 💡 Welcome to the To Do AIP App tutorial!
41
- </p>
42
- <p>
43
- The application is implemented with mock in memory data.
44
- <br />Can you solve how to change it to use the Ontology SDK
45
- instead?
46
- </p>
47
- </div>
48
- </div>
49
- <div className={css.projectSelect}>
50
- <span>Project:</span>
51
- <ProjectSelect
52
- project={project}
53
- projects={projects ?? []}
54
- onSelectProject={handleSelectProject}
55
- />
56
- <CreateProjectButton onProjectCreated={handleOnProjectCreated} />
57
- {project != null && <DeleteProjectButton project={project} />}
58
- </div>
59
- {project != null && <ProjectDetails project={project} />}
60
- </Layout>
61
- );
62
- }
63
-
64
- export default Home;
@@ -1,16 +0,0 @@
1
- .header {
2
- display: flex;
3
- align-items: center;
4
- margin: 2em;
5
- }
6
-
7
- .logo {
8
- height: 4em;
9
- align-items: center;
10
- margin-right: 1em;
11
- }
12
-
13
- .title {
14
- font-weight: 600;
15
- font-size: 1.5em;
16
- }
@@ -1,23 +0,0 @@
1
- import todoAppLogo from "/todo-aip-app.svg";
2
- import React from "react";
3
- import css from "./Layout.module.css";
4
-
5
- interface LayoutProps {
6
- children?: React.ReactNode;
7
- }
8
-
9
- function Layout({ children }: LayoutProps) {
10
- return (
11
- <>
12
- <div className={css.header}>
13
- <img src={todoAppLogo} className={css.logo} alt="Todo App logo" />
14
- <div className={css.title}>
15
- Ontology SDK Tutorial - To Do App Powered by AIP
16
- </div>
17
- </div>
18
- {children}
19
- </>
20
- );
21
- }
22
-
23
- export default Layout;
@@ -1,5 +0,0 @@
1
- .loginButton {
2
- display: flex;
3
- justify-content: center;
4
- margin: 2em;
5
- }
@@ -1,44 +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
- import css from "./Login.module.css";
6
-
7
- function Login() {
8
- const [isLoggingIn, setIsLoggingIn] = useState(false);
9
- const [error, setError] = useState<string | undefined>(undefined);
10
- const token = client.auth.token;
11
-
12
- const handleLogin = useCallback(async () => {
13
- setIsLoggingIn(true);
14
- try {
15
- // Initiate the OAuth flow, which will redirect the user to log into Foundry
16
- // Once the login has completed, the user will be redirected back to the route defined via the
17
- // FOUNDRY_REDIRECT_URL variable in .env.development
18
- await client.auth.signIn();
19
- } catch (e: unknown) {
20
- console.error(e);
21
- setError((e as Error).message ?? e);
22
- } finally {
23
- setIsLoggingIn(false);
24
- }
25
- }, []);
26
-
27
- // If the token exists but a user tries to load /login, redirect to the home page instead
28
- if (token != null) {
29
- return <Navigate to="/" replace={true} />;
30
- }
31
-
32
- return (
33
- <Layout>
34
- <div className={css.loginButton}>
35
- <button onClick={handleLogin}>
36
- {isLoggingIn ? "Logging in…" : "Log in "}
37
- </button>
38
- </div>
39
- {error && <div>Unable to log in: {error}</div>}
40
- </Layout>
41
- );
42
- }
43
-
44
- export default Login;
@@ -1,53 +0,0 @@
1
- .projectCard {
2
- margin: 2em;
3
- padding: 0.5em;
4
- border: 1px solid #ccc;
5
- /* margin: 0.5em; */
6
- gap: 0.5em;
7
- border-radius: 5px;
8
-
9
- }
10
-
11
- .projectTitle {
12
- font-size: 1.5em;
13
- }
14
-
15
- .description {
16
- display: flex;
17
- flex-direction: column;
18
- gap: 5px;
19
- }
20
-
21
- .image {
22
- height: 16px;
23
- width: 16px;
24
- }
25
-
26
- .aip {
27
- background-color: #7961DB;
28
- color: #ffffff;
29
- border: 1px solid #ccc;
30
- padding: 2px;
31
- gap: 10px;
32
- height: 30px;
33
- }
34
-
35
- .processing {
36
- cursor: progress;
37
- }
38
-
39
- .aipText {
40
- display: flex;
41
- justify-content: center;
42
- gap: 10px;
43
- align-items: center;
44
- padding: 0 10px;
45
- }
46
-
47
- .textArea {
48
- border: none;
49
- color: gray;
50
- resize: none;
51
- overflow: hidden;
52
- pointer-events: none;
53
- }
@@ -1,88 +0,0 @@
1
- import aipLogo from "/aip-icon.svg";
2
- import { useCallback, useEffect, useRef, useState } from "react";
3
- import CreateTaskButton from "./CreateTaskButton";
4
- import type { MockProject } from "./mocks";
5
- import css from "./ProjectDetails.module.css";
6
- import TaskList from "./TaskList";
7
- import useProjects from "./useProjects";
8
- import { useProjectTasks } from "./useProjectTasks";
9
-
10
- interface ProjectDetailsProps {
11
- project: MockProject;
12
- }
13
-
14
- export function ProjectDetails({ project }: ProjectDetailsProps) {
15
- const [projectHasTasks, setProjectHasTasks] = useState<boolean>(false);
16
- const [isProcessing, setIsProcessing] = useState<boolean>(false);
17
- const { updateProjectDescription } = useProjects();
18
- const tasks = useProjectTasks(project).tasks;
19
- const textAreaRef = useRef<HTMLTextAreaElement>(null);
20
-
21
- useEffect(() => {
22
- setProjectHasTasks(tasks == null ? false : tasks.length > 0);
23
- }, [project, tasks]);
24
-
25
- const handleProjectDescriptionRecommendation = useCallback(async () => {
26
- if (project == null) {
27
- return;
28
- }
29
- setIsProcessing(true);
30
- await updateProjectDescription(project);
31
- setIsProcessing(false);
32
- }, [project, updateProjectDescription]);
33
-
34
- useEffect(() => {
35
- if (textAreaRef.current) {
36
- const textArea = textAreaRef.current;
37
- textArea.style.height = "auto";
38
- textArea.style.height = `${textArea.scrollHeight}px`;
39
- }
40
- }, [project.description]);
41
-
42
- const handleOnTaskCreated = useCallback(() => {
43
- setProjectHasTasks(true);
44
- }, []);
45
-
46
- const handleOnTaskDeleted = useCallback(() => {
47
- if (tasks?.length === 0) {
48
- setProjectHasTasks(false);
49
- }
50
- }, [tasks]);
51
-
52
- return (
53
- <div className={css.projectCard} key={project.id}>
54
- <h1 className={css.projectTitle}>{project.name}</h1>
55
- {projectHasTasks && (
56
- <div className={css.description}>
57
- <textarea
58
- ref={textAreaRef}
59
- readOnly
60
- value={project.description}
61
- className={css.textArea}
62
- />
63
- <button
64
- disabled={isProcessing}
65
- className={`${css.aip} ${isProcessing ? css.processing : ""}`}
66
- title="Click here to update project description based on AIP Logic"
67
- type="button"
68
- onClick={handleProjectDescriptionRecommendation}
69
- >
70
- <div className={css.aipText}>
71
- <img
72
- src={aipLogo}
73
- alt="AIP"
74
- className={css.image}
75
- />
76
- Get description recommendation
77
- </div>
78
- </button>
79
- </div>
80
- )}
81
- <TaskList project={project} onTaskDeleted={handleOnTaskDeleted} />
82
- <CreateTaskButton
83
- project={project}
84
- onTaskCreated={handleOnTaskCreated}
85
- />
86
- </div>
87
- );
88
- }
@@ -1,40 +0,0 @@
1
- import { ChangeEvent, useCallback } from "react";
2
- import { MockProject } from "./mocks";
3
-
4
- interface ProjectSelectProps {
5
- project: MockProject | undefined;
6
- projects: MockProject[];
7
- onSelectProject: (project: MockProject) => void;
8
- }
9
-
10
- function ProjectSelect({
11
- project,
12
- projects,
13
- onSelectProject,
14
- }: ProjectSelectProps) {
15
- const handleSelect = useCallback(
16
- (e: ChangeEvent<HTMLSelectElement>) => {
17
- const nextProject = projects.find((p) => `${p.id}` === e.target.value);
18
- if (nextProject != null) {
19
- onSelectProject(nextProject);
20
- }
21
- },
22
- [projects, onSelectProject],
23
- );
24
-
25
- return (
26
- <select value={project?.id} onChange={handleSelect}>
27
- <option hidden disabled value="">
28
- -- select a project --
29
- </option>
30
-
31
- {projects.map((p) => (
32
- <option key={p.id} value={p.id}>
33
- {p.name}
34
- </option>
35
- ))}
36
- </select>
37
- );
38
- }
39
-
40
- export default ProjectSelect;
@@ -1,7 +0,0 @@
1
- .taskList {
2
- list-style: none;
3
- padding: 0;
4
- margin-top: 1em;
5
- margin-bottom: 1em;
6
- width: 100%;
7
- }
@@ -1,44 +0,0 @@
1
- import type { MockProject } from "./mocks";
2
- import css from "./TaskList.module.css";
3
- import TaskListItem from "./TaskListItem";
4
- import { useProjectTasks } from "./useProjectTasks";
5
-
6
- interface TaskListProps {
7
- project: MockProject;
8
- onTaskDeleted: (taskId: string | undefined) => void;
9
- }
10
-
11
- function TaskList({ project, onTaskDeleted }: TaskListProps) {
12
- const {
13
- tasks,
14
- isLoading: isLoadingTasks,
15
- isError: isErrorTasks,
16
- deleteTask,
17
- } = useProjectTasks(project);
18
-
19
- if (isErrorTasks) {
20
- return <div className={css.taskList}>Error loading tasks!</div>;
21
- } else if (isLoadingTasks) {
22
- return null;
23
- }
24
-
25
- const data = tasks ?? [];
26
- if (data.length === 0) {
27
- return <div className={css.taskList}>No tasks found</div>;
28
- }
29
-
30
- return (
31
- <ul className={css.taskList}>
32
- {data.map((task) => (
33
- <TaskListItem
34
- key={task.id}
35
- task={task}
36
- deleteTask={deleteTask}
37
- onTaskDeleted={onTaskDeleted}
38
- />
39
- ))}
40
- </ul>
41
- );
42
- }
43
-
44
- export default TaskList;
@@ -1,35 +0,0 @@
1
- .li {
2
- display: flex;
3
- flex-direction: row;
4
- align-items: flex-start;
5
- padding: 5px;
6
- border: 1px solid #ccc;
7
- gap: 5px;
8
- border-radius: 5px;
9
- background-color: #f9f9f9;
10
- margin: 10px 0;
11
- }
12
-
13
- .checked {
14
- text-decoration: line-through;
15
- }
16
-
17
- .delete {
18
- border: 1px solid #ccc;
19
- padding: 2px;
20
- }
21
-
22
- .task {
23
- display: flex;
24
- flex-direction: column;
25
- width: 100%;
26
- }
27
-
28
- .textArea {
29
- border: none;
30
- background-color: #f9f9f9;
31
- color: gray;
32
- resize: none;
33
- overflow: hidden;
34
- pointer-events: none;
35
- }
@@ -1,58 +0,0 @@
1
- import { useCallback, useEffect, useRef, useState } from "react";
2
- import type { MockTask } from "./mocks";
3
- import css from "./TaskListItem.module.css";
4
-
5
- interface TaskListItemProps {
6
- task: MockTask;
7
- deleteTask: (task: MockTask) => Promise<void>;
8
- onTaskDeleted: (taskId: string | undefined) => void;
9
- }
10
-
11
- function TaskListItem({ task, deleteTask, onTaskDeleted }: TaskListItemProps) {
12
- const [isDeleting, setIsDeleting] = useState(false);
13
- const textAreaRef = useRef<HTMLTextAreaElement>(null);
14
-
15
- const handleClick = useCallback(async () => {
16
- setIsDeleting(true);
17
- try {
18
- await deleteTask(task);
19
- } finally {
20
- onTaskDeleted(task.id);
21
- setIsDeleting(false);
22
- }
23
- }, [deleteTask, task, onTaskDeleted]);
24
-
25
- useEffect(() => {
26
- if (textAreaRef.current) {
27
- const textArea = textAreaRef.current;
28
- textArea.style.height = "auto";
29
- textArea.style.height = `${textArea.scrollHeight}px`;
30
- }
31
- }, [task.description]);
32
- const cleanDescription = task.description?.trim();
33
- return (
34
- <li className={css.li}>
35
- <input
36
- type="checkbox"
37
- onChange={handleClick}
38
- checked={isDeleting}
39
- className={css.delete}
40
- title="Delete task"
41
- />
42
- <div className={`${css.task} ${isDeleting ? css.checked : ""}`}>
43
- <span>{task.title}</span>
44
- {cleanDescription != null && (
45
- <textarea
46
- ref={textAreaRef}
47
- readOnly
48
- value={task.description}
49
- className={css.textArea}
50
- rows={1}
51
- />
52
- )}
53
- </div>
54
- </li>
55
- );
56
- }
57
-
58
- export default TaskListItem;
@@ -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;