@powerhousedao/network-admin 0.0.4 → 0.0.6

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.
@@ -6,8 +6,8 @@ import { createDocument } from "./utils.js";
6
6
  export function defaultGlobalState() {
7
7
  return {
8
8
  issuer: "placeholder-id",
9
- code: "",
10
9
  title: "",
10
+ code: "",
11
11
  summary: "",
12
12
  briefing: "",
13
13
  rfpCommenter: [],
@@ -3,9 +3,9 @@ import { reducer } from "./reducer.js";
3
3
  export const initialGlobalState = {
4
4
  issuer: "placeholder-id",
5
5
  title: "",
6
+ code: "",
6
7
  summary: "",
7
8
  briefing: "",
8
- code: "",
9
9
  rfpCommenter: [],
10
10
  eligibilityCriteria: "",
11
11
  evaluationCriteria: "",
@@ -1 +1 @@
1
- {"version":3,"file":"DriveExplorer.d.ts","sourceRoot":"","sources":["../../../../editors/network-admin/components/DriveExplorer.tsx"],"names":[],"mappings":"AAuCA;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,GAAG,2CA8hCvC"}
1
+ {"version":3,"file":"DriveExplorer.d.ts","sourceRoot":"","sources":["../../../../editors/network-admin/components/DriveExplorer.tsx"],"names":[],"mappings":"AAwCA;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,GAAG,2CAklCvC"}
@@ -20,6 +20,8 @@ export function DriveExplorer(props) {
20
20
  const [modalDocumentType, setModalDocumentType] = useState("powerhouse/workstream");
21
21
  const selectedDocumentModel = useRef(null);
22
22
  const editorModules = useEditorModules();
23
+ // Track the last created folder for drag and drop targeting
24
+ const [lastCreatedFolder, setLastCreatedFolder] = useState(undefined);
23
25
  // === DRIVE CONTEXT HOOKS ===
24
26
  // Core drive operations and document models
25
27
  const { onAddFile, onAddFolder, onCopyNode, onDuplicateNode, onMoveNode, onRenameNode, showDeleteNodeModal, } = useDriveContext();
@@ -31,6 +33,8 @@ export function DriveExplorer(props) {
31
33
  const selectedNodePath = useSelectedNodePath();
32
34
  const sharingType = useDriveSharingType(selectedDrive?.header.id);
33
35
  const allDocuments = useAllDocuments();
36
+ // All folders for the sidebar tree view
37
+ const allFolders = useAllFolderNodes();
34
38
  const folderChildren = useFolderChildNodes();
35
39
  const fileChildren = useFileChildNodes();
36
40
  const filesWithDocuments = fileChildren.map((file) => {
@@ -41,12 +45,38 @@ export function DriveExplorer(props) {
41
45
  state,
42
46
  };
43
47
  });
48
+ // Find the folder containing the most recent workstream document
49
+ const getMostRecentWorkstreamFolder = useCallback(() => {
50
+ const workstreamFiles = fileChildren.filter((file) => file.documentType === "powerhouse/workstream");
51
+ if (workstreamFiles.length === 0)
52
+ return undefined;
53
+ // Sort by creation time (assuming newer files have higher IDs or we can use a different method)
54
+ const mostRecentWorkstream = workstreamFiles[workstreamFiles.length - 1];
55
+ // Find the folder that contains this workstream
56
+ if (mostRecentWorkstream.parentFolder) {
57
+ return allFolders.find((folder) => folder.id === mostRecentWorkstream.parentFolder);
58
+ }
59
+ return undefined;
60
+ }, [fileChildren, allFolders]);
44
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]);
45
77
  const { isDropTarget, dropProps } = useDrop({
46
- node: folderChildren?.length > 0
47
- ? folderChildren[folderChildren.length - 1]
48
- : undefined,
49
- onAddFile,
78
+ node: dropTargetNode,
79
+ onAddFile: onAddFileWithTarget,
50
80
  onCopyNode,
51
81
  onMoveNode,
52
82
  });
@@ -54,8 +84,6 @@ export function DriveExplorer(props) {
54
84
  const isWorkstreamCreated = fileChildren.some((file) => file.documentType === "powerhouse/workstream");
55
85
  //check if network profile doc is created, set isNetworkProfileCreated to true
56
86
  const isNetworkProfileCreated = fileChildren.some((file) => file.documentType === "powerhouse/network-profile");
57
- // All folders for the sidebar tree view
58
- const allFolders = useAllFolderNodes();
59
87
  // Convert folders and files to SidebarNode format
60
88
  const sidebarNodes = useMemo(() => {
61
89
  const workstreamsNode = {
@@ -180,6 +208,8 @@ export function DriveExplorer(props) {
180
208
  // Handle sidebar node selection
181
209
  const handleActiveNodeChange = useCallback((nodeId) => {
182
210
  console.log("nodeId", nodeId);
211
+ // Clear the last created folder when navigating to a different node
212
+ setLastCreatedFolder(undefined);
183
213
  // Find the node by ID
184
214
  const findNodeById = (nodes, id) => {
185
215
  for (const node of nodes) {
@@ -395,7 +425,10 @@ export function DriveExplorer(props) {
395
425
  }
396
426
  if (name?.trim()) {
397
427
  try {
398
- await onAddFolder(name.trim(), selectedFolder);
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);
399
432
  }
400
433
  catch (error) {
401
434
  console.error("Failed to create folder:", error);
@@ -416,6 +449,9 @@ export function DriveExplorer(props) {
416
449
  let folder = undefined;
417
450
  if (documentType === "powerhouse/workstream") {
418
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);
419
455
  }
420
456
  const node = await addDocument(selectedDrive?.header.id || "", fileName, documentType, folder?.id, getNewDocumentObject(fileName, documentType), undefined, editorType);
421
457
  selectedDocumentModel.current = null;
@@ -1 +1 @@
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,4CAqLA,CAAC"}
1
+ {"version":3,"file":"EditorContainer.d.ts","sourceRoot":"","sources":["../../../../editors/network-admin/components/EditorContainer.tsx"],"names":[],"mappings":"AAsBA;;;;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,4CAwKA,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { getRevisionFromDate, useTimelineItems } from "@powerhousedao/common";
3
3
  import { DocumentToolbar, RevisionHistory, } from "@powerhousedao/design-system";
4
- import { exportFile, useEditorModuleById, useSelectedDrive, useDocumentById, addDocument, useNodes, } from "@powerhousedao/reactor-browser";
4
+ import { exportFile, useEditorModuleById, useSelectedDrive, useDocumentById, addDocument, useNodes, useFallbackEditorModule, } from "@powerhousedao/reactor-browser";
5
5
  import { Suspense, useCallback, useState } from "react";
6
6
  import { getNewDocumentObject } from "../utils.js";
7
7
  /**
@@ -55,25 +55,10 @@ export const EditorContainer = (props) => {
55
55
  }, [selectedDrive, (selectedDocument?.state).global, folderId]);
56
56
  // Timeline data for revision history
57
57
  const timelineItems = useTimelineItems(selectedDocument?.header.id, selectedDocument?.header.createdAtUtcIso, selectedDrive?.header.id);
58
- let preferredEditor = selectedDocument?.header.meta?.preferredEditor;
59
- if (!preferredEditor) {
60
- if (selectedDocument?.header.documentType === "powerhouse/workstream") {
61
- preferredEditor = "workstream-editor";
62
- }
63
- else if (selectedDocument?.header.documentType === "powerhouse/rfp") {
64
- preferredEditor = "request-for-proposals-editor";
65
- }
66
- else if (selectedDocument?.header.documentType === "payment-terms") {
67
- preferredEditor = "payment-terms-editor";
68
- }
69
- else if (selectedDocument?.header.documentType === "powerhouse/network-profile") {
70
- preferredEditor = "network-profile-editor";
71
- }
72
- else if (selectedDocument?.header.documentType === "powerhouse/scopeofwork") {
73
- preferredEditor = "scope-of-work-editor";
74
- }
75
- }
76
- const editorModule = useEditorModuleById(selectedDocument?.header.meta?.preferredEditor || preferredEditor);
58
+ let preferredEditor = useFallbackEditorModule(selectedDocument?.header.documentType);
59
+ const editorModule = useEditorModuleById(selectedDocument?.header.meta?.preferredEditor ||
60
+ preferredEditor?.id ||
61
+ undefined);
77
62
  // Document export functionality - customize export behavior here
78
63
  const onExport = useCallback(async () => {
79
64
  if (selectedDocument) {
@@ -1,5 +1,3 @@
1
- import "@uiw/react-md-editor/markdown-editor.css";
2
- import "@uiw/react-markdown-preview/markdown.css";
3
1
  export type MarkdownEditorMode = "preview" | "edit" | "live";
4
2
  interface MarkdownEditorProps {
5
3
  value: string;
@@ -1 +1 @@
1
- {"version":3,"file":"markdown-editor.d.ts","sourceRoot":"","sources":["../../../editors/request-for-proposals/markdown-editor.tsx"],"names":[],"mappings":"AAIA,OAAO,0CAA0C,CAAC;AAClD,OAAO,0CAA0C,CAAC;AAYlD,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;AAE7D,UAAU,mBAAmB;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,wBAAgB,cAAc,CAAC,EAC7B,KAAK,EACL,QAAQ,EACR,MAAM,EACN,MAAY,EACZ,KAAiB,EACjB,cAAqD,GACtD,EAAE,mBAAmB,2CAoLrB"}
1
+ {"version":3,"file":"markdown-editor.d.ts","sourceRoot":"","sources":["../../../editors/request-for-proposals/markdown-editor.tsx"],"names":[],"mappings":"AAeA,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;AAE7D,UAAU,mBAAmB;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,wBAAgB,cAAc,CAAC,EAC7B,KAAK,EACL,QAAQ,EACR,MAAM,EACN,MAAY,EACZ,KAAiB,EACjB,cAAqD,GACtD,EAAE,mBAAmB,2CAuLrB"}
@@ -3,8 +3,6 @@ import { useEffect, useState } from "react";
3
3
  import remarkGfm from "remark-gfm";
4
4
  import rehypeSlug from "rehype-slug";
5
5
  import { useLocalStorage } from "usehooks-ts";
6
- import "@uiw/react-md-editor/markdown-editor.css";
7
- import "@uiw/react-markdown-preview/markdown.css";
8
6
  // Custom preview renderer to make links open in new tabs and ensure proper list rendering
9
7
  const previewOptions = {
10
8
  components: {
@@ -20,6 +18,8 @@ export function MarkdownEditor({ value, onChange, onBlur, height = 350, label =
20
18
  const [isLoaded, setIsLoaded] = useState(false);
21
19
  const [loadError, setLoadError] = useState(null);
22
20
  const [viewMarkdownMode, setViewMarkdownMode] = useLocalStorage("markdown-editor-view-mode", "live");
21
+ // Ensure we have a valid mode for the editor
22
+ const editorMode = viewMarkdownMode || "live";
23
23
  // Load the MDEditor component dynamically
24
24
  useEffect(() => {
25
25
  // Use a more robust dynamic import approach
@@ -127,7 +127,7 @@ export function MarkdownEditor({ value, onChange, onBlur, height = 350, label =
127
127
  line-height: 24px !important;
128
128
  }
129
129
 
130
- ` }), label && _jsx("p", { className: labelClassName, children: label }), !isLoaded && (_jsx("div", { className: "w-full border border-gray-300 rounded-md p-3 bg-white", style: { height: `${height}px` }, children: _jsx("div", { className: "w-full h-full flex items-center justify-center text-gray-500", children: "Loading editor..." }) })), isLoaded && loadError && (_jsx("div", { className: "w-full border border-red-300 rounded-md p-3 bg-red-50", style: { height: `${height}px` }, children: _jsxs("div", { className: "w-full h-full flex flex-col items-center justify-center text-red-600", children: [_jsx("p", { className: "text-sm font-medium mb-2", children: "Failed to load markdown editor" }), _jsx("p", { className: "text-xs text-red-500", children: loadError }), _jsx("textarea", { className: "w-full h-full mt-2 p-2 border border-gray-300 rounded text-sm", placeholder: "Fallback text editor - write your content here...", value: value, onChange: (e) => onChange(e.target.value), onBlur: (e) => onBlur?.(e.target.value) })] }) })), isLoaded && MDEditor && (_jsx("div", { "data-color-mode": "light", className: "w-full", children: _jsx(MDEditor, { height: height, value: contentValue, onChange: handleContentChange, onBlur: handleContentBlur, previewOptions: previewOptions, enableScroll: true, preview: viewMarkdownMode, textareaProps: {
130
+ ` }), label && _jsx("p", { className: labelClassName, children: label }), !isLoaded && (_jsx("div", { className: "w-full border border-gray-300 rounded-md p-3 bg-white", style: { height: `${height}px` }, children: _jsx("div", { className: "w-full h-full flex items-center justify-center text-gray-500", children: "Loading editor..." }) })), isLoaded && loadError && (_jsx("div", { className: "w-full border border-red-300 rounded-md p-3 bg-red-50", style: { height: `${height}px` }, children: _jsxs("div", { className: "w-full h-full flex flex-col items-center justify-center text-red-600", children: [_jsx("p", { className: "text-sm font-medium mb-2", children: "Failed to load markdown editor" }), _jsx("p", { className: "text-xs text-red-500", children: loadError }), _jsx("textarea", { className: "w-full h-full mt-2 p-2 border border-gray-300 rounded text-sm", placeholder: "Fallback text editor - write your content here...", value: value, onChange: (e) => onChange(e.target.value), onBlur: (e) => onBlur?.(e.target.value) })] }) })), isLoaded && MDEditor && (_jsx("div", { "data-color-mode": "light", className: "w-full", children: _jsx(MDEditor, { height: height, value: contentValue, onChange: handleContentChange, onBlur: handleContentBlur, previewOptions: previewOptions, enableScroll: true, preview: editorMode, textareaProps: {
131
131
  placeholder: "Write your content here...",
132
132
  } }) }))] }));
133
133
  }