@powerhousedao/network-admin 0.0.18 → 0.0.19
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":"
|
|
1
|
+
{"version":3,"file":"DriveExplorer.d.ts","sourceRoot":"","sources":["../../../../editors/network-admin/components/DriveExplorer.tsx"],"names":[],"mappings":"AA6BA;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,GAAG,2CA4fvC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Button, CreateDocumentModal, } from "@powerhousedao/design-system";
|
|
3
3
|
import { Sidebar, SidebarProvider, } from "@powerhousedao/document-engineering";
|
|
4
|
-
import { addDocument, setSelectedNode, useAllFolderNodes, useFileChildNodes, useSelectedDrive, useSelectedFolder, dispatchActions, useSelectedDocument, useSelectedDriveDocuments,
|
|
4
|
+
import { addDocument, setSelectedNode, useAllFolderNodes, useFileChildNodes, useSelectedDrive, useSelectedFolder, dispatchActions, useSelectedDocument, useSelectedDriveDocuments, showDeleteNodeModal, useSelectedDriveId, useNodeActions, } from "@powerhousedao/reactor-browser";
|
|
5
5
|
import { useCallback, useRef, useState, useMemo, useEffect } from "react";
|
|
6
6
|
import { EditorContainer } from "./EditorContainer.js";
|
|
7
7
|
import { editWorkstream } from "../../../document-models/workstream/gen/creators.js";
|
|
@@ -23,6 +23,7 @@ export function DriveExplorer(props) {
|
|
|
23
23
|
const selectedFolder = useSelectedFolder(); // Currently selected folder
|
|
24
24
|
const allDocuments = useSelectedDriveDocuments();
|
|
25
25
|
const selectedDriveId = useSelectedDriveId();
|
|
26
|
+
const { onRenameNode } = useNodeActions();
|
|
26
27
|
// Listen to global selected document state (for external editors like Scope of Work)
|
|
27
28
|
const [globalSelectedDocument] = useSelectedDocument();
|
|
28
29
|
// All folders for the sidebar tree view
|
|
@@ -43,13 +44,6 @@ export function DriveExplorer(props) {
|
|
|
43
44
|
// Check if current active document is a Scope of Work (should show in full view)
|
|
44
45
|
const activeDoc = allDocuments?.find((doc) => doc.header.id === activeDocumentId);
|
|
45
46
|
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);
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
47
|
// check if workstream doc is created, set isWorkstreamCreated to true
|
|
54
48
|
const isWorkstreamCreated = networkAdminDocuments?.some((doc) => doc.header.documentType === "powerhouse/workstream") || false;
|
|
55
49
|
//check if network profile doc is created, set isNetworkProfileCreated to true
|
|
@@ -186,27 +180,28 @@ export function DriveExplorer(props) {
|
|
|
186
180
|
}, 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
181
|
// Find the corresponding file node for actions
|
|
188
182
|
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: () => {
|
|
183
|
+
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: fileNode?.name || document.header.name, children: fileNode?.name || 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
184
|
if (fileNode) {
|
|
191
185
|
setSelectedNode(fileNode);
|
|
192
186
|
}
|
|
193
187
|
}, 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
188
|
if (!fileNode || !fileNode.id)
|
|
195
189
|
return;
|
|
196
|
-
const
|
|
190
|
+
const currentName = fileNode.name || document.header.name;
|
|
191
|
+
const newName = prompt("Enter new name:", currentName);
|
|
197
192
|
if (newName &&
|
|
198
193
|
newName.trim() &&
|
|
199
|
-
newName !==
|
|
194
|
+
newName !== currentName) {
|
|
200
195
|
try {
|
|
201
|
-
await onRenameNode(
|
|
196
|
+
await onRenameNode(newName.trim(), fileNode);
|
|
202
197
|
}
|
|
203
198
|
catch (error) {
|
|
204
199
|
console.error("Failed to rename document", error);
|
|
205
200
|
}
|
|
206
201
|
}
|
|
207
202
|
}, 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
|
|
203
|
+
if (fileNode && fileNode.id) {
|
|
204
|
+
showDeleteNodeModal(fileNode.id);
|
|
210
205
|
}
|
|
211
206
|
}, 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
207
|
}) })] }) })] }))] }) }));
|