@powerhousedao/network-admin 0.0.16 → 0.0.18
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/dist/editors/network-admin/components/DriveExplorer.d.ts.map +1 -1
- package/dist/editors/network-admin/components/DriveExplorer.js +108 -341
- package/dist/editors/network-admin/components/EditorContainer.d.ts.map +1 -1
- package/dist/editors/network-admin/components/EditorContainer.js +1 -1
- package/dist/editors/network-admin/editor.d.ts +7 -2
- package/dist/editors/network-admin/editor.d.ts.map +1 -1
- package/dist/editors/network-admin/editor.js +6 -3
- package/dist/editors/network-admin/index.d.ts.map +1 -1
- package/dist/editors/network-admin/index.js +11 -0
- package/dist/editors/network-admin/utils/withDropZone.d.ts +4 -0
- package/dist/editors/network-admin/utils/withDropZone.d.ts.map +1 -0
- package/dist/editors/network-admin/utils/withDropZone.js +19 -0
- package/dist/editors/network-profile/editor.d.ts.map +1 -1
- package/dist/editors/network-profile/editor.js +40 -33
- package/dist/editors/payment-terms/editor.d.ts.map +1 -1
- package/dist/editors/payment-terms/editor.js +35 -24
- package/dist/editors/request-for-proposals/editor.d.ts.map +1 -1
- package/dist/editors/request-for-proposals/editor.js +3 -15
- package/dist/editors/workstream/editor.d.ts.map +1 -1
- package/dist/editors/workstream/editor.js +18 -19
- package/dist/style.css +316 -527
- package/package.json +14 -14
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DriveExplorer.d.ts","sourceRoot":"","sources":["../../../../editors/network-admin/components/DriveExplorer.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DriveExplorer.d.ts","sourceRoot":"","sources":["../../../../editors/network-admin/components/DriveExplorer.tsx"],"names":[],"mappings":"AA4BA;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,GAAG,2CAigBvC"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Button, CreateDocumentModal,
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { useCallback, useRef, useState, useMemo } from "react";
|
|
2
|
+
import { Button, CreateDocumentModal, } from "@powerhousedao/design-system";
|
|
3
|
+
import { Sidebar, SidebarProvider, } from "@powerhousedao/document-engineering";
|
|
4
|
+
import { addDocument, setSelectedNode, useAllFolderNodes, useFileChildNodes, useSelectedDrive, useSelectedFolder, dispatchActions, useSelectedDocument, useSelectedDriveDocuments, renameNode, showDeleteNodeModal, useSelectedDriveId, } from "@powerhousedao/reactor-browser";
|
|
5
|
+
import { useCallback, useRef, useState, useMemo, useEffect } from "react";
|
|
6
6
|
import { EditorContainer } from "./EditorContainer.js";
|
|
7
|
-
import { IsolatedSidebarProvider } from "./IsolatedSidebarProvider.js";
|
|
8
|
-
import { IsolatedSidebar } from "./IsolatedSidebar.js";
|
|
9
7
|
import { editWorkstream } from "../../../document-models/workstream/gen/creators.js";
|
|
10
8
|
/**
|
|
11
9
|
* Main drive explorer component with sidebar navigation and content area.
|
|
@@ -19,130 +17,74 @@ export function DriveExplorer(props) {
|
|
|
19
17
|
const [selectedRootNode, setSelectedRootNode] = useState("workstreams");
|
|
20
18
|
const [modalDocumentType, setModalDocumentType] = useState("powerhouse/workstream");
|
|
21
19
|
const selectedDocumentModel = useRef(null);
|
|
22
|
-
const editorModules = useEditorModules();
|
|
23
|
-
// Track the last created folder for drag and drop targeting
|
|
24
|
-
const [lastCreatedFolder, setLastCreatedFolder] = useState(undefined);
|
|
25
|
-
// === DRIVE CONTEXT HOOKS ===
|
|
26
|
-
// Core drive operations and document models
|
|
27
|
-
const { onAddFile, onAddFolder, onCopyNode, onDuplicateNode, onMoveNode, onRenameNode, showDeleteNodeModal, } = useDriveContext();
|
|
28
|
-
const { isAllowedToCreateDocuments } = useUserPermissions();
|
|
29
20
|
// === STATE MANAGEMENT HOOKS ===
|
|
30
21
|
// Core state hooks for drive navigation
|
|
31
22
|
const [selectedDrive] = useSelectedDrive(); // Currently selected drive
|
|
32
23
|
const selectedFolder = useSelectedFolder(); // Currently selected folder
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
|
|
24
|
+
const allDocuments = useSelectedDriveDocuments();
|
|
25
|
+
const selectedDriveId = useSelectedDriveId();
|
|
26
|
+
// Listen to global selected document state (for external editors like Scope of Work)
|
|
27
|
+
const [globalSelectedDocument] = useSelectedDocument();
|
|
36
28
|
// All folders for the sidebar tree view
|
|
37
29
|
const allFolders = useAllFolderNodes();
|
|
38
|
-
const folderChildren = useFolderChildNodes();
|
|
39
30
|
const fileChildren = useFileChildNodes();
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
31
|
+
const networkAdminDocuments = allDocuments?.filter((doc) => doc.header.documentType === "powerhouse/network-profile" ||
|
|
32
|
+
doc.header.documentType === "powerhouse/workstream" ||
|
|
33
|
+
doc.header.documentType === "powerhouse/scopeofwork" ||
|
|
34
|
+
doc.header.documentType === "powerhouse/rfp" ||
|
|
35
|
+
doc.header.documentType === "payment-terms");
|
|
36
|
+
// Sync global selected document with local activeDocumentId
|
|
37
|
+
// This makes setSelectedNode() trigger the EditorContainer to open
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (globalSelectedDocument?.header?.id) {
|
|
40
|
+
setActiveDocumentId(globalSelectedDocument.header.id);
|
|
41
|
+
}
|
|
42
|
+
}, [globalSelectedDocument]);
|
|
43
|
+
// Check if current active document is a Scope of Work (should show in full view)
|
|
44
|
+
const activeDoc = allDocuments?.find((doc) => doc.header.id === activeDocumentId);
|
|
45
|
+
const isScopeOfWorkFullView = activeDoc?.header.documentType === "powerhouse/scopeofwork";
|
|
46
|
+
// rename node
|
|
47
|
+
const onRenameNode = async (nodeId, newName) => {
|
|
48
|
+
const renamedNode = await renameNode(selectedDriveId || "", nodeId, newName);
|
|
49
|
+
if (renamedNode) {
|
|
50
|
+
console.log("Renamed node", renamedNode);
|
|
58
51
|
}
|
|
59
|
-
|
|
60
|
-
}, [fileChildren, allFolders]);
|
|
61
|
-
// === DROP HOOKS ===
|
|
62
|
-
const mostRecentWorkstreamFolder = getMostRecentWorkstreamFolder();
|
|
63
|
-
const dropTargetNode = lastCreatedFolder ||
|
|
64
|
-
mostRecentWorkstreamFolder ||
|
|
65
|
-
selectedFolder ||
|
|
66
|
-
undefined;
|
|
67
|
-
// Create a custom onAddFile wrapper that ensures the correct folder is used
|
|
68
|
-
const onAddFileWithTarget = useCallback((file, targetFolder) => {
|
|
69
|
-
console.log("onAddFileWithTarget called with:", {
|
|
70
|
-
file,
|
|
71
|
-
targetFolder,
|
|
72
|
-
dropTargetNode,
|
|
73
|
-
});
|
|
74
|
-
// Use the dropTargetNode as the folder, not the targetFolder parameter
|
|
75
|
-
return onAddFile(file, dropTargetNode);
|
|
76
|
-
}, [onAddFile, dropTargetNode]);
|
|
77
|
-
const { isDropTarget, dropProps } = useDrop({
|
|
78
|
-
node: dropTargetNode,
|
|
79
|
-
onAddFile: onAddFileWithTarget,
|
|
80
|
-
onCopyNode,
|
|
81
|
-
onMoveNode,
|
|
82
|
-
});
|
|
52
|
+
};
|
|
83
53
|
// check if workstream doc is created, set isWorkstreamCreated to true
|
|
84
|
-
const isWorkstreamCreated =
|
|
54
|
+
const isWorkstreamCreated = networkAdminDocuments?.some((doc) => doc.header.documentType === "powerhouse/workstream") || false;
|
|
85
55
|
//check if network profile doc is created, set isNetworkProfileCreated to true
|
|
86
|
-
const isNetworkProfileCreated =
|
|
87
|
-
// Convert
|
|
56
|
+
const isNetworkProfileCreated = networkAdminDocuments?.some((doc) => doc.header.documentType === "powerhouse/network-profile") || false;
|
|
57
|
+
// Convert network admin documents to SidebarNode format
|
|
88
58
|
const sidebarNodes = useMemo(() => {
|
|
59
|
+
// Group documents by type
|
|
60
|
+
const workstreamDocs = networkAdminDocuments?.filter((doc) => doc.header.documentType === "powerhouse/workstream") || [];
|
|
61
|
+
const scopeOfWorkDocs = networkAdminDocuments?.filter((doc) => doc.header.documentType === "powerhouse/scopeofwork") || [];
|
|
62
|
+
const rfpDocs = networkAdminDocuments?.filter((doc) => doc.header.documentType === "powerhouse/rfp") || [];
|
|
63
|
+
const paymentTermsDocs = networkAdminDocuments?.filter((doc) => doc.header.documentType === "payment-terms") || [];
|
|
64
|
+
const networkProfileDocs = networkAdminDocuments?.filter((doc) => doc.header.documentType === "powerhouse/network-profile") || [];
|
|
89
65
|
const workstreamsNode = {
|
|
90
66
|
id: "workstreams",
|
|
91
67
|
title: "Workstreams",
|
|
92
68
|
children: [
|
|
93
|
-
// Add
|
|
94
|
-
...
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
allFolders.some((subFolder) => subFolder.parentFolder === folder.id &&
|
|
103
|
-
file.parentFolder === subFolder.id)));
|
|
104
|
-
return hasNonNetworkProfileFiles;
|
|
105
|
-
})
|
|
106
|
-
.map((folder) => ({
|
|
107
|
-
id: folder.id,
|
|
108
|
-
title: folder.name,
|
|
109
|
-
children: [
|
|
110
|
-
// Add child folders
|
|
111
|
-
...allFolders
|
|
112
|
-
.filter((childFolder) => childFolder.parentFolder === folder.id &&
|
|
113
|
-
filesWithDocuments.some((file) => file.documentType !== "powerhouse/network-profile" &&
|
|
114
|
-
file.parentFolder === childFolder.id))
|
|
115
|
-
.map((childFolder) => ({
|
|
116
|
-
id: childFolder.id,
|
|
117
|
-
title: childFolder.name,
|
|
118
|
-
children: [
|
|
119
|
-
// Add files in this folder (exclude network-profile documents)
|
|
120
|
-
...filesWithDocuments
|
|
121
|
-
.filter((file) => file.parentFolder === childFolder.id &&
|
|
122
|
-
file.documentType !== "powerhouse/network-profile")
|
|
123
|
-
.map((file) => ({
|
|
124
|
-
id: `editor-${file.id}`,
|
|
125
|
-
title: `${file.state?.code || ""} - ${file.state?.title || file.name}`,
|
|
126
|
-
})),
|
|
127
|
-
],
|
|
128
|
-
})),
|
|
129
|
-
// Add files directly in this folder (exclude network-profile documents)
|
|
130
|
-
...filesWithDocuments
|
|
131
|
-
.filter((file) => file.parentFolder === folder.id &&
|
|
132
|
-
file.documentType !== "powerhouse/network-profile")
|
|
133
|
-
.map((file) => ({
|
|
134
|
-
id: `editor-${file.id}`,
|
|
135
|
-
title: `${file.state?.code || ""} - ${file.state?.title || file.name}`,
|
|
136
|
-
})),
|
|
137
|
-
],
|
|
69
|
+
// Add workstream documents
|
|
70
|
+
...workstreamDocs.map((doc) => ({
|
|
71
|
+
id: `editor-${doc.header.id}`,
|
|
72
|
+
title: `${doc.state?.global?.code || ""} - ${doc.state?.global?.title || doc.header.name}`,
|
|
73
|
+
})),
|
|
74
|
+
// Add scope of work documents
|
|
75
|
+
...scopeOfWorkDocs.map((doc) => ({
|
|
76
|
+
id: `editor-${doc.header.id}`,
|
|
77
|
+
title: `${doc.state?.global?.title || doc.header.name}`,
|
|
138
78
|
})),
|
|
139
|
-
// Add
|
|
140
|
-
...
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
79
|
+
// Add RFP documents
|
|
80
|
+
...rfpDocs.map((doc) => ({
|
|
81
|
+
id: `editor-${doc.header.id}`,
|
|
82
|
+
title: `${doc.state?.global?.code || ""} - ${doc.state?.global?.title || doc.header.name}`,
|
|
83
|
+
})),
|
|
84
|
+
// Add payment terms documents
|
|
85
|
+
...paymentTermsDocs.map((doc) => ({
|
|
86
|
+
id: `editor-${doc.header.id}`,
|
|
87
|
+
title: `${doc.state?.global?.code || ""} - ${doc.state?.global?.title || doc.header.name}`,
|
|
146
88
|
})),
|
|
147
89
|
],
|
|
148
90
|
};
|
|
@@ -150,66 +92,18 @@ export function DriveExplorer(props) {
|
|
|
150
92
|
id: "network-information",
|
|
151
93
|
title: "Network Information",
|
|
152
94
|
children: [
|
|
153
|
-
// Add
|
|
154
|
-
...
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
const hasNetworkProfileFiles = filesWithDocuments.some((file) => file.documentType === "powerhouse/network-profile" &&
|
|
158
|
-
(file.parentFolder === folder.id ||
|
|
159
|
-
allFolders.some((subFolder) => subFolder.parentFolder === folder.id &&
|
|
160
|
-
file.parentFolder === subFolder.id)));
|
|
161
|
-
return hasNetworkProfileFiles;
|
|
162
|
-
})
|
|
163
|
-
.map((folder) => ({
|
|
164
|
-
id: folder.id,
|
|
165
|
-
title: folder.name,
|
|
166
|
-
children: [
|
|
167
|
-
// Add child folders that contain network-profile documents
|
|
168
|
-
...allFolders
|
|
169
|
-
.filter((childFolder) => childFolder.parentFolder === folder.id &&
|
|
170
|
-
filesWithDocuments.some((file) => file.documentType === "powerhouse/network-profile" &&
|
|
171
|
-
file.parentFolder === childFolder.id))
|
|
172
|
-
.map((childFolder) => ({
|
|
173
|
-
id: childFolder.id,
|
|
174
|
-
title: childFolder.name,
|
|
175
|
-
children: [
|
|
176
|
-
// Add network-profile files in this folder
|
|
177
|
-
...filesWithDocuments
|
|
178
|
-
.filter((file) => file.documentType === "powerhouse/network-profile" &&
|
|
179
|
-
file.parentFolder === childFolder.id)
|
|
180
|
-
.map((file) => ({
|
|
181
|
-
id: `editor-${file.id}`,
|
|
182
|
-
title: `${file.name}`,
|
|
183
|
-
})),
|
|
184
|
-
],
|
|
185
|
-
})),
|
|
186
|
-
// Add network-profile files directly in this folder
|
|
187
|
-
...filesWithDocuments
|
|
188
|
-
.filter((file) => file.documentType === "powerhouse/network-profile" &&
|
|
189
|
-
file.parentFolder === folder.id)
|
|
190
|
-
.map((file) => ({
|
|
191
|
-
id: `editor-${file.id}`,
|
|
192
|
-
title: `${file.name}`,
|
|
193
|
-
})),
|
|
194
|
-
],
|
|
195
|
-
})),
|
|
196
|
-
// Add root-level network-profile files
|
|
197
|
-
...filesWithDocuments
|
|
198
|
-
.filter((file) => !file.parentFolder &&
|
|
199
|
-
file.documentType === "powerhouse/network-profile")
|
|
200
|
-
.map((file) => ({
|
|
201
|
-
id: `editor-${file.id}`,
|
|
202
|
-
title: `${file.name}`,
|
|
95
|
+
// Add network profile documents
|
|
96
|
+
...networkProfileDocs.map((doc) => ({
|
|
97
|
+
id: `editor-${doc.header.id}`,
|
|
98
|
+
title: doc.header.name,
|
|
203
99
|
})),
|
|
204
100
|
],
|
|
205
101
|
};
|
|
206
102
|
return [workstreamsNode, networkInfoNode];
|
|
207
|
-
}, [
|
|
103
|
+
}, [networkAdminDocuments]);
|
|
208
104
|
// Handle sidebar node selection
|
|
209
105
|
const handleActiveNodeChange = useCallback((nodeId) => {
|
|
210
106
|
console.log("nodeId", nodeId);
|
|
211
|
-
// Clear the last created folder when navigating to a different node
|
|
212
|
-
setLastCreatedFolder(undefined);
|
|
213
107
|
// Find the node by ID
|
|
214
108
|
const findNodeById = (nodes, id) => {
|
|
215
109
|
for (const node of nodes) {
|
|
@@ -239,16 +133,8 @@ export function DriveExplorer(props) {
|
|
|
239
133
|
else if (newNode.id.startsWith("editor-")) {
|
|
240
134
|
// Extract file ID from editor-{file.id} format
|
|
241
135
|
const fileId = newNode.id.replace("editor-", "");
|
|
242
|
-
const file = fileChildren.find((f) => f.id === fileId);
|
|
243
136
|
setActiveDocumentId(fileId);
|
|
244
137
|
}
|
|
245
|
-
else {
|
|
246
|
-
// Find if it's a folder
|
|
247
|
-
const folder = allFolders.find((f) => f.id === newNode.id);
|
|
248
|
-
if (folder) {
|
|
249
|
-
setActiveDocumentId(undefined);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
138
|
}, [
|
|
253
139
|
allFolders,
|
|
254
140
|
fileChildren,
|
|
@@ -266,7 +152,7 @@ export function DriveExplorer(props) {
|
|
|
266
152
|
nodeType = "workstreams";
|
|
267
153
|
}
|
|
268
154
|
else if (activeNodeId === "network-information") {
|
|
269
|
-
nodeType = "
|
|
155
|
+
nodeType = "workstreams";
|
|
270
156
|
}
|
|
271
157
|
else if (activeNodeId.startsWith("editor-")) {
|
|
272
158
|
nodeType = "file";
|
|
@@ -289,152 +175,45 @@ export function DriveExplorer(props) {
|
|
|
289
175
|
}
|
|
290
176
|
switch (nodeType) {
|
|
291
177
|
case "workstreams":
|
|
292
|
-
return (
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
alert("Failed to rename document. Please try again.");
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
}, className: "px-2 py-1 bg-yellow-500 text-white rounded text-sm hover:bg-yellow-600", children: "Edit" }), _jsx("button", { onClick: () => showDeleteNodeModal(fileNode), className: "px-2 py-1 bg-red-500 text-white rounded text-sm hover:bg-red-600", children: "Delete" })] })] }, fileNode.id))) })] })] }) }))] }));
|
|
331
|
-
case "folder":
|
|
332
|
-
const folder = allFolders.find((f) => f.id === actualId);
|
|
333
|
-
if (!folder)
|
|
334
|
-
return null;
|
|
335
|
-
return (_jsx("div", { className: "p-4", children: _jsxs("div", { className: "space-y-6", children: [_jsx("div", { className: "space-y-3", children: _jsxs("div", { className: "flex items-center justify-between", children: [_jsxs("h2", { className: "text-lg font-semibold", children: ["Contents of \"", folder.name, "\""] }), _jsx("button", { onClick: () => {
|
|
336
|
-
setSelectedNode(selectedDrive?.header.id);
|
|
337
|
-
}, className: "rounded bg-gray-500 px-3 py-1 text-sm text-white hover:bg-gray-600", children: "Back" }), isAllowedToCreateDocuments && (_jsx("button", { onClick: () => handleCreateFolder(), className: "rounded bg-blue-500 px-3 py-1 text-sm text-white hover:bg-blue-600", children: "+ New Folder" }))] }) }), folderChildren.length > 0 && (_jsxs("div", { children: [_jsx("h3", { className: "mb-2 text-sm font-medium text-gray-500", children: "\uD83D\uDCC1 Folders" }), _jsx("div", { className: "grid grid-cols-1 gap-2", children: folderChildren.map((folderNode) => folderNode && folderNode.id ? (_jsxs("div", { className: "p-2 border rounded", children: [_jsxs("div", { className: "font-medium", children: ["\uD83D\uDCC1 ", folderNode.name] }), _jsx("div", { className: "text-sm text-gray-500", children: "Folder" }), _jsxs("div", { className: "mt-2 flex gap-2", children: [_jsx("button", { onClick: () => setSelectedNode(folderNode), className: "px-2 py-1 bg-blue-500 text-white rounded text-sm hover:bg-blue-600", children: "Open" }), _jsx("button", { onClick: () => {
|
|
338
|
-
const newName = prompt("Enter new name:", folderNode.name || "");
|
|
339
|
-
if (newName &&
|
|
340
|
-
newName.trim() &&
|
|
341
|
-
newName !== folderNode.name) {
|
|
342
|
-
try {
|
|
343
|
-
onRenameNode(newName.trim(), folderNode);
|
|
344
|
-
}
|
|
345
|
-
catch (error) {
|
|
346
|
-
console.error("Failed to rename:", error);
|
|
347
|
-
alert("Failed to rename folder. Please try again.");
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
}, className: "px-2 py-1 bg-yellow-500 text-white rounded text-sm hover:bg-yellow-600", children: "Edit" }), _jsx("button", { onClick: () => showDeleteNodeModal(folderNode), className: "px-2 py-1 bg-red-500 text-white rounded text-sm hover:bg-red-600", children: "Delete" })] })] }, folderNode.id)) : null) })] })), fileChildren.length > 0 ? (_jsxs("div", { children: [_jsx("h3", { className: "mb-2 text-sm font-medium text-gray-500", children: "\uD83D\uDCC4 Documents" }), _jsx("div", { className: "grid grid-cols-1 gap-2", children: fileChildren.map((fileNode) => (_jsxs("div", { className: "p-2 border rounded", children: [_jsx("div", { className: "font-medium", children: fileNode.name }), _jsx("div", { className: "text-sm text-gray-500", children: fileNode.documentType }), _jsxs("div", { className: "mt-2 flex gap-2", children: [_jsx("button", { onClick: () => {
|
|
351
|
-
setSelectedNode(fileNode);
|
|
352
|
-
setActiveDocumentId(fileNode.id);
|
|
353
|
-
}, className: "px-2 py-1 bg-blue-500 text-white rounded text-sm hover:bg-blue-600", children: "Open" }), _jsx("button", { onClick: () => {
|
|
354
|
-
if (!fileNode || !fileNode.id)
|
|
355
|
-
return;
|
|
356
|
-
const newName = prompt("Enter new name:", fileNode.name || "");
|
|
357
|
-
if (newName &&
|
|
358
|
-
newName.trim() &&
|
|
359
|
-
newName !== fileNode.name) {
|
|
360
|
-
try {
|
|
361
|
-
onRenameNode(newName.trim(), fileNode);
|
|
362
|
-
}
|
|
363
|
-
catch (error) {
|
|
364
|
-
alert("Failed to rename document. Please try again.");
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
}, className: "px-2 py-1 bg-yellow-500 text-white rounded text-sm hover:bg-yellow-600", children: "Edit" }), _jsx("button", { onClick: () => showDeleteNodeModal(fileNode), className: "px-2 py-1 bg-red-500 text-white rounded text-sm hover:bg-red-600", children: "Delete" })] })] }, fileNode.id))) })] })) : null, folderChildren.length === 0 && fileChildren.length === 0 && (_jsxs("div", { className: "py-12 text-center text-gray-500", children: [_jsx("p", { className: "text-lg", children: "\uD83D\uDDC2\uFE0F This folder is empty" }), _jsx("p", { className: "mt-2 text-sm", children: "Create your first document or folder below" })] }))] }) }));
|
|
368
|
-
case "network-information":
|
|
369
|
-
return (_jsxs("div", { className: "mt-20 p-4 flex flex-col items-center justify-center", children: [_jsxs("div", { className: "space-y-6 flex flex-col items-center justify-center", children: [_jsx("h1", { className: "text-2xl font-bold", children: "Network Information" }), _jsx("p", { children: "Create a new network profile to get started, or select an existing network profile from the left sidebar" }), _jsx("div", { className: "flex gap-3", children: _jsx(Button, { color: "dark", size: "medium", className: "cursor-pointer hover:bg-gray-600 hover:text-white", title: "Create Network Profile Document", "aria-description": "Create Network Profile Document", onClick: () => {
|
|
370
|
-
setModalDocumentType("powerhouse/network-profile");
|
|
371
|
-
setOpenModal(true);
|
|
372
|
-
}, disabled: isNetworkProfileCreated, children: _jsx("span", { children: "Create Network Profile Document" }) }) })] }), (folderChildren.length > 0 || fileChildren.length > 0) && (_jsx("div", { className: "mt-10", children: _jsxs("div", { className: "grid grid-cols-2 gap-6", children: [_jsxs("div", { children: [_jsx("h3", { className: "mb-2 text-sm font-medium text-gray-500", children: "\uD83D\uDCC1 Network Profile Folders" }), _jsx("div", { className: "space-y-2", children: folderChildren
|
|
373
|
-
.filter((folder) => {
|
|
374
|
-
// Only show folders that contain network-profile documents
|
|
375
|
-
return filesWithDocuments.some((file) => file.documentType ===
|
|
376
|
-
"powerhouse/network-profile" &&
|
|
377
|
-
(file.parentFolder === folder.id ||
|
|
378
|
-
allFolders.some((subFolder) => subFolder.parentFolder === folder.id &&
|
|
379
|
-
file.parentFolder === subFolder.id)));
|
|
380
|
-
})
|
|
381
|
-
.map((folderNode) => folderNode && folderNode.id ? (_jsxs("div", { className: "p-2 border rounded", children: [_jsxs("div", { className: "font-medium", children: ["\uD83D\uDCC1 ", folderNode.name] }), _jsx("div", { className: "text-sm text-gray-500", children: "Network Profile Folder" }), _jsxs("div", { className: "mt-2 flex gap-2", children: [_jsx("button", { onClick: () => setSelectedNode(folderNode), className: "px-2 py-1 bg-blue-500 text-white rounded text-sm hover:bg-blue-600", children: "Open" }), _jsx("button", { onClick: () => {
|
|
382
|
-
const newName = prompt("Enter new name:", folderNode.name || "");
|
|
383
|
-
if (newName &&
|
|
384
|
-
newName.trim() &&
|
|
385
|
-
newName !== folderNode.name) {
|
|
386
|
-
try {
|
|
387
|
-
onRenameNode(newName.trim(), folderNode);
|
|
388
|
-
}
|
|
389
|
-
catch (error) {
|
|
390
|
-
console.error("Failed to rename:", error);
|
|
391
|
-
alert("Failed to rename folder. Please try again.");
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
}, className: "px-2 py-1 bg-yellow-500 text-white rounded text-sm hover:bg-blue-600", children: "Edit" }), _jsx("button", { onClick: () => showDeleteNodeModal(folderNode), className: "px-2 py-1 bg-red-500 text-white rounded text-sm hover:bg-red-600", children: "Delete" })] })] }, folderNode.id)) : null) })] }), _jsxs("div", { children: [_jsx("h3", { className: "mb-2 text-sm font-medium text-gray-500", children: "\uD83C\uDF10 Network Profile Documents" }), _jsx("div", { className: "space-y-2", children: filesWithDocuments
|
|
395
|
-
.filter((file) => file.documentType === "powerhouse/network-profile")
|
|
396
|
-
.map((fileNode) => (_jsxs("div", { className: "p-2 border rounded", children: [_jsxs("div", { className: "font-medium", children: ["\uD83C\uDF10 ", fileNode.name] }), _jsx("div", { className: "text-sm text-gray-500", children: "Network Profile" }), _jsxs("div", { className: "mt-2 flex gap-2", children: [_jsx("button", { onClick: () => {
|
|
397
|
-
setSelectedNode(fileNode);
|
|
398
|
-
setActiveDocumentId(fileNode.id);
|
|
399
|
-
}, className: "px-2 py-1 bg-blue-500 text-white rounded text-sm hover:bg-blue-600", children: "Open" }), _jsx("button", { onClick: () => {
|
|
400
|
-
if (!fileNode || !fileNode.id)
|
|
401
|
-
return;
|
|
402
|
-
const newName = prompt("Enter new name:", fileNode.name || "");
|
|
403
|
-
if (newName &&
|
|
404
|
-
newName.trim() &&
|
|
405
|
-
newName !== fileNode.name) {
|
|
406
|
-
try {
|
|
407
|
-
onRenameNode(newName.trim(), fileNode);
|
|
408
|
-
}
|
|
409
|
-
catch (error) {
|
|
410
|
-
alert("Failed to rename document. Please try again.");
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
}, className: "px-2 py-1 bg-yellow-500 text-white rounded text-sm hover:bg-blue-600", children: "Edit" }), _jsx("button", { onClick: () => showDeleteNodeModal(fileNode), className: "px-2 py-1 bg-red-500 text-white rounded text-sm hover:bg-red-600", children: "Delete" })] })] }, fileNode.id))) })] })] }) })), folderChildren.length === 0 && fileChildren.length === 0 && (_jsxs("div", { className: "py-12 text-center text-gray-500", children: [_jsx("p", { className: "text-lg", children: "\uD83C\uDF10 No network profiles yet" }), _jsx("p", { className: "mt-2 text-sm", children: "Create your first network profile above" })] }))] }));
|
|
178
|
+
return (_jsx("div", { className: "w-full h-full p-6 overflow-auto", children: _jsxs("div", { className: "max-w-7xl mx-auto", children: [_jsxs("div", { className: "space-y-6 flex flex-col items-center justify-center mb-10", children: [_jsx("h1", { className: "text-2xl font-bold", children: "Welcome to the Network Admin" }), _jsx("p", { className: "text-center", children: "Create a new workstream to get started, or select an existing workstream on the left" }), _jsxs("div", { className: "flex flex-wrap gap-3 justify-center", children: [_jsx(Button, { color: "dark" // Customize button appearance
|
|
179
|
+
, size: "medium", className: "cursor-pointer hover:bg-gray-600 hover:text-white", title: "Create Workstream Document", "aria-description": "Create Workstream Document", onClick: () => {
|
|
180
|
+
setModalDocumentType("powerhouse/workstream");
|
|
181
|
+
setOpenModal(true);
|
|
182
|
+
}, disabled: isWorkstreamCreated, children: _jsx("span", { children: "Create Workstream Document" }) }), _jsx(Button, { color: "dark" // Customize button appearance
|
|
183
|
+
, size: "medium", className: "cursor-pointer hover:bg-gray-600 hover:text-white", title: "Create Network Profile Document", "aria-description": "Create Network Profile Document", onClick: () => {
|
|
184
|
+
setModalDocumentType("powerhouse/network-profile");
|
|
185
|
+
setOpenModal(true);
|
|
186
|
+
}, disabled: isNetworkProfileCreated, children: _jsx("span", { children: "Create Network Profile Document" }) })] })] }), networkAdminDocuments && networkAdminDocuments.length > 0 && (_jsxs("div", { className: "w-full", children: [_jsx("h3", { className: "mb-4 text-lg font-medium text-gray-700", children: "\uD83D\uDCC4 Documents" }), _jsx("div", { className: "overflow-x-auto rounded-lg border border-gray-200 shadow-sm", children: _jsxs("table", { className: "w-full bg-white", children: [_jsx("thead", { className: "bg-gray-50", children: _jsxs("tr", { children: [_jsx("th", { className: "px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider w-1/4", children: "Name" }), _jsx("th", { className: "px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider w-1/4", children: "Type" }), _jsx("th", { className: "px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider w-1/4", children: "Actions" })] }) }), _jsx("tbody", { className: "bg-white divide-y divide-gray-200", children: networkAdminDocuments.map((document) => {
|
|
187
|
+
// Find the corresponding file node for actions
|
|
188
|
+
const fileNode = fileChildren?.find((file) => file.id === document.header.id);
|
|
189
|
+
return (_jsxs("tr", { className: "hover:bg-gray-50 transition-colors", children: [_jsx("td", { className: "px-2 py-2", children: _jsx("div", { className: "text-sm font-medium text-gray-900 truncate max-w-xs", title: document.header.name, children: document.header.name }) }), _jsx("td", { className: "px-2 py-2", children: _jsx("div", { className: "text-sm text-gray-500 truncate max-w-xs", title: document.header.documentType, children: document.header.documentType }) }), _jsx("td", { className: "px-2 py-2", children: _jsxs("div", { className: "flex gap-2 flex-wrap", children: [_jsx("button", { onClick: () => {
|
|
190
|
+
if (fileNode) {
|
|
191
|
+
setSelectedNode(fileNode);
|
|
192
|
+
}
|
|
193
|
+
}, className: "px-3 py-1.5 bg-blue-500 text-white rounded text-xs font-medium hover:bg-blue-600 transition-colors whitespace-nowrap", children: "Open" }), _jsx("button", { onClick: async () => {
|
|
194
|
+
if (!fileNode || !fileNode.id)
|
|
195
|
+
return;
|
|
196
|
+
const newName = prompt("Enter new name:", document.header.name || "");
|
|
197
|
+
if (newName &&
|
|
198
|
+
newName.trim() &&
|
|
199
|
+
newName !== document.header.name) {
|
|
200
|
+
try {
|
|
201
|
+
await onRenameNode(fileNode.id || "", newName.trim());
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
console.error("Failed to rename document", error);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}, className: "px-3 py-1.5 bg-yellow-500 text-white rounded text-xs font-medium hover:bg-yellow-600 transition-colors whitespace-nowrap", children: "Edit" }), _jsx("button", { onClick: () => {
|
|
208
|
+
if (fileNode) {
|
|
209
|
+
showDeleteNodeModal(fileNode.id || "");
|
|
210
|
+
}
|
|
211
|
+
}, className: "px-3 py-1.5 bg-red-500 text-white rounded text-xs font-medium hover:bg-red-600 transition-colors whitespace-nowrap", children: "Delete" })] }) })] }, document.header.id));
|
|
212
|
+
}) })] }) })] }))] }) }));
|
|
414
213
|
default:
|
|
415
214
|
return _jsxs("div", { children: ["Unknown node type: ", nodeType] });
|
|
416
215
|
}
|
|
417
216
|
};
|
|
418
|
-
// Handle folder creation with optional name parameter
|
|
419
|
-
const handleCreateFolder = useCallback(async (folderName) => {
|
|
420
|
-
let name = folderName;
|
|
421
|
-
// If no name provided, prompt for it (for manual folder creation)
|
|
422
|
-
if (!name) {
|
|
423
|
-
const promptResult = prompt("Enter folder name:");
|
|
424
|
-
name = promptResult || undefined;
|
|
425
|
-
}
|
|
426
|
-
if (name?.trim()) {
|
|
427
|
-
try {
|
|
428
|
-
const createdFolder = await onAddFolder(name.trim(), selectedFolder);
|
|
429
|
-
// Track the created folder for drag and drop targeting
|
|
430
|
-
console.log("Created manual folder:", createdFolder);
|
|
431
|
-
setLastCreatedFolder(createdFolder);
|
|
432
|
-
}
|
|
433
|
-
catch (error) {
|
|
434
|
-
console.error("Failed to create folder:", error);
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
}, [onAddFolder, selectedFolder]);
|
|
438
217
|
// Handle document creation from modal
|
|
439
218
|
const onCreateDocument = useCallback(async (fileName) => {
|
|
440
219
|
setOpenModal(false);
|
|
@@ -446,14 +225,8 @@ export function DriveExplorer(props) {
|
|
|
446
225
|
: "workstream-editor";
|
|
447
226
|
console.log(`Creating ${documentType} document: ${fileName}`);
|
|
448
227
|
try {
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
folder = await onAddFolder(fileName, undefined);
|
|
452
|
-
// Track the created folder for drag and drop targeting
|
|
453
|
-
console.log("Created workstream folder:", folder);
|
|
454
|
-
setLastCreatedFolder(folder);
|
|
455
|
-
}
|
|
456
|
-
const node = await addDocument(selectedDrive?.header.id || "", fileName, documentType, folder?.id, undefined, undefined, editorType);
|
|
228
|
+
const node = await addDocument(selectedDrive?.header.id || "", fileName, documentType, undefined, // creating in root folder
|
|
229
|
+
undefined, undefined, editorType);
|
|
457
230
|
if (!node?.id) {
|
|
458
231
|
console.error("Error creating document", fileName);
|
|
459
232
|
return;
|
|
@@ -483,22 +256,16 @@ export function DriveExplorer(props) {
|
|
|
483
256
|
selectedFolder?.id,
|
|
484
257
|
modalDocumentType,
|
|
485
258
|
]);
|
|
486
|
-
// === DOCUMENT EDITOR DATA ===
|
|
487
|
-
// Filter available document types here if needed
|
|
488
|
-
const documentModelModules = useDocumentModelModules();
|
|
489
|
-
// Get active document and its editor components
|
|
490
|
-
const activeDocument = activeDocumentId
|
|
491
|
-
? fileChildren.find((file) => file.id === activeDocumentId)
|
|
492
|
-
: undefined;
|
|
493
|
-
const documentModelModule = activeDocument
|
|
494
|
-
? documentModelModules?.find((m) => m.documentModel.id === activeDocument.documentType)
|
|
495
|
-
: null;
|
|
496
|
-
const editorModule = activeDocument
|
|
497
|
-
? editorModules?.find((e) => e.documentTypes.includes(activeDocument.documentType))
|
|
498
|
-
: null;
|
|
499
259
|
// === RENDER ===
|
|
500
|
-
return (_jsx(
|
|
260
|
+
return (_jsx(SidebarProvider, { nodes: sidebarNodes, children: isScopeOfWorkFullView && activeDocumentId ? (_jsx("div", { className: "h-full w-full", children: _jsx(EditorContainer, { handleClose: () => {
|
|
261
|
+
setActiveDocumentId(undefined);
|
|
262
|
+
setSelectedNode(undefined); // Clear global selection
|
|
263
|
+
}, hideToolbar: false, activeDocumentId: activeDocumentId, setActiveDocumentId: setActiveDocumentId }) })) : (
|
|
264
|
+
/* === NORMAL VIEW WITH SIDEBAR === */
|
|
265
|
+
_jsxs("div", { className: "flex h-full", children: [_jsx(Sidebar, { className: String.raw `
|
|
266
|
+
[&_.sidebar\\_\\_item--active]:bg-yellow-500
|
|
267
|
+
`, nodes: sidebarNodes, activeNodeId: selectedFolder?.id || activeDocumentId, onActiveNodeChange: (node) => handleActiveNodeChange(node.id), sidebarTitle: "Network Admin", showSearchBar: true, allowPinning: true, resizable: true, initialWidth: 300, maxWidth: 500, enableMacros: 2, handleOnTitleClick: () => {
|
|
501
268
|
setActiveDocumentId(undefined);
|
|
502
269
|
setSelectedRootNode("workstreams");
|
|
503
|
-
} }), _jsx("div", { className: "flex-1 overflow-y-auto", children: _jsx("div", {
|
|
270
|
+
} }), _jsx("div", { className: "flex-1 overflow-y-auto", children: _jsx("div", { className: "h-full", children: activeDocumentId ? (_jsx(EditorContainer, { handleClose: () => setActiveDocumentId(undefined), hideToolbar: false, activeDocumentId: activeDocumentId, setActiveDocumentId: setActiveDocumentId })) : (displayActiveNode(selectedFolder?.id || selectedRootNode)) }) }), _jsx(CreateDocumentModal, { onContinue: onCreateDocument, onOpenChange: (open) => setOpenModal(open), open: openModal })] })) }));
|
|
504
271
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorContainer.d.ts","sourceRoot":"","sources":["../../../../editors/network-admin/components/EditorContainer.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EditorContainer.d.ts","sourceRoot":"","sources":["../../../../editors/network-admin/components/EditorContainer.tsx"],"names":[],"mappings":"AAqBA;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,OAAO;IACrC,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,mBAAmB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CAC3C,4CAgMA,CAAC"}
|
|
@@ -95,5 +95,5 @@ export const EditorContainer = (props) => {
|
|
|
95
95
|
_jsxs(Suspense, { fallback: loadingContent, children: [!hideToolbar && (_jsx(DocumentToolbar, { onClose: handleClose, onExport: onExport, onShowRevisionHistory: () => setShowRevisionHistory(true), onSwitchboardLinkClick: () => { }, title: selectedDocument.header.name, timelineButtonVisible: editorModule.config.timelineEnabled, timelineItems: timelineItems.data, onTimelineItemClick: setSelectedTimelineItem })), _jsx(EditorComponent, { context: {
|
|
96
96
|
readMode: !!selectedTimelineItem,
|
|
97
97
|
selectedTimelineRevision: getRevisionFromDate(selectedTimelineItem?.startDate, selectedTimelineItem?.endDate, selectedDocument.operations.global),
|
|
98
|
-
}, dispatch: dispatch, document: selectedDocument, error: console.error, createRfp: createRfpDocument, setActiveDocumentId: setActiveDocumentId, createSow: createSowDocument, createPaymentTerms: createPaymentTermsDocument })] })) }));
|
|
98
|
+
}, dispatch: dispatch, document: selectedDocument, error: console.error, createRfp: createRfpDocument, setActiveDocumentId: setActiveDocumentId, createSow: createSowDocument, createPaymentTerms: createPaymentTermsDocument, documentId: selectedDocument.header.id })] })) }));
|
|
99
99
|
};
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
+
import { type DriveEditorProps } from "@powerhousedao/reactor-browser";
|
|
2
|
+
export type IProps = DriveEditorProps & {
|
|
3
|
+
context?: any;
|
|
4
|
+
document?: any;
|
|
5
|
+
};
|
|
1
6
|
/**
|
|
2
7
|
* Base editor component that renders the drive explorer interface.
|
|
3
8
|
* Customize document opening behavior and drive-level actions here.
|
|
4
9
|
*/
|
|
5
|
-
export declare function BaseEditor(props:
|
|
10
|
+
export declare function BaseEditor(props: IProps): import("react/jsx-runtime").JSX.Element;
|
|
6
11
|
/**
|
|
7
12
|
* Main editor entry point with required providers.
|
|
8
13
|
*/
|
|
9
|
-
export default function Editor(props:
|
|
14
|
+
export default function Editor(props: IProps): import("react/jsx-runtime").JSX.Element;
|
|
10
15
|
//# sourceMappingURL=editor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../../editors/network-admin/editor.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../../editors/network-admin/editor.tsx"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,gCAAgC,CAAC;AAIxC,MAAM,MAAM,MAAM,GAAG,gBAAgB,GAAG;IACtC,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,QAAQ,CAAC,EAAE,GAAG,CAAC;CAChB,CAAC;AAEF;;;GAGG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,2CAOvC;AAKD;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,KAAK,EAAE,MAAM,2CAW3C"}
|