@powerhousedao/codegen 4.1.0-dev.88 → 4.1.0-dev.89

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.
@@ -2,18 +2,27 @@
2
2
  to: "<%= rootDir %>/<%= h.changeCase.param(name) %>/editor.tsx"
3
3
  unless_exists: true
4
4
  ---
5
+ import { DocumentToolbar } from "@powerhousedao/design-system";
5
6
  import {
6
7
  Button,
7
8
  Form,
8
9
  FormLabel,
9
10
  StringField,
10
11
  } from "@powerhousedao/document-engineering";
12
+ import {
13
+ setSelectedNode,
14
+ useParentFolderForSelectedNode,
15
+ } from "@powerhousedao/reactor-browser";
11
16
  <% if(!documentType){ %>import { useSelectedDocument } from "@powerhousedao/reactor-browser";<% } else { %>import { useSelected<%= documentType.name %>Document %>} from "../hooks/use<%= documentType.name %>Document%>.js";<% } %>
12
17
  import { setName } from "document-model";<% if(documentType) { %>
13
18
  import { actions } from "<%= documentType.importPath %>";<% } %>
14
19
 
15
20
  export function Editor() {
16
21
  const [document, dispatch] = <% if(documentType) { %>useSelected<%= documentType.name %>Document()<% } else { %>useSelectedDocument()<% } %>;
22
+
23
+ // Get the parent folder node for the currently selected node
24
+ const parentFolder = useParentFolderForSelectedNode();
25
+
17
26
  <% if(!documentType){ %>
18
27
  if (!document) {
19
28
  return null;
@@ -25,68 +34,77 @@ export function Editor() {
25
34
  }
26
35
  }
27
36
 
37
+ // Set the selected node to the parent folder node (close the editor)
38
+ function handleClose() {
39
+ setSelectedNode(parentFolder?.id);
40
+ }
41
+
28
42
  return (
29
- <div className="ph-default-styles py-10 text-center">
30
- <div className="inline-flex flex-col gap-10 text-start">
31
-
32
- {/* Edit document name form */}
33
- <section className="flex justify-between">
34
- <h1 className="text-start">{document.header.name}</h1>
35
- <div className="flex flex-col space-y-2">
36
- <Form
37
- onSubmit={handleSetName}
38
- defaultValues={{ name: document.header.name }}
39
- className="flex flex-col gap-3 pt-2"
40
- >
41
- <div className="flex items-end gap-3">
42
- <div>
43
- <FormLabel htmlFor="name">
44
- <b className="mb-1">Change document name</b>
45
- </FormLabel>
46
- <StringField
47
- name="name"
48
- placeholder="Enter document name"
49
- className="mt-1"
50
- />
43
+ <div>
44
+ <DocumentToolbar document={document} onClose={handleClose} />
45
+ <div className="ph-default-styles py-10 text-center">
46
+ <div className="inline-flex flex-col gap-10 text-start">
47
+ {/* Edit document name form */}
48
+ <section className="flex justify-between">
49
+ <h1 className="text-start">{document.header.name}</h1>
50
+ <div className="flex flex-col space-y-2">
51
+ <Form
52
+ onSubmit={handleSetName}
53
+ defaultValues={{ name: document.header.name }}
54
+ className="flex flex-col gap-3 pt-2"
55
+ >
56
+ <div className="flex items-end gap-3">
57
+ <div>
58
+ <FormLabel htmlFor="name">
59
+ <b className="mb-1">Change document name</b>
60
+ </FormLabel>
61
+ <StringField
62
+ name="name"
63
+ placeholder="Enter document name"
64
+ className="mt-1"
65
+ />
66
+ </div>
67
+ <Button type="submit">Edit</Button>
51
68
  </div>
52
- <Button type="submit">Edit</Button>
53
- </div>
54
- </Form>
55
- </div>
56
- </section>
69
+ </Form>
70
+ </div>
71
+ </section>
57
72
 
58
- {/* Document metadata */}
59
- <section>
60
- <ul className="grid grid-cols-2 gap-x-4 gap-y-1 text-gray-700">
61
- <li>
62
- <b className="mr-1">Id:</b>
63
- {document.header.id}
64
- </li>
65
- <li>
66
- <b className="mr-1">Created:</b>
67
- {new Date(document.header.createdAtUtcIso).toLocaleString()}
68
- </li>
69
- <li>
70
- <b className="mr-1">Type:</b>
71
- {document.header.documentType}
72
- </li>
73
- <li>
74
- <b className="mr-1">Last Modified:</b>
75
- {new Date(document.header.lastModifiedAtUtcIso).toLocaleString()}
76
- </li>
77
- </ul>
78
- </section>
73
+ {/* Document metadata */}
74
+ <section>
75
+ <ul className="grid grid-cols-2 gap-x-4 gap-y-1 text-gray-700">
76
+ <li>
77
+ <b className="mr-1">Id:</b>
78
+ {document.header.id}
79
+ </li>
80
+ <li>
81
+ <b className="mr-1">Created:</b>
82
+ {new Date(document.header.createdAtUtcIso).toLocaleString()}
83
+ </li>
84
+ <li>
85
+ <b className="mr-1">Type:</b>
86
+ {document.header.documentType}
87
+ </li>
88
+ <li>
89
+ <b className="mr-1">Last Modified:</b>
90
+ {new Date(
91
+ document.header.lastModifiedAtUtcIso,
92
+ ).toLocaleString()}
93
+ </li>
94
+ </ul>
95
+ </section>
79
96
 
80
- {/* Document state */}
81
- <section className="inline-block">
82
- <h2 className="mb-4">Document state</h2>
83
- <textarea
84
- rows={10}
85
- readOnly
86
- value={JSON.stringify(document.state, null, 2)}
87
- className="font-mono"
88
- ></textarea>
89
- </section>
97
+ {/* Document state */}
98
+ <section className="inline-block">
99
+ <h2 className="mb-4">Document state</h2>
100
+ <textarea
101
+ rows={10}
102
+ readOnly
103
+ value={JSON.stringify(document.state, null, 2)}
104
+ className="font-mono"
105
+ ></textarea>
106
+ </section>
107
+ </div>
90
108
  </div>
91
109
  </div>
92
110
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerhousedao/codegen",
3
- "version": "4.1.0-dev.88",
3
+ "version": "4.1.0-dev.89",
4
4
  "license": "AGPL-3.0-only",
5
5
  "private": false,
6
6
  "type": "module",
@@ -31,11 +31,11 @@
31
31
  "kysely-pglite": "^0.6.1",
32
32
  "prettier": "^3.4.2",
33
33
  "ts-morph": "^26.0.0",
34
- "@powerhousedao/common": "4.1.0-dev.88",
35
- "@powerhousedao/config": "4.1.0-dev.88",
36
- "@powerhousedao/design-system": "4.1.0-dev.88",
37
- "@powerhousedao/reactor-browser": "4.1.0-dev.88",
38
- "document-model": "4.1.0-dev.88"
34
+ "@powerhousedao/config": "4.1.0-dev.89",
35
+ "@powerhousedao/design-system": "4.1.0-dev.89",
36
+ "document-model": "4.1.0-dev.89",
37
+ "@powerhousedao/reactor-browser": "4.1.0-dev.89",
38
+ "@powerhousedao/common": "4.1.0-dev.89"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@graphql-codegen/core": "^4.0.2",
@@ -49,7 +49,7 @@
49
49
  "react-dom": "^19.2.0",
50
50
  "vitest": "^3.2.4",
51
51
  "zod": "^3.24.3",
52
- "document-drive": "4.1.0-dev.88"
52
+ "document-drive": "4.1.0-dev.89"
53
53
  },
54
54
  "scripts": {
55
55
  "tsc": "tsc",