@powerhousedao/network-admin 0.0.15 → 0.0.17

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.
@@ -1 +1 @@
1
- {"version":3,"file":"DriveExplorer.d.ts","sourceRoot":"","sources":["../../../../editors/network-admin/components/DriveExplorer.tsx"],"names":[],"mappings":"AAyCA;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,GAAG,2CAylCvC"}
1
+ {"version":3,"file":"DriveExplorer.d.ts","sourceRoot":"","sources":["../../../../editors/network-admin/components/DriveExplorer.tsx"],"names":[],"mappings":"AA4CA;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,GAAG,2CAknBvC"}
@@ -1,11 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Button, CreateDocumentModal, useDrop, } from "@powerhousedao/design-system";
3
- import { addDocument, setSelectedNode, useAllFolderNodes, useDocumentModelModules, useDriveContext, useDriveSharingType, useEditorModules, useFileChildNodes, useFolderChildNodes, useSelectedDrive, useSelectedFolder, useSelectedNodePath, useUserPermissions, useAllDocuments, dispatchActions, } from "@powerhousedao/reactor-browser";
3
+ import { Sidebar, SidebarProvider, } from "@powerhousedao/document-engineering";
4
+ import { addDocument, setSelectedNode, useAllFolderNodes, useDocumentModelModules, useDriveContext, useDriveSharingType, useEditorModules, useFileChildNodes, useSelectedDrive, useSelectedFolder, useSelectedNodePath, useUserPermissions, useAllDocuments, dispatchActions, useSelectedDocument, } from "@powerhousedao/reactor-browser";
4
5
  import { twMerge } from "tailwind-merge";
5
- import { useCallback, useRef, useState, useMemo } from "react";
6
+ import { useCallback, useRef, useState, useMemo, useEffect } from "react";
6
7
  import { EditorContainer } from "./EditorContainer.js";
7
- import { IsolatedSidebarProvider } from "./IsolatedSidebarProvider.js";
8
- import { IsolatedSidebar } from "./IsolatedSidebar.js";
9
8
  import { editWorkstream } from "../../../document-models/workstream/gen/creators.js";
10
9
  /**
11
10
  * Main drive explorer component with sidebar navigation and content area.
@@ -33,18 +32,26 @@ export function DriveExplorer(props) {
33
32
  const selectedNodePath = useSelectedNodePath();
34
33
  const sharingType = useDriveSharingType(selectedDrive?.header.id);
35
34
  const allDocuments = useAllDocuments();
35
+ // Listen to global selected document state (for external editors like Scope of Work)
36
+ const [globalSelectedDocument] = useSelectedDocument();
36
37
  // All folders for the sidebar tree view
37
38
  const allFolders = useAllFolderNodes();
38
- const folderChildren = useFolderChildNodes();
39
39
  const fileChildren = useFileChildNodes();
40
- const filesWithDocuments = fileChildren.map((file) => {
41
- const document = allDocuments?.find((doc) => doc.header.id === file.id);
42
- const state = document?.state?.global;
43
- return {
44
- ...file,
45
- state,
46
- };
47
- });
40
+ const networkAdminDocuments = allDocuments?.filter((doc) => doc.header.documentType === "powerhouse/network-profile" ||
41
+ doc.header.documentType === "powerhouse/workstream" ||
42
+ doc.header.documentType === "powerhouse/scopeofwork" ||
43
+ doc.header.documentType === "powerhouse/rfp" ||
44
+ doc.header.documentType === "payment-terms");
45
+ // Sync global selected document with local activeDocumentId
46
+ // This makes setSelectedNode() trigger the EditorContainer to open
47
+ useEffect(() => {
48
+ if (globalSelectedDocument?.header?.id) {
49
+ setActiveDocumentId(globalSelectedDocument.header.id);
50
+ }
51
+ }, [globalSelectedDocument]);
52
+ // Check if current active document is a Scope of Work (should show in full view)
53
+ const activeDoc = allDocuments?.find((doc) => doc.header.id === activeDocumentId);
54
+ const isScopeOfWorkFullView = activeDoc?.header.documentType === "powerhouse/scopeofwork";
48
55
  // Find the folder containing the most recent workstream document
49
56
  const getMostRecentWorkstreamFolder = useCallback(() => {
50
57
  const workstreamFiles = fileChildren.filter((file) => file.documentType === "powerhouse/workstream");
@@ -81,68 +88,40 @@ export function DriveExplorer(props) {
81
88
  onMoveNode,
82
89
  });
83
90
  // check if workstream doc is created, set isWorkstreamCreated to true
84
- const isWorkstreamCreated = fileChildren.some((file) => file.documentType === "powerhouse/workstream");
91
+ const isWorkstreamCreated = networkAdminDocuments?.some((doc) => doc.header.documentType === "powerhouse/workstream") || false;
85
92
  //check if network profile doc is created, set isNetworkProfileCreated to true
86
- const isNetworkProfileCreated = fileChildren.some((file) => file.documentType === "powerhouse/network-profile");
87
- // Convert folders and files to SidebarNode format
93
+ const isNetworkProfileCreated = networkAdminDocuments?.some((doc) => doc.header.documentType === "powerhouse/network-profile") || false;
94
+ // Convert network admin documents to SidebarNode format
88
95
  const sidebarNodes = useMemo(() => {
96
+ // Group documents by type
97
+ const workstreamDocs = networkAdminDocuments?.filter((doc) => doc.header.documentType === "powerhouse/workstream") || [];
98
+ const scopeOfWorkDocs = networkAdminDocuments?.filter((doc) => doc.header.documentType === "powerhouse/scopeofwork") || [];
99
+ const rfpDocs = networkAdminDocuments?.filter((doc) => doc.header.documentType === "powerhouse/rfp") || [];
100
+ const paymentTermsDocs = networkAdminDocuments?.filter((doc) => doc.header.documentType === "payment-terms") || [];
101
+ const networkProfileDocs = networkAdminDocuments?.filter((doc) => doc.header.documentType === "powerhouse/network-profile") || [];
89
102
  const workstreamsNode = {
90
103
  id: "workstreams",
91
104
  title: "Workstreams",
92
105
  children: [
93
- // Add folders
94
- ...allFolders
95
- .filter((folder) => {
96
- // Only root folders that contain non-network-profile documents
97
- if (folder.parentFolder)
98
- return false;
99
- // Check if this folder or any of its subfolders contain non-network-profile documents
100
- const hasNonNetworkProfileFiles = filesWithDocuments.some((file) => file.documentType !== "powerhouse/network-profile" &&
101
- (file.parentFolder === folder.id ||
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
- ],
106
+ // Add workstream documents
107
+ ...workstreamDocs.map((doc) => ({
108
+ id: `editor-${doc.header.id}`,
109
+ title: `${doc.state?.global?.code || ""} - ${doc.state?.global?.title || doc.header.name}`,
110
+ })),
111
+ // Add scope of work documents
112
+ ...scopeOfWorkDocs.map((doc) => ({
113
+ id: `editor-${doc.header.id}`,
114
+ title: `${doc.state?.global?.title || doc.header.name}`,
138
115
  })),
139
- // Add root-level files (exclude network-profile documents)
140
- ...filesWithDocuments
141
- .filter((file) => !file.parentFolder &&
142
- file.documentType !== "powerhouse/network-profile")
143
- .map((file) => ({
144
- id: `editor-${file.id}`,
145
- title: `${file.state?.code || ""} - ${file.state?.title || file.name}`,
116
+ // Add RFP documents
117
+ ...rfpDocs.map((doc) => ({
118
+ id: `editor-${doc.header.id}`,
119
+ title: `${doc.state?.global?.code || ""} - ${doc.state?.global?.title || doc.header.name}`,
120
+ })),
121
+ // Add payment terms documents
122
+ ...paymentTermsDocs.map((doc) => ({
123
+ id: `editor-${doc.header.id}`,
124
+ title: `${doc.state?.global?.code || ""} - ${doc.state?.global?.title || doc.header.name}`,
146
125
  })),
147
126
  ],
148
127
  };
@@ -150,61 +129,15 @@ export function DriveExplorer(props) {
150
129
  id: "network-information",
151
130
  title: "Network Information",
152
131
  children: [
153
- // Add folders that contain network-profile documents
154
- ...allFolders
155
- .filter((folder) => {
156
- // Check if this folder or any of its subfolders contain network-profile documents
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}`,
132
+ // Add network profile documents
133
+ ...networkProfileDocs.map((doc) => ({
134
+ id: `editor-${doc.header.id}`,
135
+ title: doc.header.name,
203
136
  })),
204
137
  ],
205
138
  };
206
139
  return [workstreamsNode, networkInfoNode];
207
- }, [allFolders, filesWithDocuments]);
140
+ }, [networkAdminDocuments]);
208
141
  // Handle sidebar node selection
209
142
  const handleActiveNodeChange = useCallback((nodeId) => {
210
143
  console.log("nodeId", nodeId);
@@ -239,16 +172,8 @@ export function DriveExplorer(props) {
239
172
  else if (newNode.id.startsWith("editor-")) {
240
173
  // Extract file ID from editor-{file.id} format
241
174
  const fileId = newNode.id.replace("editor-", "");
242
- const file = fileChildren.find((f) => f.id === fileId);
243
175
  setActiveDocumentId(fileId);
244
176
  }
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
177
  }, [
253
178
  allFolders,
254
179
  fileChildren,
@@ -266,7 +191,7 @@ export function DriveExplorer(props) {
266
191
  nodeType = "workstreams";
267
192
  }
268
193
  else if (activeNodeId === "network-information") {
269
- nodeType = "network-information";
194
+ nodeType = "workstreams";
270
195
  }
271
196
  else if (activeNodeId.startsWith("editor-")) {
272
197
  nodeType = "file";
@@ -289,128 +214,41 @@ export function DriveExplorer(props) {
289
214
  }
290
215
  switch (nodeType) {
291
216
  case "workstreams":
292
- 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: "Welcome to the Network Admin" }), _jsx("p", { children: "Create a new workstream to get started, or select an existing workstream on the left" }), _jsxs("div", { className: "flex gap-3", children: [_jsx(Button, { color: "dark" // Customize button appearance
293
- , size: "medium", className: "cursor-pointer hover:bg-gray-600 hover:text-white", title: "Create Workstream Document", "aria-description": "Create Workstream Document", onClick: () => {
294
- setModalDocumentType("powerhouse/workstream");
295
- setOpenModal(true);
296
- }, disabled: isWorkstreamCreated, children: _jsx("span", { children: "Create Workstream Document" }) }), _jsx(Button, { color: "dark" // Customize button appearance
297
- , size: "medium", className: "cursor-pointer hover:bg-gray-600 hover:text-white", title: "Create Network Profile Document", "aria-description": "Create Network Profile Document", onClick: () => {
298
- setModalDocumentType("powerhouse/network-profile");
299
- setOpenModal(true);
300
- }, 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 Folders" }), _jsx("div", { className: "space-y-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: () => {
301
- const newName = prompt("Enter new name:", folderNode.name || "");
302
- if (newName &&
303
- newName.trim() &&
304
- newName !== folderNode.name) {
305
- try {
306
- onRenameNode(newName.trim(), folderNode);
307
- }
308
- catch (error) {
309
- console.error("Failed to rename:", error);
310
- alert("Failed to rename folder. Please try again.");
311
- }
312
- }
313
- }, 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) })] }), _jsxs("div", { children: [_jsx("h3", { className: "mb-2 text-sm font-medium text-gray-500", children: "\uD83D\uDCC4 Documents" }), _jsx("div", { className: "space-y-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: () => {
314
- setSelectedNode(fileNode);
315
- setActiveDocumentId(fileNode.id);
316
- }, className: "px-2 py-1 bg-blue-500 text-white rounded text-sm hover:bg-blue-600", children: "Open" }), _jsx("button", { onClick: () => {
317
- if (!fileNode || !fileNode.id)
318
- return;
319
- const newName = prompt("Enter new name:", fileNode.name || "");
320
- if (newName &&
321
- newName.trim() &&
322
- newName !== fileNode.name) {
323
- try {
324
- onRenameNode(newName.trim(), fileNode);
325
- }
326
- catch (error) {
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" })] }))] }));
217
+ 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
218
+ , size: "medium", className: "cursor-pointer hover:bg-gray-600 hover:text-white", title: "Create Workstream Document", "aria-description": "Create Workstream Document", onClick: () => {
219
+ setModalDocumentType("powerhouse/workstream");
220
+ setOpenModal(true);
221
+ }, disabled: isWorkstreamCreated, children: _jsx("span", { children: "Create Workstream Document" }) }), _jsx(Button, { color: "dark" // Customize button appearance
222
+ , size: "medium", className: "cursor-pointer hover:bg-gray-600 hover:text-white", title: "Create Network Profile Document", "aria-description": "Create Network Profile Document", onClick: () => {
223
+ setModalDocumentType("powerhouse/network-profile");
224
+ setOpenModal(true);
225
+ }, 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) => {
226
+ // Find the corresponding file node for actions
227
+ const fileNode = fileChildren?.find((file) => file.id === document.header.id);
228
+ 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: () => {
229
+ if (fileNode) {
230
+ setSelectedNode(fileNode);
231
+ }
232
+ }, 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: () => {
233
+ if (!fileNode || !fileNode.id)
234
+ return;
235
+ const newName = prompt("Enter new name:", document.header.name || "");
236
+ if (newName &&
237
+ newName.trim() &&
238
+ newName !== document.header.name) {
239
+ try {
240
+ onRenameNode(newName.trim(), fileNode);
241
+ }
242
+ catch (error) {
243
+ alert("Failed to rename document. Please try again.");
244
+ }
245
+ }
246
+ }, 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: () => {
247
+ if (fileNode) {
248
+ showDeleteNodeModal(fileNode);
249
+ }
250
+ }, 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));
251
+ }) })] }) })] }))] }) }));
414
252
  default:
415
253
  return _jsxs("div", { children: ["Unknown node type: ", nodeType] });
416
254
  }
@@ -446,14 +284,8 @@ export function DriveExplorer(props) {
446
284
  : "workstream-editor";
447
285
  console.log(`Creating ${documentType} document: ${fileName}`);
448
286
  try {
449
- let folder = undefined;
450
- if (documentType === "powerhouse/workstream") {
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);
287
+ const node = await addDocument(selectedDrive?.header.id || "", fileName, documentType, undefined, // creating in root folder
288
+ undefined, undefined, editorType);
457
289
  if (!node?.id) {
458
290
  console.error("Error creating document", fileName);
459
291
  return;
@@ -483,7 +315,6 @@ export function DriveExplorer(props) {
483
315
  selectedFolder?.id,
484
316
  modalDocumentType,
485
317
  ]);
486
- // === DOCUMENT EDITOR DATA ===
487
318
  // Filter available document types here if needed
488
319
  const documentModelModules = useDocumentModelModules();
489
320
  // Get active document and its editor components
@@ -497,8 +328,15 @@ export function DriveExplorer(props) {
497
328
  ? editorModules?.find((e) => e.documentTypes.includes(activeDocument.documentType))
498
329
  : null;
499
330
  // === RENDER ===
500
- return (_jsx(IsolatedSidebarProvider, { nodes: sidebarNodes, children: _jsxs("div", { className: "flex h-full", children: [_jsx(IsolatedSidebar, { nodes: sidebarNodes, activeNodeId: selectedFolder?.id || activeDocumentId, onActiveNodeChange: handleActiveNodeChange, sidebarTitle: "Network Admin", showSearchBar: true, allowPinning: true, resizable: true, initialWidth: 300, maxWidth: 500, enableMacros: 2, handleOnTitleClick: () => {
331
+ return (_jsx(SidebarProvider, { nodes: sidebarNodes, children: isScopeOfWorkFullView && activeDocumentId ? (_jsx("div", { className: "h-full w-full", children: _jsx(EditorContainer, { handleClose: () => {
332
+ setActiveDocumentId(undefined);
333
+ setSelectedNode(undefined); // Clear global selection
334
+ }, hideToolbar: false, activeDocumentId: activeDocumentId, setActiveDocumentId: setActiveDocumentId }) })) : (
335
+ /* === NORMAL VIEW WITH SIDEBAR === */
336
+ _jsxs("div", { className: "flex h-full", children: [_jsx(Sidebar, { className: String.raw `
337
+ [&_.sidebar\\_\\_item--active]:bg-yellow-500
338
+ `, 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
339
  setActiveDocumentId(undefined);
502
340
  setSelectedRootNode("workstreams");
503
- } }), _jsx("div", { className: "flex-1 overflow-y-auto", children: _jsx("div", { ...dropProps, className: twMerge("rounded-md border-2 border-transparent ", isDropTarget && "border-dashed border-blue-100"), 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 })] }) }));
341
+ } }), _jsx("div", { className: "flex-1 overflow-y-auto", children: _jsx("div", { ...dropProps, className: twMerge("rounded-md border-2 border-transparent ", isDropTarget && "border-dashed border-blue-100"), 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
342
  }
@@ -1 +1 @@
1
- {"version":3,"file":"EditorContainer.d.ts","sourceRoot":"","sources":["../../../../editors/network-admin/components/EditorContainer.tsx"],"names":[],"mappings":"AAyBA;;;;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,4CA+LA,CAAC"}
1
+ {"version":3,"file":"EditorContainer.d.ts","sourceRoot":"","sources":["../../../../editors/network-admin/components/EditorContainer.tsx"],"names":[],"mappings":"AAyBA;;;;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 +1 @@
1
- {"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../../editors/network-profile/editor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAgBlD,MAAM,MAAM,MAAM,GAAG,WAAW,CAAC;AAmLjC,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,KAAK,EAAE,GAAG,2CA8OxC"}
1
+ {"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../../editors/network-profile/editor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAU,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAgB1D,MAAM,MAAM,MAAM,GAAG,WAAW,CAAC;AA8MjC,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,KAAK,EAAE,GAAG,2CAgPxC"}