@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.
- package/CHANGELOG.md +12 -0
- package/build/browser/index.js +9 -13
- package/build/browser/index.js.map +1 -1
- package/build/cjs/index.cjs +9 -14
- package/build/cjs/index.cjs.map +1 -1
- package/build/esm/index.js +9 -13
- package/build/esm/index.js.map +1 -1
- package/build/esm/run.d.ts.map +1 -1
- package/package.json +15 -6
- package/templates/template-next-static-export/.eslintrc.json +0 -4
- package/templates/template-next-static-export/README.md.hbs +0 -35
- package/templates/template-next-static-export/_gitignore +0 -36
- package/templates/template-next-static-export/next.config.js.hbs +0 -17
- package/templates/template-next-static-export/package.json.hbs +0 -25
- package/templates/template-next-static-export/public/next.svg +0 -20
- package/templates/template-next-static-export/public/palantir.svg +0 -3
- package/templates/template-next-static-export/src/app/auth/callback/page.tsx +0 -25
- package/templates/template-next-static-export/src/app/globals.css +0 -81
- package/templates/template-next-static-export/src/app/icon.svg +0 -20
- package/templates/template-next-static-export/src/app/layout.module.css +0 -11
- package/templates/template-next-static-export/src/app/layout.tsx +0 -51
- package/templates/template-next-static-export/src/app/login/page.tsx +0 -45
- package/templates/template-next-static-export/src/app/page.module.css +0 -7
- package/templates/template-next-static-export/src/app/page.tsx.hbs +0 -53
- package/templates/template-next-static-export/src/lib/client.ts.hbs +0 -31
- package/templates/template-next-static-export/src/lib/useAuthenticated.ts +0 -25
- package/templates/template-next-static-export/tsconfig.json +0 -27
- package/templates/template-react/.eslintrc.cjs +0 -18
- package/templates/template-react/README.md.hbs +0 -35
- package/templates/template-react/_gitignore +0 -24
- package/templates/template-react/index.html +0 -15
- package/templates/template-react/package.json.hbs +0 -30
- package/templates/template-react/public/palantir.svg +0 -3
- package/templates/template-react/public/react.svg +0 -1
- package/templates/template-react/src/AuthCallback.tsx +0 -24
- package/templates/template-react/src/AuthenticatedRoute.tsx +0 -33
- package/templates/template-react/src/Home.module.css +0 -7
- package/templates/template-react/src/Home.tsx.hbs +0 -47
- package/templates/template-react/src/Layout.module.css +0 -10
- package/templates/template-react/src/Layout.tsx +0 -29
- package/templates/template-react/src/Login.tsx +0 -42
- package/templates/template-react/src/client.ts.hbs +0 -31
- package/templates/template-react/src/index.css +0 -81
- package/templates/template-react/src/main.tsx +0 -36
- package/templates/template-react/src/vite-env.d.ts +0 -1
- package/templates/template-react/tsconfig.json +0 -25
- package/templates/template-react/tsconfig.node.json +0 -10
- package/templates/template-react/vite.config.ts.hbs +0 -19
- package/templates/template-tutorial-todo-aip-app/.eslintrc.cjs +0 -18
- package/templates/template-tutorial-todo-aip-app/README.md.hbs +0 -34
- package/templates/template-tutorial-todo-aip-app/index.html +0 -15
- package/templates/template-tutorial-todo-aip-app/package.json.hbs +0 -31
- package/templates/template-tutorial-todo-aip-app/public/aip-icon.svg +0 -3
- package/templates/template-tutorial-todo-aip-app/public/todo-aip-app.svg +0 -19
- package/templates/template-tutorial-todo-aip-app/src/AuthCallback.tsx +0 -24
- package/templates/template-tutorial-todo-aip-app/src/AuthenticatedRoute.tsx +0 -33
- package/templates/template-tutorial-todo-aip-app/src/CreateProjectButton.module.css +0 -3
- package/templates/template-tutorial-todo-aip-app/src/CreateProjectButton.tsx +0 -36
- package/templates/template-tutorial-todo-aip-app/src/CreateProjectDialog.module.css +0 -15
- package/templates/template-tutorial-todo-aip-app/src/CreateProjectDialog.tsx +0 -74
- package/templates/template-tutorial-todo-aip-app/src/CreateTaskButton.module.css +0 -3
- package/templates/template-tutorial-todo-aip-app/src/CreateTaskButton.tsx +0 -38
- package/templates/template-tutorial-todo-aip-app/src/CreateTaskDialog.module.css +0 -66
- package/templates/template-tutorial-todo-aip-app/src/CreateTaskDialog.tsx +0 -140
- package/templates/template-tutorial-todo-aip-app/src/DeleteProjectButton.module.css +0 -3
- package/templates/template-tutorial-todo-aip-app/src/DeleteProjectButton.tsx +0 -37
- package/templates/template-tutorial-todo-aip-app/src/DeleteProjectDialog.module.css +0 -3
- package/templates/template-tutorial-todo-aip-app/src/DeleteProjectDialog.tsx +0 -57
- package/templates/template-tutorial-todo-aip-app/src/Dialog.module.css +0 -11
- package/templates/template-tutorial-todo-aip-app/src/Dialog.tsx +0 -19
- package/templates/template-tutorial-todo-aip-app/src/Home.module.css +0 -80
- package/templates/template-tutorial-todo-aip-app/src/Home.tsx +0 -135
- package/templates/template-tutorial-todo-aip-app/src/Layout.module.css +0 -16
- package/templates/template-tutorial-todo-aip-app/src/Layout.tsx +0 -23
- package/templates/template-tutorial-todo-aip-app/src/Login.module.css +0 -5
- package/templates/template-tutorial-todo-aip-app/src/Login.tsx +0 -44
- package/templates/template-tutorial-todo-aip-app/src/ProjectSelect.tsx +0 -40
- package/templates/template-tutorial-todo-aip-app/src/TaskList.module.css +0 -7
- package/templates/template-tutorial-todo-aip-app/src/TaskList.tsx +0 -44
- package/templates/template-tutorial-todo-aip-app/src/TaskListItem.module.css +0 -35
- package/templates/template-tutorial-todo-aip-app/src/TaskListItem.tsx +0 -58
- package/templates/template-tutorial-todo-aip-app/src/client.ts.hbs +0 -31
- package/templates/template-tutorial-todo-aip-app/src/index.css +0 -75
- package/templates/template-tutorial-todo-aip-app/src/main.tsx +0 -36
- package/templates/template-tutorial-todo-aip-app/src/mocks.ts +0 -187
- package/templates/template-tutorial-todo-aip-app/src/useProjectTasks.ts +0 -75
- package/templates/template-tutorial-todo-aip-app/src/useProjects.ts +0 -58
- package/templates/template-tutorial-todo-aip-app/src/vite-env.d.ts +0 -1
- package/templates/template-tutorial-todo-aip-app/tsconfig.json +0 -25
- package/templates/template-tutorial-todo-aip-app/tsconfig.node.json +0 -10
- package/templates/template-tutorial-todo-aip-app/vite.config.ts.hbs +0 -19
- package/templates/template-tutorial-todo-app/.eslintrc.cjs +0 -18
- package/templates/template-tutorial-todo-app/README.md.hbs +0 -33
- package/templates/template-tutorial-todo-app/index.html +0 -15
- package/templates/template-tutorial-todo-app/package.json.hbs +0 -31
- package/templates/template-tutorial-todo-app/public/todo-app.svg +0 -4
- package/templates/template-tutorial-todo-app/src/AuthCallback.tsx +0 -24
- package/templates/template-tutorial-todo-app/src/AuthenticatedRoute.tsx +0 -33
- package/templates/template-tutorial-todo-app/src/CreateProjectButton.tsx +0 -33
- package/templates/template-tutorial-todo-app/src/CreateProjectDialog.tsx +0 -56
- package/templates/template-tutorial-todo-app/src/CreateTaskButton.tsx +0 -35
- package/templates/template-tutorial-todo-app/src/CreateTaskDialog.tsx +0 -52
- package/templates/template-tutorial-todo-app/src/DeleteProjectButton.tsx +0 -34
- package/templates/template-tutorial-todo-app/src/DeleteProjectDialog.tsx +0 -46
- package/templates/template-tutorial-todo-app/src/Dialog.module.css +0 -10
- package/templates/template-tutorial-todo-app/src/Dialog.tsx +0 -19
- package/templates/template-tutorial-todo-app/src/Home.module.css +0 -34
- package/templates/template-tutorial-todo-app/src/Home.tsx +0 -63
- package/templates/template-tutorial-todo-app/src/Layout.module.css +0 -16
- package/templates/template-tutorial-todo-app/src/Layout.tsx +0 -21
- package/templates/template-tutorial-todo-app/src/Login.module.css +0 -5
- package/templates/template-tutorial-todo-app/src/Login.tsx +0 -44
- package/templates/template-tutorial-todo-app/src/ProjectSelect.tsx +0 -40
- package/templates/template-tutorial-todo-app/src/TaskList.module.css +0 -6
- package/templates/template-tutorial-todo-app/src/TaskList.tsx +0 -38
- package/templates/template-tutorial-todo-app/src/TaskListItem.module.css +0 -13
- package/templates/template-tutorial-todo-app/src/TaskListItem.tsx +0 -40
- package/templates/template-tutorial-todo-app/src/client.ts.hbs +0 -31
- package/templates/template-tutorial-todo-app/src/index.css +0 -75
- package/templates/template-tutorial-todo-app/src/main.tsx +0 -36
- package/templates/template-tutorial-todo-app/src/mocks.ts +0 -137
- package/templates/template-tutorial-todo-app/src/useProjectTasks.ts +0 -60
- package/templates/template-tutorial-todo-app/src/useProjects.ts +0 -43
- package/templates/template-tutorial-todo-app/src/vite-env.d.ts +0 -1
- package/templates/template-tutorial-todo-app/tsconfig.json +0 -25
- package/templates/template-tutorial-todo-app/tsconfig.node.json +0 -10
- package/templates/template-tutorial-todo-app/vite.config.ts.hbs +0 -19
- package/templates/template-vue/.vscode/extensions.json +0 -3
- package/templates/template-vue/README.md.hbs +0 -35
- package/templates/template-vue/_gitignore +0 -24
- package/templates/template-vue/index.html +0 -15
- package/templates/template-vue/package.json.hbs +0 -22
- package/templates/template-vue/public/palantir.svg +0 -3
- package/templates/template-vue/public/vue.svg +0 -1
- package/templates/template-vue/src/AuthCallback.vue +0 -22
- package/templates/template-vue/src/Home.vue.hbs +0 -38
- package/templates/template-vue/src/Layout.vue +0 -26
- package/templates/template-vue/src/Login.vue +0 -36
- package/templates/template-vue/src/client.ts.hbs +0 -31
- package/templates/template-vue/src/main.ts +0 -35
- package/templates/template-vue/src/style.css +0 -81
- package/templates/template-vue/src/vite-env.d.ts +0 -1
- package/templates/template-vue/tsconfig.json +0 -25
- package/templates/template-vue/tsconfig.node.json +0 -10
- package/templates/template-vue/vite.config.ts.hbs +0 -24
|
@@ -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={onClose} key="cancel">
|
|
43
|
-
Cancel
|
|
44
|
-
</button>,
|
|
45
|
-
<button disabled={isCreating} onClick={handleSubmit} key="create">
|
|
46
|
-
Create project
|
|
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;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { ChangeEvent, useCallback, useEffect, useState } from "react";
|
|
2
|
-
import Dialog from "./Dialog";
|
|
3
|
-
import { MockProject } from "./mocks";
|
|
4
|
-
import { useProjectTasks } from "./useProjectTasks";
|
|
5
|
-
|
|
6
|
-
interface CreateTaskDialogProps {
|
|
7
|
-
project: MockProject;
|
|
8
|
-
isOpen: boolean;
|
|
9
|
-
onClose: () => void;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function CreateTaskDialog({ project, isOpen, onClose }: CreateTaskDialogProps) {
|
|
13
|
-
const { createTask } = useProjectTasks(project);
|
|
14
|
-
|
|
15
|
-
const [name, setName] = useState<string>("New task");
|
|
16
|
-
const handleChange = useCallback(
|
|
17
|
-
(e: ChangeEvent<HTMLInputElement>) => setName(e.target.value),
|
|
18
|
-
[],
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
useEffect(() => setName("New task"), [isOpen]);
|
|
22
|
-
|
|
23
|
-
const [isCreating, setIsCreating] = useState(false);
|
|
24
|
-
const handleSubmit = useCallback(async () => {
|
|
25
|
-
setIsCreating(true);
|
|
26
|
-
try {
|
|
27
|
-
await createTask(name);
|
|
28
|
-
} finally {
|
|
29
|
-
setIsCreating(false);
|
|
30
|
-
onClose();
|
|
31
|
-
}
|
|
32
|
-
}, [onClose, createTask, name]);
|
|
33
|
-
|
|
34
|
-
return (
|
|
35
|
-
<Dialog
|
|
36
|
-
isOpen={isOpen}
|
|
37
|
-
buttons={[
|
|
38
|
-
<button disabled={isCreating} onClick={onClose} key="cancel">
|
|
39
|
-
Cancel
|
|
40
|
-
</button>,
|
|
41
|
-
<button disabled={isCreating} onClick={handleSubmit} key="create">
|
|
42
|
-
Create task
|
|
43
|
-
</button>,
|
|
44
|
-
]}
|
|
45
|
-
>
|
|
46
|
-
<label>
|
|
47
|
-
Task name: <input type="text" value={name} onChange={handleChange} />
|
|
48
|
-
</label>
|
|
49
|
-
</Dialog>
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
export default CreateTaskDialog;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { useCallback, useState } from "react";
|
|
2
|
-
import DeleteProjectDialog from "./DeleteProjectDialog";
|
|
3
|
-
import { MockProject } from "./mocks";
|
|
4
|
-
import useProjects from "./useProjects";
|
|
5
|
-
|
|
6
|
-
interface DeleteProjectButtonProps {
|
|
7
|
-
project: MockProject;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
function DeleteProjectButton({ project }: DeleteProjectButtonProps) {
|
|
11
|
-
const { isLoading: isLoadingProjects, isError: isErrorProjects } =
|
|
12
|
-
useProjects();
|
|
13
|
-
|
|
14
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
15
|
-
const handleOpen = useCallback(() => setIsOpen(true), []);
|
|
16
|
-
const handleClose = useCallback(() => setIsOpen(false), []);
|
|
17
|
-
|
|
18
|
-
if (isLoadingProjects || isErrorProjects) {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<>
|
|
24
|
-
<button onClick={handleOpen}>Delete Project</button>
|
|
25
|
-
<DeleteProjectDialog
|
|
26
|
-
project={project}
|
|
27
|
-
isOpen={isOpen}
|
|
28
|
-
onClose={handleClose}
|
|
29
|
-
/>
|
|
30
|
-
</>
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export default DeleteProjectButton;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { useCallback, useState } from "react";
|
|
2
|
-
import Dialog from "./Dialog";
|
|
3
|
-
import { MockProject } from "./mocks";
|
|
4
|
-
import useProjects from "./useProjects";
|
|
5
|
-
|
|
6
|
-
interface DeleteProjectDialogProps {
|
|
7
|
-
project: MockProject;
|
|
8
|
-
isOpen: boolean;
|
|
9
|
-
onClose: () => void;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function DeleteProjectDialog({
|
|
13
|
-
project,
|
|
14
|
-
isOpen,
|
|
15
|
-
onClose,
|
|
16
|
-
}: DeleteProjectDialogProps) {
|
|
17
|
-
const { deleteProject } = useProjects();
|
|
18
|
-
|
|
19
|
-
const [isDeleting, setIsDeleting] = useState(false);
|
|
20
|
-
const handleSubmit = useCallback(async () => {
|
|
21
|
-
setIsDeleting(true);
|
|
22
|
-
try {
|
|
23
|
-
await deleteProject(project);
|
|
24
|
-
} finally {
|
|
25
|
-
setIsDeleting(false);
|
|
26
|
-
onClose();
|
|
27
|
-
}
|
|
28
|
-
}, [deleteProject, onClose, project]);
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
<Dialog
|
|
32
|
-
isOpen={isOpen}
|
|
33
|
-
buttons={[
|
|
34
|
-
<button disabled={isDeleting} onClick={onClose} key="cancel">
|
|
35
|
-
Cancel
|
|
36
|
-
</button>,
|
|
37
|
-
<button disabled={isDeleting} onClick={handleSubmit} key="delete">
|
|
38
|
-
Delete
|
|
39
|
-
</button>,
|
|
40
|
-
]}
|
|
41
|
-
>
|
|
42
|
-
Are you sure you want to delete this project?
|
|
43
|
-
</Dialog>
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
export default DeleteProjectDialog;
|
|
@@ -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,34 +0,0 @@
|
|
|
1
|
-
.tutorialBannerWrapper {
|
|
2
|
-
display: flex;
|
|
3
|
-
margin: 2em;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
.tutorialBanner {
|
|
7
|
-
flex: 1;
|
|
8
|
-
width: 0;
|
|
9
|
-
background: hsl(35, 100%, 70%);
|
|
10
|
-
border-radius: 1em;
|
|
11
|
-
padding: 1em;
|
|
12
|
-
box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.tutorialBannerTitle {
|
|
16
|
-
margin-top: 0;
|
|
17
|
-
font-weight: 600;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.projectSelect {
|
|
21
|
-
display: flex;
|
|
22
|
-
align-items: center;
|
|
23
|
-
gap: 1em;
|
|
24
|
-
margin: 2em;
|
|
25
|
-
font-weight: 600;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.projectCard {
|
|
29
|
-
margin: 2em;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
.projectTitle {
|
|
33
|
-
font-size: 1.5em;
|
|
34
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { useCallback, useEffect, useState } from "react";
|
|
2
|
-
import CreateProjectButton from "./CreateProjectButton";
|
|
3
|
-
import CreateTaskButton from "./CreateTaskButton";
|
|
4
|
-
import DeleteProjectButton from "./DeleteProjectButton";
|
|
5
|
-
import css from "./Home.module.css";
|
|
6
|
-
import Layout from "./Layout";
|
|
7
|
-
import { MockProject } from "./mocks";
|
|
8
|
-
import ProjectSelect from "./ProjectSelect";
|
|
9
|
-
import TaskList from "./TaskList";
|
|
10
|
-
import useProjects from "./useProjects";
|
|
11
|
-
|
|
12
|
-
function Home() {
|
|
13
|
-
const [projectId, setProjectId] = useState<string | undefined>(undefined);
|
|
14
|
-
const { projects } = useProjects();
|
|
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
|
-
return (
|
|
29
|
-
<Layout>
|
|
30
|
-
<div className={css.tutorialBannerWrapper}>
|
|
31
|
-
<div className={css.tutorialBanner}>
|
|
32
|
-
<p className={css.tutorialBannerTitle}>
|
|
33
|
-
💡 Welcome to To Do app tutorial!
|
|
34
|
-
</p>
|
|
35
|
-
<p>
|
|
36
|
-
The To Do App is implemented with mock in-memory data.
|
|
37
|
-
<br />Can you solve how to switch it to use the Ontology SDK
|
|
38
|
-
instead?
|
|
39
|
-
</p>
|
|
40
|
-
</div>
|
|
41
|
-
</div>
|
|
42
|
-
<div className={css.projectSelect}>
|
|
43
|
-
<span>Project:</span>
|
|
44
|
-
<ProjectSelect
|
|
45
|
-
project={project}
|
|
46
|
-
projects={projects ?? []}
|
|
47
|
-
onSelectProject={handleSelectProject}
|
|
48
|
-
/>
|
|
49
|
-
<CreateProjectButton onProjectCreated={setProjectId} />
|
|
50
|
-
{project != null && <DeleteProjectButton project={project} />}
|
|
51
|
-
</div>
|
|
52
|
-
{project != null && (
|
|
53
|
-
<div className={css.projectCard} key={project.id}>
|
|
54
|
-
<h1 className={css.projectTitle}>{project.name}</h1>
|
|
55
|
-
<TaskList project={project} />
|
|
56
|
-
<CreateTaskButton project={project} />
|
|
57
|
-
</div>
|
|
58
|
-
)}
|
|
59
|
-
</Layout>
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export default Home;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import todoAppLogo from "/todo-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}>Ontology SDK Tutorial - Todo App</div>
|
|
15
|
-
</div>
|
|
16
|
-
{children}
|
|
17
|
-
</>
|
|
18
|
-
);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export default Layout;
|
|
@@ -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,38 +0,0 @@
|
|
|
1
|
-
import { 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
|
-
}
|
|
9
|
-
|
|
10
|
-
function TaskList({ project }: TaskListProps) {
|
|
11
|
-
const {
|
|
12
|
-
tasks,
|
|
13
|
-
isLoading: isLoadingTasks,
|
|
14
|
-
isError: isErrorTasks,
|
|
15
|
-
deleteTask,
|
|
16
|
-
} = useProjectTasks(project);
|
|
17
|
-
|
|
18
|
-
if (isErrorTasks) {
|
|
19
|
-
return <div className={css.taskList}>Error loading tasks!</div>;
|
|
20
|
-
} else if (isLoadingTasks) {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const data = tasks ?? [];
|
|
25
|
-
if (data.length === 0) {
|
|
26
|
-
return <div className={css.taskList}>No tasks found</div>;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return (
|
|
30
|
-
<ul className={css.taskList}>
|
|
31
|
-
{data.map((task) => (
|
|
32
|
-
<TaskListItem key={task.id} task={task} deleteTask={deleteTask} />
|
|
33
|
-
))}
|
|
34
|
-
</ul>
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export default TaskList;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { useCallback, useState } from "react";
|
|
2
|
-
import { MockTask } from "./mocks";
|
|
3
|
-
import css from "./TaskListItem.module.css";
|
|
4
|
-
|
|
5
|
-
interface TaskListItemProps {
|
|
6
|
-
task: MockTask;
|
|
7
|
-
deleteTask: (task: MockTask) => Promise<void>;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
function TaskListItem({ task, deleteTask }: TaskListItemProps) {
|
|
11
|
-
const [isDeleting, setIsDeleting] = useState(false);
|
|
12
|
-
const handleClick = useCallback(async () => {
|
|
13
|
-
setIsDeleting(true);
|
|
14
|
-
try {
|
|
15
|
-
await deleteTask(task);
|
|
16
|
-
} finally {
|
|
17
|
-
setIsDeleting(false);
|
|
18
|
-
}
|
|
19
|
-
}, [deleteTask, task]);
|
|
20
|
-
|
|
21
|
-
return (
|
|
22
|
-
<li>
|
|
23
|
-
<label
|
|
24
|
-
className={`${css.label} ${isDeleting ? css.checked : ""}`}
|
|
25
|
-
htmlFor={`${task.id}`}
|
|
26
|
-
>
|
|
27
|
-
<input
|
|
28
|
-
type="checkbox"
|
|
29
|
-
onChange={handleClick}
|
|
30
|
-
checked={isDeleting}
|
|
31
|
-
className={css.delete}
|
|
32
|
-
title="Delete task"
|
|
33
|
-
/>
|
|
34
|
-
{task.title}
|
|
35
|
-
</label>
|
|
36
|
-
</li>
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
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;
|