@osdk/create-app 0.17.0-beta.2 → 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 (145) hide show
  1. package/CHANGELOG.md +12 -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 -80
  72. package/templates/template-tutorial-todo-aip-app/src/Home.tsx +0 -135
  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/ProjectSelect.tsx +0 -40
  78. package/templates/template-tutorial-todo-aip-app/src/TaskList.module.css +0 -7
  79. package/templates/template-tutorial-todo-aip-app/src/TaskList.tsx +0 -44
  80. package/templates/template-tutorial-todo-aip-app/src/TaskListItem.module.css +0 -35
  81. package/templates/template-tutorial-todo-aip-app/src/TaskListItem.tsx +0 -58
  82. package/templates/template-tutorial-todo-aip-app/src/client.ts.hbs +0 -31
  83. package/templates/template-tutorial-todo-aip-app/src/index.css +0 -75
  84. package/templates/template-tutorial-todo-aip-app/src/main.tsx +0 -36
  85. package/templates/template-tutorial-todo-aip-app/src/mocks.ts +0 -187
  86. package/templates/template-tutorial-todo-aip-app/src/useProjectTasks.ts +0 -75
  87. package/templates/template-tutorial-todo-aip-app/src/useProjects.ts +0 -58
  88. package/templates/template-tutorial-todo-aip-app/src/vite-env.d.ts +0 -1
  89. package/templates/template-tutorial-todo-aip-app/tsconfig.json +0 -25
  90. package/templates/template-tutorial-todo-aip-app/tsconfig.node.json +0 -10
  91. package/templates/template-tutorial-todo-aip-app/vite.config.ts.hbs +0 -19
  92. package/templates/template-tutorial-todo-app/.eslintrc.cjs +0 -18
  93. package/templates/template-tutorial-todo-app/README.md.hbs +0 -33
  94. package/templates/template-tutorial-todo-app/index.html +0 -15
  95. package/templates/template-tutorial-todo-app/package.json.hbs +0 -31
  96. package/templates/template-tutorial-todo-app/public/todo-app.svg +0 -4
  97. package/templates/template-tutorial-todo-app/src/AuthCallback.tsx +0 -24
  98. package/templates/template-tutorial-todo-app/src/AuthenticatedRoute.tsx +0 -33
  99. package/templates/template-tutorial-todo-app/src/CreateProjectButton.tsx +0 -33
  100. package/templates/template-tutorial-todo-app/src/CreateProjectDialog.tsx +0 -56
  101. package/templates/template-tutorial-todo-app/src/CreateTaskButton.tsx +0 -35
  102. package/templates/template-tutorial-todo-app/src/CreateTaskDialog.tsx +0 -52
  103. package/templates/template-tutorial-todo-app/src/DeleteProjectButton.tsx +0 -34
  104. package/templates/template-tutorial-todo-app/src/DeleteProjectDialog.tsx +0 -46
  105. package/templates/template-tutorial-todo-app/src/Dialog.module.css +0 -10
  106. package/templates/template-tutorial-todo-app/src/Dialog.tsx +0 -19
  107. package/templates/template-tutorial-todo-app/src/Home.module.css +0 -34
  108. package/templates/template-tutorial-todo-app/src/Home.tsx +0 -63
  109. package/templates/template-tutorial-todo-app/src/Layout.module.css +0 -16
  110. package/templates/template-tutorial-todo-app/src/Layout.tsx +0 -21
  111. package/templates/template-tutorial-todo-app/src/Login.module.css +0 -5
  112. package/templates/template-tutorial-todo-app/src/Login.tsx +0 -44
  113. package/templates/template-tutorial-todo-app/src/ProjectSelect.tsx +0 -40
  114. package/templates/template-tutorial-todo-app/src/TaskList.module.css +0 -6
  115. package/templates/template-tutorial-todo-app/src/TaskList.tsx +0 -38
  116. package/templates/template-tutorial-todo-app/src/TaskListItem.module.css +0 -13
  117. package/templates/template-tutorial-todo-app/src/TaskListItem.tsx +0 -40
  118. package/templates/template-tutorial-todo-app/src/client.ts.hbs +0 -31
  119. package/templates/template-tutorial-todo-app/src/index.css +0 -75
  120. package/templates/template-tutorial-todo-app/src/main.tsx +0 -36
  121. package/templates/template-tutorial-todo-app/src/mocks.ts +0 -137
  122. package/templates/template-tutorial-todo-app/src/useProjectTasks.ts +0 -60
  123. package/templates/template-tutorial-todo-app/src/useProjects.ts +0 -43
  124. package/templates/template-tutorial-todo-app/src/vite-env.d.ts +0 -1
  125. package/templates/template-tutorial-todo-app/tsconfig.json +0 -25
  126. package/templates/template-tutorial-todo-app/tsconfig.node.json +0 -10
  127. package/templates/template-tutorial-todo-app/vite.config.ts.hbs +0 -19
  128. package/templates/template-vue/.vscode/extensions.json +0 -3
  129. package/templates/template-vue/README.md.hbs +0 -35
  130. package/templates/template-vue/_gitignore +0 -24
  131. package/templates/template-vue/index.html +0 -15
  132. package/templates/template-vue/package.json.hbs +0 -22
  133. package/templates/template-vue/public/palantir.svg +0 -3
  134. package/templates/template-vue/public/vue.svg +0 -1
  135. package/templates/template-vue/src/AuthCallback.vue +0 -22
  136. package/templates/template-vue/src/Home.vue.hbs +0 -38
  137. package/templates/template-vue/src/Layout.vue +0 -26
  138. package/templates/template-vue/src/Login.vue +0 -36
  139. package/templates/template-vue/src/client.ts.hbs +0 -31
  140. package/templates/template-vue/src/main.ts +0 -35
  141. package/templates/template-vue/src/style.css +0 -81
  142. package/templates/template-vue/src/vite-env.d.ts +0 -1
  143. package/templates/template-vue/tsconfig.json +0 -25
  144. package/templates/template-vue/tsconfig.node.json +0 -10
  145. 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,80 +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
-
29
- .projectCard {
30
- margin: 2em;
31
- padding: 0.5em;
32
- border: 1px solid #ccc;
33
- /* margin: 0.5em; */
34
- gap: 0.5em;
35
- border-radius: 5px;
36
-
37
- }
38
-
39
- .projectTitle {
40
- font-size: 1.5em;
41
- }
42
-
43
- .description {
44
- display: flex;
45
- flex-direction: column;
46
- }
47
-
48
- .image {
49
- height: 16px;
50
- width: 16px;
51
- }
52
-
53
- .aip {
54
- background-color: #7961DB;
55
- color: #ffffff;
56
- border: 1px solid #ccc;
57
- padding: 2px;
58
- gap: 10px;
59
- height: 30px;
60
- }
61
-
62
- .processing {
63
- cursor: progress;
64
- }
65
-
66
- .aipText {
67
- display: flex;
68
- justify-content: center;
69
- gap: 10px;
70
- align-items: center;
71
- padding: 0 10px;
72
- }
73
-
74
- .textArea {
75
- border: none;
76
- color: gray;
77
- resize: none;
78
- overflow: hidden;
79
- pointer-events: none;
80
- }
@@ -1,135 +0,0 @@
1
- import aipLogo from "/aip-icon.svg";
2
- import { useCallback, useEffect, useRef, useState } from "react";
3
- import CreateProjectButton from "./CreateProjectButton";
4
- import CreateTaskButton from "./CreateTaskButton";
5
- import DeleteProjectButton from "./DeleteProjectButton";
6
- import css from "./Home.module.css";
7
- import Layout from "./Layout";
8
- import type { MockProject } from "./mocks";
9
- import ProjectSelect from "./ProjectSelect";
10
- import TaskList from "./TaskList";
11
- import useProjects from "./useProjects";
12
- import { useProjectTasks } from "./useProjectTasks";
13
-
14
- function Home() {
15
- const [projectId, setProjectId] = useState<string | undefined>(undefined);
16
- const { projects, updateProjectDescription } = useProjects();
17
- const [isProcessing, setIsProcessing] = useState<boolean>(false);
18
- const [projectHasTasks, setProjectHasTasks] = useState<boolean>(false);
19
-
20
- const textAreaRef = useRef<HTMLTextAreaElement>(null);
21
- const project = projects?.find((p) => p.id === projectId);
22
- const tasks = useProjectTasks(project).tasks;
23
-
24
- const handleSelectProject = useCallback(
25
- (p: MockProject) => setProjectId(p.id),
26
- [],
27
- );
28
-
29
- const handleProjectDescriptionRecommendation = useCallback(async () => {
30
- if (project == null) {
31
- return;
32
- }
33
- setIsProcessing(true);
34
- await updateProjectDescription(project);
35
- setIsProcessing(false);
36
- }, [project, updateProjectDescription]);
37
-
38
- useEffect(() => {
39
- if (project == null && projects != null && projects.length > 0) {
40
- setProjectId(projects[0].id);
41
- setProjectHasTasks(tasks == null ? false : tasks.length > 0);
42
- }
43
- }, [project, projects, tasks]);
44
-
45
- useEffect(() => {
46
- if (textAreaRef.current) {
47
- const textArea = textAreaRef.current;
48
- textArea.style.height = "auto";
49
- textArea.style.height = `${textArea.scrollHeight}px`;
50
- }
51
- }, [project?.description]);
52
-
53
- const handleOnTaskCreated = useCallback(() => {
54
- setProjectHasTasks(true);
55
- }, []);
56
-
57
- const handleOnProjectCreated = useCallback(
58
- (projectId: string | undefined) => {
59
- setProjectId(projectId);
60
- setProjectHasTasks(false);
61
- },
62
- [],
63
- );
64
-
65
- const handleOnTaskDeleted = useCallback(() => {
66
- if (tasks?.length === 0) {
67
- setProjectHasTasks(false);
68
- }
69
- }, [tasks]);
70
-
71
- return (
72
- <Layout>
73
- <div className={css.tutorialBannerWrapper}>
74
- <div className={css.tutorialBanner}>
75
- <p className={css.tutorialBannerTitle}>
76
- 💡 Welcome to the To Do AIP App tutorial!
77
- </p>
78
- <p>
79
- The application is implemented with mock in memory data.
80
- <br />Can you solve how to change it to use the Ontology SDK
81
- instead?
82
- </p>
83
- </div>
84
- </div>
85
- <div className={css.projectSelect}>
86
- <span>Project:</span>
87
- <ProjectSelect
88
- project={project}
89
- projects={projects ?? []}
90
- onSelectProject={handleSelectProject}
91
- />
92
- <CreateProjectButton onProjectCreated={handleOnProjectCreated} />
93
- {project != null && <DeleteProjectButton project={project} />}
94
- </div>
95
- {project != null && (
96
- <div className={css.projectCard} key={project.id}>
97
- <h1 className={css.projectTitle}>{project.name}</h1>
98
- {projectHasTasks && (
99
- <div className={css.description}>
100
- <textarea
101
- ref={textAreaRef}
102
- readOnly
103
- value={project.description}
104
- className={css.textArea}
105
- />
106
- <button
107
- disabled={isProcessing}
108
- className={`${css.aip} ${isProcessing ? css.processing : ""}`}
109
- title="Click here to update project description based on AIP Logic"
110
- type="button"
111
- onClick={handleProjectDescriptionRecommendation}
112
- >
113
- <div className={css.aipText}>
114
- <img
115
- src={aipLogo}
116
- alt="AIP"
117
- className={css.image}
118
- />
119
- Get description recommendation
120
- </div>
121
- </button>
122
- </div>
123
- )}
124
- <TaskList project={project} onTaskDeleted={handleOnTaskDeleted} />
125
- <CreateTaskButton
126
- project={project}
127
- onTaskCreated={handleOnTaskCreated}
128
- />
129
- </div>
130
- )}
131
- </Layout>
132
- );
133
- }
134
-
135
- 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,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;