From 2cd60c3957685049fc6ff64beb094b409bbd4f32 Mon Sep 17 00:00:00 2001 From: ryanwolhuter Date: Thu, 18 Apr 2024 16:18:46 +0200 Subject: [PATCH 01/17] feat: simplify copy --- .env.local | 1 + package-lock.json | 8 +- package.json | 2 +- src/hooks/useDocumentDriveServer.ts | 144 +++++++++++++++++++--------- src/hooks/useOnDropEvent.ts | 92 ++++++++---------- 5 files changed, 145 insertions(+), 102 deletions(-) create mode 100644 .env.local diff --git a/.env.local b/.env.local new file mode 100644 index 00000000..8baeef10 --- /dev/null +++ b/.env.local @@ -0,0 +1 @@ +VITE_CREATE_DOCUMENT_ALLOW_LIST='0xcA06585Ee8b94351288277f0Ea7ee9234a00Afb8,0x7Ea463eEcF971f57799afC4e1069c6521E47c4c1' \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 92dea14d..f0f4fa66 100644 --- a/package-lock.json +++ b/package-lock.json @@ -56,7 +56,7 @@ "@vitejs/plugin-react": "^4.2.1", "asar": "^3.2.0", "autoprefixer": "^10.4.14", - "document-model-libs": "^1.33.0", + "document-model-libs": "^1.34.0", "electron": "28.2.3", "electron-playwright-helpers": "^1.7.1", "eslint": "^8.56.0", @@ -10563,9 +10563,9 @@ } }, "node_modules/document-model-libs": { - "version": "1.33.0", - "resolved": "https://registry.npmjs.org/document-model-libs/-/document-model-libs-1.33.0.tgz", - "integrity": "sha512-bv85g42aFSGTqlRZC35eip48szj/2f8OTK1E3OP91RVCnt+zJ24o8fSj9bd2eeEaAycGbJVJL2u8gLBWb3AyyQ==", + "version": "1.34.0", + "resolved": "https://registry.npmjs.org/document-model-libs/-/document-model-libs-1.34.0.tgz", + "integrity": "sha512-jL/w8qzZbF0wR67z/TWn1or32vVCOexK09W7DrTxsxHY0oAOAMpeXV+BEoyPf91NM6Kyw/qTwAUz1j3skGfcgQ==", "dependencies": { "@acaldas/graphql-codegen-typescript-validation-schema": "^0.12.3", "@graphql-codegen/core": "^4.0.2", diff --git a/package.json b/package.json index 55a106c6..bdf9b9af 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "@vitejs/plugin-react": "^4.2.1", "asar": "^3.2.0", "autoprefixer": "^10.4.14", - "document-model-libs": "^1.33.0", + "document-model-libs": "^1.34.0", "electron": "28.2.3", "electron-playwright-helpers": "^1.7.1", "eslint": "^8.56.0", diff --git a/src/hooks/useDocumentDriveServer.ts b/src/hooks/useDocumentDriveServer.ts index c2d6d243..8e7c0f88 100644 --- a/src/hooks/useDocumentDriveServer.ts +++ b/src/hooks/useDocumentDriveServer.ts @@ -222,60 +222,111 @@ export function useDocumentDriveServer( return node; } - async function copyOrMoveNode( - driveId: string, - srcId: string, - targetId: string, - operation: string, - targetName?: string, - // eslint-disable-next-line @typescript-eslint/no-unused-vars -- TODO: use this later for sorting - sortOptions?: SortOptions, - ) { - if (srcId === targetId) return; + async function moveNode(params: { + srcId: string; + decodedDriveId: string; + decodedTargetId: string; + }) { + const { decodedDriveId, srcId, decodedTargetId } = params; + + await _addDriveOperation( + decodedDriveId, + actions.moveNode({ + srcFolder: srcId, + targetParentFolder: decodedTargetId, + }), + ); + } + + async function copyNode(params: { + srcId: string; + srcName: string; + decodedDriveId: string; + decodedTargetId: string; + }) { + const { decodedDriveId, srcId, srcName, decodedTargetId } = params; + + if (srcId === decodedTargetId) return; const drive = documentDrives.find( - drive => drive.state.global.id === driveId, + drive => drive.state.global.id === decodedDriveId, ); - if (operation === 'copy' && drive) { - const targetParentFolder = targetId === '' ? null : targetId; - const generateId = () => utils.hashKey(); - - const copyNodesInput = documentDriveUtils.generateNodesCopy( - { - srcId, - targetParentFolder, - ...(targetName && { targetName }), - }, - generateId, - drive.state.global.nodes, - ); + if (!drive) return; - const copyActions = copyNodesInput.map(copyNodeInput => - actions.copyNode(copyNodeInput), - ); + const targetNode = drive.state.global.nodes.find( + node => node.id === decodedTargetId, + ); - const result = await server.addDriveActions(driveId, copyActions); - if (result.operations.length) { - await refreshDocumentDrives(); - } else if (result.status !== 'SUCCESS') { - console.error( - `Error copying files: ${result.status}`, - result.error, - ); - } - } else { - await _addDriveOperation( - driveId, - actions.moveNode({ - srcFolder: srcId, - targetParentFolder: targetId, - }), + if (!targetNode) return; + + function getNextCopyNumber( + files: string[], + baseFilename: string, + ): number { + let maxNumber = 0; // Start by assuming no copies exist + + // Regex to find files that match the base filename followed by " (copy)" and possibly a number + const regex = new RegExp( + `^${escapeRegExp(baseFilename)} \\(copy\\)(?: (\\d+))?$`, ); - if (targetName) { - await renameNode(driveId, srcId, targetName); + for (const file of files) { + const match = file.match(regex); + if (match) { + const number = match[1] ? parseInt(match[1], 10) : 1; + if (number > maxNumber) { + maxNumber = number; + } + } } + + return maxNumber + 1; // Return the next available number + } + + // Helper function to escape any special characters in the filename for use in a regex + function escapeRegExp(string: string) { + return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string + } + + const targetNodeChildrenNames = drive.state.global.nodes + .filter(node => node.parentFolder === decodedTargetId) + .map(node => node.name); + + const targetHasNodesWithSameName = + targetNodeChildrenNames.includes(srcName); + + const targetName = targetHasNodesWithSameName + ? `${srcName} (copy) ${getNextCopyNumber(targetNodeChildrenNames, srcName)}` + : srcName; + + const generateId = () => utils.hashKey(); + + const copyNodesInput = documentDriveUtils.generateNodesCopy( + { + srcId, + targetParentFolder: decodedTargetId, + targetName, + }, + generateId, + drive.state.global.nodes, + ); + + const copyActions = copyNodesInput.map(copyNodeInput => + actions.copyNode(copyNodeInput), + ); + + const result = await server.addDriveActions( + decodedDriveId, + copyActions, + ); + if (result.operations.length) { + await refreshDocumentDrives(); + } else if (result.status !== 'SUCCESS') { + console.error( + `Error copying files: ${result.status}`, + result.error, + ); } } @@ -418,7 +469,8 @@ export function useDocumentDriveServer( addFolder, deleteNode, renameNode, - copyOrMoveNode, + moveNode, + copyNode, addOperation, addOperations, getChildren, diff --git a/src/hooks/useOnDropEvent.ts b/src/hooks/useOnDropEvent.ts index d8b2e331..c66cf84f 100644 --- a/src/hooks/useOnDropEvent.ts +++ b/src/hooks/useOnDropEvent.ts @@ -2,30 +2,24 @@ import { TreeItem, UseDraggableTargetProps, decodeID, - encodeID, getRootPath, - useFilterPathContent, - useItemActions, } from '@powerhousedao/design-system'; import path from 'path'; -import { - SortOptions, - useDocumentDriveServer, -} from 'src/hooks/useDocumentDriveServer'; +import { useDocumentDriveServer } from 'src/hooks/useDocumentDriveServer'; export const useOnDropEvent = () => { - const { copyOrMoveNode, addFile } = useDocumentDriveServer(); - const actions = useItemActions(); - const filterPathContent = useFilterPathContent(); + const { copyNode, moveNode, addFile } = useDocumentDriveServer(); const onDropEventHandler: UseDraggableTargetProps['onDropEvent'] = async (item, target, event) => { - const driveID = getRootPath(target.path); + const driveId = getRootPath(target.path); const isDropAfter = !!item.dropAfterItem; - const sortOptions: SortOptions | undefined = isDropAfter - ? { afterNodePath: target.id } - : undefined; + const isFileUpload = item.kind === 'file'; + + // const sortOptions: SortOptions | undefined = isDropAfter + // ? { afterNodePath: target.id } + // : undefined; const targetPath = isDropAfter && !target.expanded @@ -34,54 +28,50 @@ export const useOnDropEvent = () => { let targetId = targetPath.split('/').pop() ?? ''; - if (targetId === driveID || targetId == '.') { + if (targetId === driveId || targetId == '.') { targetId = ''; } - const decodedDriveID = decodeID(driveID); - - if (item.kind === 'object') { - const filterPath = filterPathContent( - treeItem => - treeItem.label === item.data.label && - treeItem.id !== item.data.id, - { path: targetPath }, - ); + const decodedDriveId = decodeID(driveId); + const decodedTargetId = decodeID(targetId); - if (filterPath.length > 0) { - actions.setExpandedItem(target.id, true); - actions.newVirtualItem({ - id: `(from)${item.data.id}`, - label: `${item.data.label} (2)`, - path: path.join(targetPath, encodeID(item.data.id)), - type: item.data.type, - action: - event.dropOperation === 'copy' - ? 'UPDATE_AND_COPY' - : 'UPDATE_AND_MOVE', - sharingType: item.data.sharingType, - availableOffline: item.data.availableOffline, - }); - return; - } - - copyOrMoveNode( - decodedDriveID, - item.data.id, - decodeID(targetId), - event.dropOperation, - undefined, - sortOptions, - ).catch(console.error); - } else { + if (isFileUpload) { const file = await item.getFile(); + await addFile( file, - decodedDriveID, + decodedDriveId, undefined, decodeID(targetId), ); + + return; } + + if (target.type === 'FILE') { + throw new Error('Cannot move a node into a file'); + } + + const isMoveOperation = event.dropOperation === 'move'; + const srcId = item.data.id; + const srcName = item.data.label + + if (isMoveOperation) { + await moveNode({ + decodedDriveId, + srcId, + decodedTargetId, + }); + + return; + } + + await copyNode({ + decodedDriveId, + srcId, + decodedTargetId, + srcName, + }); }; return onDropEventHandler; From e12240c40ca8368b9f99f0bdfa5d2881a9a71dc5 Mon Sep 17 00:00:00 2001 From: ryanwolhuter Date: Fri, 19 Apr 2024 11:12:16 +0200 Subject: [PATCH 02/17] feat: move helpers --- .env.local | 1 - src/hooks/useDocumentDriveServer.ts | 58 ++++++++++++++--------------- 2 files changed, 29 insertions(+), 30 deletions(-) delete mode 100644 .env.local diff --git a/.env.local b/.env.local deleted file mode 100644 index 8baeef10..00000000 --- a/.env.local +++ /dev/null @@ -1 +0,0 @@ -VITE_CREATE_DOCUMENT_ALLOW_LIST='0xcA06585Ee8b94351288277f0Ea7ee9234a00Afb8,0x7Ea463eEcF971f57799afC4e1069c6521E47c4c1' \ No newline at end of file diff --git a/src/hooks/useDocumentDriveServer.ts b/src/hooks/useDocumentDriveServer.ts index 9dd023f0..ff042cd2 100644 --- a/src/hooks/useDocumentDriveServer.ts +++ b/src/hooks/useDocumentDriveServer.ts @@ -282,35 +282,6 @@ export function useDocumentDriveServer( if (!targetNode) return; - function getNextCopyNumber( - files: string[], - baseFilename: string, - ): number { - let maxNumber = 0; // Start by assuming no copies exist - - // Regex to find files that match the base filename followed by " (copy)" and possibly a number - const regex = new RegExp( - `^${escapeRegExp(baseFilename)} \\(copy\\)(?: (\\d+))?$`, - ); - - for (const file of files) { - const match = file.match(regex); - if (match) { - const number = match[1] ? parseInt(match[1], 10) : 1; - if (number > maxNumber) { - maxNumber = number; - } - } - } - - return maxNumber + 1; // Return the next available number - } - - // Helper function to escape any special characters in the filename for use in a regex - function escapeRegExp(string: string) { - return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string - } - const targetNodeChildrenNames = drive.state.global.nodes .filter(node => node.parentFolder === decodedTargetId) .map(node => node.name); @@ -534,3 +505,32 @@ export function useDocumentDriveServer( [documentDrives], ); } + +function getNextCopyNumber( + files: string[], + baseFilename: string, +): number { + let maxNumber = 0; // Start by assuming no copies exist + + // Regex to find files that match the base filename followed by " (copy)" and possibly a number + const regex = new RegExp( + `^${escapeRegExp(baseFilename)} \\(copy\\)(?: (\\d+))?$`, + ); + + for (const file of files) { + const match = file.match(regex); + if (match) { + const number = match[1] ? parseInt(match[1], 10) : 1; + if (number > maxNumber) { + maxNumber = number; + } + } + } + + return maxNumber + 1; // Return the next available number +} + +// Helper function to escape any special characters in the filename for use in a regex +function escapeRegExp(string: string) { + return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string +} \ No newline at end of file From 978e0d057e5b8b2e0d080f179deec630eb6ec48e Mon Sep 17 00:00:00 2001 From: acaldas Date: Fri, 19 Apr 2024 14:29:06 +0100 Subject: [PATCH 03/17] feat: updated package-lock --- package-lock.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 61bbe957..ee264712 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "@powerhousedao/design-system": "1.0.0-alpha.97", "@sentry/react": "^7.109.0", "did-key-creator": "^1.2.0", - "document-drive": "^1.0.0-alpha.41", + "document-drive": "^1.0.0-alpha.42", "document-model": "^1.0.51", "document-model-libs": "^1.37.0-arbitrum.1", "electron-is-dev": "^3.0.1", @@ -9440,9 +9440,9 @@ } }, "node_modules/document-drive": { - "version": "1.0.0-alpha.41", - "resolved": "https://registry.npmjs.org/document-drive/-/document-drive-1.0.0-alpha.41.tgz", - "integrity": "sha512-THFqagGjNajva9wouTZB7oK9HKL0G1jQXIBrJXMTvjw7VvrWJPeYn1Kc/pDvq/qpB2GwVfkOVv1XfcRvO9I1eQ==", + "version": "1.0.0-alpha.42", + "resolved": "https://registry.npmjs.org/document-drive/-/document-drive-1.0.0-alpha.42.tgz", + "integrity": "sha512-cn2pD9r2drNdFRp2RcLe/iU4A2tpJ6R7ZorA6gJm4ukOpe2siyExu7yGdfYZ3DRGQKfyZZL/gG+BFBQJftTZSA==", "dependencies": { "graphql": "^16.8.1", "graphql-request": "^6.1.0", From 217d6e5ac54033bda7bd36473712e048fe775623 Mon Sep 17 00:00:00 2001 From: ryanwolhuter Date: Mon, 22 Apr 2024 09:24:08 +0200 Subject: [PATCH 04/17] feat: remove default node logic Signed-off-by: ryanwolhuter --- package.json | 1 + src/hooks/useDocumentDriveServer.ts | 6 ------ 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/package.json b/package.json index b08a8d5c..86b419d3 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "lint": "eslint --ext .js,.ts,.tsx . && tsc --noemit --project tsconfig.spec.json", "format": "prettier --write \"**/*.+(js|ts|jsx|tsx|json)\"", "dev:web": "vite -c vite.renderer.config.ts", + "dev:nocache": "rm -rf node_modules/.vite && rm -rf node_modules/.cache && npm run dev:web", "build:web": "vite build -c vite.renderer.config.ts", "release": "semantic-release", "prepare": "npm run prepare:scripts", diff --git a/src/hooks/useDocumentDriveServer.ts b/src/hooks/useDocumentDriveServer.ts index ff042cd2..1849da2a 100644 --- a/src/hooks/useDocumentDriveServer.ts +++ b/src/hooks/useDocumentDriveServer.ts @@ -276,12 +276,6 @@ export function useDocumentDriveServer( if (!drive) return; - const targetNode = drive.state.global.nodes.find( - node => node.id === decodedTargetId, - ); - - if (!targetNode) return; - const targetNodeChildrenNames = drive.state.global.nodes .filter(node => node.parentFolder === decodedTargetId) .map(node => node.name); From 9cd1a10a0fee03bf4ddd2ace4f1a3796e1b4de30 Mon Sep 17 00:00:00 2001 From: ryanwolhuter Date: Mon, 22 Apr 2024 09:48:21 +0200 Subject: [PATCH 05/17] feat: update submit handler Signed-off-by: ryanwolhuter --- src/hooks/useDrivesContainer.ts | 70 +++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 30 deletions(-) diff --git a/src/hooks/useDrivesContainer.ts b/src/hooks/useDrivesContainer.ts index 1a672407..ba4aa427 100644 --- a/src/hooks/useDrivesContainer.ts +++ b/src/hooks/useDrivesContainer.ts @@ -74,7 +74,8 @@ export function useDrivesContainer() { setDriveAvailableOffline, setDriveSharingType, documentDrives, - copyOrMoveNode, + copyNode, + moveNode, getSyncStatus, } = useDocumentDriveServer(); @@ -198,40 +199,49 @@ export function useDrivesContainer() { await renameNode(decodedDriveID, item.id, item.label); } - const onSubmitInput = (item: TreeItem, onCancel?: () => void) => { - const driveID = item.path.split('/')[0]; + const onSubmitInput = async (item: TreeItem, onCancel?: () => void) => { + const driveId = getRootPath(item.path); + + const isCreateNewOperation = item.action === 'NEW'; + const isMoveOperation = item.action === 'UPDATE_AND_MOVE'; + const isCopyOperation = item.action === 'UPDATE_AND_COPY'; - if (item.action === 'NEW') { + if (isCreateNewOperation) { actions.deleteVirtualItem(item.id); - addNewFolder(item, driveID, onCancel); + await addNewFolder(item, driveId, onCancel); return; } - if ( - item.action === 'UPDATE_AND_COPY' || - item.action === 'UPDATE_AND_MOVE' - ) { - actions.deleteVirtualItem(item.id); + const srcId = item.id; + const srcName = item.label; + const targetPath = path.dirname(item.path); + let targetId = targetPath.split('/').pop() ?? ''; + + if (targetId === driveId || targetId == '.') { + targetId = ''; + } + + const decodedDriveId = decodeID(driveId); + const decodedTargetId = decodeID(targetId); + + if (isMoveOperation) { + await moveNode({ + decodedDriveId, + srcId, + decodedTargetId, + }); + + return; + } + + if (isCopyOperation) { + await copyNode({ + decodedDriveId, + srcId, + decodedTargetId, + srcName, + }); - const driveID = getRootPath(item.path); - const srcID = item.id.replace('(from)', ''); - const targetPath = path.dirname(item.path); - const operation = - item.action === 'UPDATE_AND_COPY' ? 'copy' : 'move'; - - let targetId = targetPath.split('/').pop() ?? ''; - - if (targetId === driveID || targetId == '.') { - targetId = ''; - } - - copyOrMoveNode( - decodeID(driveID), - srcID, - decodeID(targetId), - operation, - item.label, - ); return; } @@ -242,7 +252,7 @@ export function useDrivesContainer() { return; } - updateNodeName(item, driveID); + await updateNodeName(item, driveId); }; async function driveToBaseItems(drive: DocumentDriveDocument) { From a9d2e29318badb84ca51acc9603a2c2dc7f25a0e Mon Sep 17 00:00:00 2001 From: ryanwolhuter Date: Mon, 22 Apr 2024 16:08:44 +0200 Subject: [PATCH 06/17] feat: add duplicate action --- package-lock.json | 7 ++++--- package.json | 2 +- src/components/file-item/file-item.tsx | 10 ++++++++-- src/components/folder-view.tsx | 1 - src/hooks/useDrivesContainer.ts | 16 ++++------------ src/hooks/useGetReadableItemPath.ts | 2 +- 6 files changed, 18 insertions(+), 20 deletions(-) diff --git a/package-lock.json b/package-lock.json index 168b03ea..4fe7e7f9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.0-alpha.6", "license": "AGPL-3.0-only", "dependencies": { - "@powerhousedao/design-system": "1.0.0-alpha.97", + "@powerhousedao/design-system": "^1.0.0-alpha.99", "@sentry/react": "^7.109.0", "did-key-creator": "^1.2.0", "document-drive": "1.0.0-alpha.41", @@ -3425,8 +3425,9 @@ } }, "node_modules/@powerhousedao/design-system": { - "version": "1.0.0-alpha.97", - "license": "AGPL-3.0-only", + "version": "1.0.0-alpha.99", + "resolved": "https://registry.npmjs.org/@powerhousedao/design-system/-/design-system-1.0.0-alpha.99.tgz", + "integrity": "sha512-DXnCWYHmMxiWm2uCHL4kA4zaNifHAck2Mb/m/IiH0wsEISSOkVjqRCssIt5YI5kUfpe87Mx0cGOR8UgyFpzWbg==", "dependencies": { "@internationalized/date": "^3.5.1", "@radix-ui/react-dialog": "^1.0.5", diff --git a/package.json b/package.json index 86b419d3..91610f20 100644 --- a/package.json +++ b/package.json @@ -90,7 +90,7 @@ "xvfb-maybe": "^0.2.1" }, "dependencies": { - "@powerhousedao/design-system": "1.0.0-alpha.97", + "@powerhousedao/design-system": "^1.0.0-alpha.99", "@sentry/react": "^7.109.0", "did-key-creator": "^1.2.0", "document-drive": "1.0.0-alpha.41", diff --git a/src/components/file-item/file-item.tsx b/src/components/file-item/file-item.tsx index dc1b8034..3cd12df9 100644 --- a/src/components/file-item/file-item.tsx +++ b/src/components/file-item/file-item.tsx @@ -16,7 +16,7 @@ import { useIsAllowedToCreateDocuments } from 'src/hooks/useIsAllowedToCreateDoc import { useOpenSwitchboardLink } from 'src/hooks/useOpenSwitchboardLink'; import { useModal } from '../modal'; -const allowedItemOptions = ['delete', 'rename']; +const allowedItemOptions = ['delete', 'rename', 'duplicate']; const defaultItemOptions = defaultDropdownMenuOptions.filter(option => allowedItemOptions.includes(option.id), @@ -34,7 +34,7 @@ export const FileItem: React.FC = ({ file, drive, onFileSelected }) => { const [isWriteMode, setIsWriteMode] = useState(false); const getReadableItemPath = useGetReadableItemPath(); const getDocumentById = useGetDocumentById(); - const { updateNodeName } = useDrivesContainer(); + const { updateNodeName, onSubmitInput } = useDrivesContainer(); const { showModal } = useModal(); const isAllowedToCreateDocuments = useIsAllowedToCreateDocuments(); @@ -51,6 +51,12 @@ export const FileItem: React.FC = ({ file, drive, onFileSelected }) => { type: 'file', }); } + if (optionId === 'duplicate') { + await onSubmitInput({ + ...file, + action: 'UPDATE_AND_COPY', + }); + } if (optionId === 'rename') { setIsWriteMode(true); diff --git a/src/components/folder-view.tsx b/src/components/folder-view.tsx index 7b0c155c..ffeb6c71 100644 --- a/src/components/folder-view.tsx +++ b/src/components/folder-view.tsx @@ -8,7 +8,6 @@ import { FileItem } from 'src/components/file-item'; import { FolderItem } from 'src/components/folder-item'; import { useFolderContent } from 'src/hooks/useFolderContent'; -import { useIsAllowedToCreateDocuments } from 'src/hooks/useIsAllowedToCreateDocuments'; import { useOnDropEvent } from 'src/hooks/useOnDropEvent'; import { twMerge } from 'tailwind-merge'; import { ContentSection } from './content'; diff --git a/src/hooks/useDrivesContainer.ts b/src/hooks/useDrivesContainer.ts index ba4aa427..ff0a6a4b 100644 --- a/src/hooks/useDrivesContainer.ts +++ b/src/hooks/useDrivesContainer.ts @@ -19,7 +19,7 @@ import { import path from 'path'; import { useTranslation } from 'react-i18next'; import { useModal } from 'src/components/modal'; -import { getLastIndexFromPath, sanitizePath } from 'src/utils'; +import { getLastIndexFromPath } from 'src/utils'; import { v4 as uuid } from 'uuid'; import { useDocumentDriveServer } from './useDocumentDriveServer'; import { useNavigateToItemId } from './useNavigateToItemId'; @@ -107,17 +107,9 @@ export function useDrivesContainer() { }); } - async function addNewFolder( - item: TreeItem, - driveID: string, - onCancel?: () => void, - ) { + async function addNewFolder(item: TreeItem, driveID: string) { const basePathComponents = item.path.split('/').slice(1, -1); - const basePath = basePathComponents.join('/'); - const newPath = path.join(basePath, sanitizePath(item.label)); - // TODO is this needed? - if (newPath === '.') return onCancel?.(); const decodedDriveID = decodeID(driveID); const parentFolder = basePathComponents.pop(); await addFolder( @@ -208,8 +200,8 @@ export function useDrivesContainer() { if (isCreateNewOperation) { actions.deleteVirtualItem(item.id); - await addNewFolder(item, driveId, onCancel); - return; + await addNewFolder(item, driveId); + return; } const srcId = item.id; diff --git a/src/hooks/useGetReadableItemPath.ts b/src/hooks/useGetReadableItemPath.ts index c437e953..6377dd25 100644 --- a/src/hooks/useGetReadableItemPath.ts +++ b/src/hooks/useGetReadableItemPath.ts @@ -10,7 +10,7 @@ export const useGetReadableItemPath = () => { const pathSegments = filteredItem.path.split('/'); const pathNames = pathSegments.map(segmentId => { const segmentItem = items.find( - item => item.id === decodeID(segmentId) + item => item.id === decodeID(segmentId), ); if (!segmentItem) return ''; From a6212a8fe3c62f49d1b624e75152e48f80034ed2 Mon Sep 17 00:00:00 2001 From: ryanwolhuter Date: Mon, 22 Apr 2024 16:32:32 +0200 Subject: [PATCH 07/17] feat: add duplicate to folder Signed-off-by: ryanwolhuter --- src/components/folder-item/folder-item.tsx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/components/folder-item/folder-item.tsx b/src/components/folder-item/folder-item.tsx index 86752b4c..9690d72d 100644 --- a/src/components/folder-item/folder-item.tsx +++ b/src/components/folder-item/folder-item.tsx @@ -9,7 +9,7 @@ import { useDrivesContainer } from 'src/hooks/useDrivesContainer'; import { useIsAllowedToCreateDocuments } from 'src/hooks/useIsAllowedToCreateDocuments'; import { useOnDropEvent } from 'src/hooks/useOnDropEvent'; -const allowedItemOptions = ['delete', 'rename']; +const allowedItemOptions = ['delete', 'rename', 'duplicate']; const itemOptions = defaultDropdownMenuOptions.filter(option => allowedItemOptions.includes(option.id), @@ -26,11 +26,14 @@ export const FolderItem: React.FC = props => { const isAllowedToCreateDocuments = useIsAllowedToCreateDocuments(); const { showModal } = useModal(); - const { updateNodeName } = useDrivesContainer(); + const { updateNodeName, onSubmitInput } = useDrivesContainer(); const [isWriteMode, setIsWriteMode] = useState(false); const onDropEvent = useOnDropEvent(); - const onFolderOptionsClick = (optionId: string, folderNode: TreeItem) => { + const onFolderOptionsClick = async ( + optionId: string, + folderNode: TreeItem, + ) => { if (optionId === 'delete') { showModal('deleteItem', { driveId: decodedDriveID, @@ -40,6 +43,13 @@ export const FolderItem: React.FC = props => { }); } + if (optionId === 'duplicate') { + await onSubmitInput({ + ...folder, + action: 'UPDATE_AND_COPY', + }); + } + if (optionId === 'rename') { setIsWriteMode(true); } From 21f93703b08e39c6c97312a232a609a53dacf1c0 Mon Sep 17 00:00:00 2001 From: ryanwolhuter Date: Mon, 22 Apr 2024 16:42:05 +0200 Subject: [PATCH 08/17] feat: handle null parent folder Signed-off-by: ryanwolhuter --- src/hooks/useDocumentDriveServer.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/hooks/useDocumentDriveServer.ts b/src/hooks/useDocumentDriveServer.ts index 1849da2a..7f66c9eb 100644 --- a/src/hooks/useDocumentDriveServer.ts +++ b/src/hooks/useDocumentDriveServer.ts @@ -277,9 +277,17 @@ export function useDocumentDriveServer( if (!drive) return; const targetNodeChildrenNames = drive.state.global.nodes - .filter(node => node.parentFolder === decodedTargetId) + .filter(node => + decodedTargetId === '' + ? node.parentFolder === null + : node.parentFolder === decodedTargetId, + ) .map(node => node.name); + console.log(drive.state.global.nodes, decodedTargetId); + + console.log({ targetNodeChildrenNames }); + const targetHasNodesWithSameName = targetNodeChildrenNames.includes(srcName); @@ -500,10 +508,7 @@ export function useDocumentDriveServer( ); } -function getNextCopyNumber( - files: string[], - baseFilename: string, -): number { +function getNextCopyNumber(files: string[], baseFilename: string): number { let maxNumber = 0; // Start by assuming no copies exist // Regex to find files that match the base filename followed by " (copy)" and possibly a number @@ -527,4 +532,4 @@ function getNextCopyNumber( // Helper function to escape any special characters in the filename for use in a regex function escapeRegExp(string: string) { return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string -} \ No newline at end of file +} From 858289b95312581c1ac7321fe04c5f1f9c1ddaee Mon Sep 17 00:00:00 2001 From: Benjamin Jordan Date: Tue, 23 Apr 2024 09:29:41 -0500 Subject: [PATCH 09/17] version bump of libs --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 82951037..a4a5bcce 100644 --- a/package.json +++ b/package.json @@ -94,7 +94,7 @@ "did-key-creator": "^1.2.0", "document-drive": "^1.0.0-alpha.43", "document-model": "^1.0.51", - "document-model-libs": "^1.37.0-arbitrum.1", + "document-model-libs": "1.37.0-arbitrum.2", "electron-is-dev": "^3.0.1", "electron-squirrel-startup": "^1.0.0", "electron-store": "^8.1.0", From 44d4796fc9efbea31457c3eebc215cfcdfa8d133 Mon Sep 17 00:00:00 2001 From: Benjamin Jordan Date: Tue, 23 Apr 2024 09:30:54 -0500 Subject: [PATCH 10/17] point at correct renown --- .env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env b/.env index afca7d3f..e336a239 100644 --- a/.env +++ b/.env @@ -1,5 +1,5 @@ VITE_ENABLED_EDITORS=ARBLTIPGrantee -VITE_RENOWN_URL=http://localhost:3000 +VITE_RENOWN_URL=https://renown.vercel.app/ VITE_DEFAULT_DRIVE_URL=https://apps.powerhouse.io/alpha/arbitrum/switchboard/d/arbitrum VITE_BASE_HREF=/ From 5f3b172956ad3384ea168771919ef2929a72e3b8 Mon Sep 17 00:00:00 2001 From: Frank Date: Tue, 23 Apr 2024 17:26:12 +0200 Subject: [PATCH 11/17] chore: allow list for makerdao staging --- .github/workflows/build-and-deploy-makerdao-staging.yaml | 2 +- Dockerfile | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-deploy-makerdao-staging.yaml b/.github/workflows/build-and-deploy-makerdao-staging.yaml index eab51d5b..c7ff0ba2 100644 --- a/.github/workflows/build-and-deploy-makerdao-staging.yaml +++ b/.github/workflows/build-and-deploy-makerdao-staging.yaml @@ -22,5 +22,5 @@ jobs: email: ${{ secrets.HEROKU_EMAIL }} heroku_api_key: ${{ secrets.HEROKU_API_KEY }} heroku_app_name: ${{ secrets.HEROKU_APP_NAME }} - docker_options: "--build-arg BASE_PATH=/alpha/makerdao/connect --build-arg VITE_BASE_HREF=/alpha/makerdao/connect/ --build-arg VITE_ROUTER_BASENAME=/alpha/makerdao/connect --build-arg VITE_SENTRY_DSN=${{ secrets.SENTRY_DSN }} --build-arg VITE_SENTRY_ENV=${{ secrets.SENTRY_ENV }} --build-arg VITE_DEFAULT_DRIVE_URL=https://apps.powerhouse.io/alpha/makerdao/switchboard/d/monetalis" + docker_options: "--build-arg BASE_PATH=/alpha/makerdao/connect --build-arg VITE_BASE_HREF=/alpha/makerdao/connect/ --build-arg VITE_ROUTER_BASENAME=/alpha/makerdao/connect --build-arg VITE_SENTRY_DSN=${{ secrets.SENTRY_DSN }} --build-arg VITE_SENTRY_ENV=${{ secrets.SENTRY_ENV }} --build-arg VITE_DEFAULT_DRIVE_URL=https://apps.powerhouse.io/alpha/makerdao/switchboard/d/monetalis --build-arg VITE_CREATE_DOCUMENT_ALLOW_LIST=${{secrets.VITE_CREATE_DOCUMENT_ALLOW_LIST}}" process_type: web \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index a3a4ecb8..c6a86875 100644 --- a/Dockerfile +++ b/Dockerfile @@ -47,6 +47,9 @@ ENV VITE_DISABLE_DELETE_LOCAL_DRIVES=${VITE_DISABLE_DELETE_LOCAL_DRIVES} ARG VITE_LOCAL_DRIVES_ENABLED=false ENV VITE_LOCAL_DRIVES_ENABLED=${VITE_LOCAL_DRIVES_ENABLED} +ARG VITE_CREATE_DOCUMENT_ALLOW_LIST="" +ENV VITE_CREATE_DOCUMENT_ALLOW_LIST=${VITE_CREATE_DOCUMENT_ALLOW_LIST} + WORKDIR /opt/app COPY . . RUN npm install -g husky vite From 7100848213fe6e5d0811229e67c82b8997648fa2 Mon Sep 17 00:00:00 2001 From: acaldas Date: Tue, 23 Apr 2024 16:36:16 +0100 Subject: [PATCH 12/17] feat: added vercel redirect --- vercel.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/vercel.json b/vercel.json index 0967ef42..9e940b3a 100644 --- a/vercel.json +++ b/vercel.json @@ -1 +1,3 @@ -{} +{ + "rewrites": [{ "source": "/(.*)", "destination": "/" }] +} From 8abb8d059310b0c43a05665e340557d53e2e9ef0 Mon Sep 17 00:00:00 2001 From: Benjamin Jordan Date: Tue, 23 Apr 2024 10:49:38 -0500 Subject: [PATCH 13/17] update package-lock --- package-lock.json | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4a6c91be..a5de1e9e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,13 +12,9 @@ "@powerhousedao/design-system": "1.0.0-alpha.97", "@sentry/react": "^7.109.0", "did-key-creator": "^1.2.0", -<<<<<<< HEAD - "document-drive": "^1.0.0-alpha.42", -======= "document-drive": "^1.0.0-alpha.43", ->>>>>>> staging "document-model": "^1.0.51", - "document-model-libs": "^1.37.0-arbitrum.1", + "document-model-libs": "1.37.0-arbitrum.2", "electron-is-dev": "^3.0.1", "electron-squirrel-startup": "^1.0.0", "electron-store": "^8.1.0", @@ -9480,9 +9476,9 @@ } }, "node_modules/document-model-libs": { - "version": "1.37.0-arbitrum.1", - "resolved": "https://registry.npmjs.org/document-model-libs/-/document-model-libs-1.37.0-arbitrum.1.tgz", - "integrity": "sha512-wgYOTUW4aZLmU4Q9/8xZj+Bq4ppo2mSMvEFgT+n3HUsCGx/GahTAHY59ZpkndtlY0tAAygjoZVQkuZ8Z+uZTag==", + "version": "1.37.0-arbitrum.2", + "resolved": "https://registry.npmjs.org/document-model-libs/-/document-model-libs-1.37.0-arbitrum.2.tgz", + "integrity": "sha512-neKRffA+LXW9/CVGYYdrXIBz/p2gUvXtgJUq2J6ChpjJt07QrVx7iuGEcj6Xlvk6/yMgSrj47MFJS17p2jb1Nw==", "dependencies": { "@acaldas/graphql-codegen-typescript-validation-schema": "^0.12.3", "@graphql-codegen/core": "^4.0.2", From 645097513096fa26327e60ea510d2e4bd628a870 Mon Sep 17 00:00:00 2001 From: ryanwolhuter Date: Wed, 24 Apr 2024 08:54:25 +0200 Subject: [PATCH 14/17] feat: update url params logic Signed-off-by: ryanwolhuter --- src/hooks/useDocumentDriveServer.ts | 47 +------------------------ src/hooks/useDrivesContainer.ts | 12 +++++-- src/pages/content.tsx | 54 ++++++++++++++++++----------- 3 files changed, 44 insertions(+), 69 deletions(-) diff --git a/src/hooks/useDocumentDriveServer.ts b/src/hooks/useDocumentDriveServer.ts index 7f66c9eb..0baed7f5 100644 --- a/src/hooks/useDocumentDriveServer.ts +++ b/src/hooks/useDocumentDriveServer.ts @@ -276,32 +276,13 @@ export function useDocumentDriveServer( if (!drive) return; - const targetNodeChildrenNames = drive.state.global.nodes - .filter(node => - decodedTargetId === '' - ? node.parentFolder === null - : node.parentFolder === decodedTargetId, - ) - .map(node => node.name); - - console.log(drive.state.global.nodes, decodedTargetId); - - console.log({ targetNodeChildrenNames }); - - const targetHasNodesWithSameName = - targetNodeChildrenNames.includes(srcName); - - const targetName = targetHasNodesWithSameName - ? `${srcName} (copy) ${getNextCopyNumber(targetNodeChildrenNames, srcName)}` - : srcName; - const generateId = () => utils.hashKey(); const copyNodesInput = documentDriveUtils.generateNodesCopy( { srcId, targetParentFolder: decodedTargetId, - targetName, + targetName: srcName, }, generateId, drive.state.global.nodes, @@ -507,29 +488,3 @@ export function useDocumentDriveServer( [documentDrives], ); } - -function getNextCopyNumber(files: string[], baseFilename: string): number { - let maxNumber = 0; // Start by assuming no copies exist - - // Regex to find files that match the base filename followed by " (copy)" and possibly a number - const regex = new RegExp( - `^${escapeRegExp(baseFilename)} \\(copy\\)(?: (\\d+))?$`, - ); - - for (const file of files) { - const match = file.match(regex); - if (match) { - const number = match[1] ? parseInt(match[1], 10) : 1; - if (number > maxNumber) { - maxNumber = number; - } - } - } - - return maxNumber + 1; // Return the next available number -} - -// Helper function to escape any special characters in the filename for use in a regex -function escapeRegExp(string: string) { - return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string -} diff --git a/src/hooks/useDrivesContainer.ts b/src/hooks/useDrivesContainer.ts index ff0a6a4b..b15bd503 100644 --- a/src/hooks/useDrivesContainer.ts +++ b/src/hooks/useDrivesContainer.ts @@ -183,6 +183,12 @@ export function useDrivesContainer() { decodeID(item.id), item.sharingType?.toLowerCase() as TreeItemSharingType, ); + break; + case 'duplicate': + await onSubmitInput({ + ...item, + action: 'UPDATE_AND_COPY', + }); } }; @@ -191,7 +197,7 @@ export function useDrivesContainer() { await renameNode(decodedDriveID, item.id, item.label); } - const onSubmitInput = async (item: TreeItem, onCancel?: () => void) => { + async function onSubmitInput(item: TreeItem, onCancel?: () => void) { const driveId = getRootPath(item.path); const isCreateNewOperation = item.action === 'NEW'; @@ -201,7 +207,7 @@ export function useDrivesContainer() { if (isCreateNewOperation) { actions.deleteVirtualItem(item.id); await addNewFolder(item, driveId); - return; + return; } const srcId = item.id; @@ -245,7 +251,7 @@ export function useDrivesContainer() { } await updateNodeName(item, driveId); - }; + } async function driveToBaseItems(drive: DocumentDriveDocument) { const driveID = encodeID(drive.state.global.id); diff --git a/src/pages/content.tsx b/src/pages/content.tsx index b1325170..5bf2999a 100644 --- a/src/pages/content.tsx +++ b/src/pages/content.tsx @@ -119,30 +119,44 @@ const Content = () => { // builds the path from the url checking if the nodes exist const path = [encodeID(drive.state.global.id)]; + let currentNodes = drive.state.global.nodes.filter( + node => node.parentFolder === null, + ); if (params['*']) { - for (const nodeId of decodeURIComponent(params['*']).split( - '/', - )) { - const node = drive.state.global.nodes.find( - node => node.name === nodeId || node.id === nodeId, + const nodeNames = decodeURIComponent(params['*']).split('/'); + + for (const nodeName of nodeNames) { + const node = currentNodes.find( + node => node.name === nodeName, ); - if (node) { - // if the node is a file, then opens it instead of adding it to the path - if (isFileNode(node)) { - if ( - selectedFileNode?.drive !== - drive.state.global.id || - selectedFileNode.id !== node.id - ) { - setSelectedFileNode({ - drive: drive.state.global.id, - id: node.id, - }); - } - break; + + if (!node) { + console.error('Node not found:', nodeName); + break; + } + + // if the node is a file, then opens it instead of adding it to the path + if (isFileNode(node)) { + if ( + selectedFileNode?.drive !== drive.state.global.id || + selectedFileNode.id !== node.id + ) { + setSelectedFileNode({ + drive: drive.state.global.id, + id: node.id, + }); } - path.push(encodeID(node.id)); + break; } + path.push(encodeID(node.id)); + + const nextNodes = drive.state.global.nodes.filter( + n => n.parentFolder === node.id, + ); + + if (!nextNodes.length) break; + + currentNodes = nextNodes; } } setSelectedPath(path.join('/')); From aee1dce7f1c927ca24ac5283ab3d4d48ca85b7f6 Mon Sep 17 00:00:00 2001 From: Guillermo Puente Date: Tue, 23 Apr 2024 17:29:15 -0400 Subject: [PATCH 15/17] feat: update document-model document-drive and document-model-libs deps --- package-lock.json | 28 ++++++++++++++-------------- package.json | 6 +++--- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9ead4f88..9018fc4a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,9 +12,9 @@ "@powerhousedao/design-system": "1.0.0-alpha.100", "@sentry/react": "^7.109.0", "did-key-creator": "^1.2.0", - "document-drive": "^1.0.0-alpha.46", - "document-model": "^1.0.52", - "document-model-libs": "^1.36.0", + "document-drive": "^1.0.0-alpha.50", + "document-model": "^1.0.53", + "document-model-libs": "^1.37.0", "electron-is-dev": "^3.0.1", "electron-squirrel-startup": "^1.0.0", "electron-store": "^8.1.0", @@ -9345,9 +9345,9 @@ } }, "node_modules/document-drive": { - "version": "1.0.0-alpha.46", - "resolved": "https://registry.npmjs.org/document-drive/-/document-drive-1.0.0-alpha.46.tgz", - "integrity": "sha512-vInSQsqy0u1OVlGGe7GcToUZpdauq7m4eRZ7UO4CSsehFp9g6JkC2RXtwAPJt7hqmeCZVVBJE9WfooxuniBCrw==", + "version": "1.0.0-alpha.50", + "resolved": "https://registry.npmjs.org/document-drive/-/document-drive-1.0.0-alpha.50.tgz", + "integrity": "sha512-SRZTnzvKxupeh5nj7b+ZtYmDOx6dRDdUKlwTlcCoWeC31vpPTRqNssp8O8K3yldl/ZomIMVlVxGv/66pzqUUoA==", "dependencies": { "graphql": "^16.8.1", "graphql-request": "^6.1.0", @@ -9363,14 +9363,14 @@ "sqlite3": "^5.1.7" }, "peerDependencies": { - "document-model": "^1.0.52", - "document-model-libs": "^1.36.0" + "document-model": "^1.0.53", + "document-model-libs": "^1.37.0" } }, "node_modules/document-model": { - "version": "1.0.52", - "resolved": "https://registry.npmjs.org/document-model/-/document-model-1.0.52.tgz", - "integrity": "sha512-zP6jVkVVJWelsdYpagOtcIouHWUYnVVRWeAwSC2YC0SOxowERG+NtSRx2Uk2v6UFVWOA78sPAeY4NQaNB0yWOw==", + "version": "1.0.53", + "resolved": "https://registry.npmjs.org/document-model/-/document-model-1.0.53.tgz", + "integrity": "sha512-Ld+ECcBFEP6l83YArZJH/TmUqYGX1n+sC9dvKw2icnvlzxnlkjzMJUdsVBcGX8pLRx+pHd6v2Vu5N3ffaKMsqg==", "dependencies": { "change-case": "^5.4.3", "immer": "^10.0.3", @@ -9381,9 +9381,9 @@ } }, "node_modules/document-model-libs": { - "version": "1.36.0", - "resolved": "https://registry.npmjs.org/document-model-libs/-/document-model-libs-1.36.0.tgz", - "integrity": "sha512-XVCx8GPqXXmy1Kb+9JY2pNwdu3V4KRi8tvhzost8WdFTnI+KlJS+VQTs5j9LlwZ66NxzINxnEUS7WOqgDxmx7g==", + "version": "1.37.0", + "resolved": "https://registry.npmjs.org/document-model-libs/-/document-model-libs-1.37.0.tgz", + "integrity": "sha512-yVoeKCLhFfI2MbrFMwtx+poXmfx5FtACzH4Dyp4EKXjHHITA+vhxbZ9eVpBJLypjXk8NYib2WOmAKza2igP0cA==", "dependencies": { "@acaldas/graphql-codegen-typescript-validation-schema": "^0.12.3", "@graphql-codegen/core": "^4.0.2", diff --git a/package.json b/package.json index 92567f7d..942b1752 100644 --- a/package.json +++ b/package.json @@ -92,9 +92,9 @@ "@powerhousedao/design-system": "1.0.0-alpha.100", "@sentry/react": "^7.109.0", "did-key-creator": "^1.2.0", - "document-drive": "^1.0.0-alpha.46", - "document-model": "^1.0.52", - "document-model-libs": "^1.36.0", + "document-drive": "^1.0.0-alpha.50", + "document-model": "^1.0.53", + "document-model-libs": "^1.37.0", "electron-is-dev": "^3.0.1", "electron-squirrel-startup": "^1.0.0", "electron-store": "^8.1.0", From 1db971cf324e2ca0e92c8f9b01614f7ef64f3d6a Mon Sep 17 00:00:00 2001 From: ryanwolhuter Date: Wed, 24 Apr 2024 08:55:09 +0200 Subject: [PATCH 16/17] feat: remove check Signed-off-by: ryanwolhuter --- src/hooks/useDocumentDriveServer.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/hooks/useDocumentDriveServer.ts b/src/hooks/useDocumentDriveServer.ts index 9871db96..2a697e3f 100644 --- a/src/hooks/useDocumentDriveServer.ts +++ b/src/hooks/useDocumentDriveServer.ts @@ -364,9 +364,6 @@ export function useDocumentDriveServer( } async function addRemoteDrive(url: string, options: RemoteDriveOptions) { - if (!isAllowedToCreateDocuments) { - throw new Error('User is not allowed to create drives'); - } await server.addRemoteDrive(url, options); await refreshDocumentDrives(); } From d766c36649f3575b2d10bcaf532249437a79b36c Mon Sep 17 00:00:00 2001 From: ryanwolhuter Date: Wed, 24 Apr 2024 09:37:37 +0200 Subject: [PATCH 17/17] feat: bump libs Signed-off-by: ryanwolhuter --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9018fc4a..6276b082 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,7 @@ "did-key-creator": "^1.2.0", "document-drive": "^1.0.0-alpha.50", "document-model": "^1.0.53", - "document-model-libs": "^1.37.0", + "document-model-libs": "^1.38.0", "electron-is-dev": "^3.0.1", "electron-squirrel-startup": "^1.0.0", "electron-store": "^8.1.0", @@ -9381,9 +9381,9 @@ } }, "node_modules/document-model-libs": { - "version": "1.37.0", - "resolved": "https://registry.npmjs.org/document-model-libs/-/document-model-libs-1.37.0.tgz", - "integrity": "sha512-yVoeKCLhFfI2MbrFMwtx+poXmfx5FtACzH4Dyp4EKXjHHITA+vhxbZ9eVpBJLypjXk8NYib2WOmAKza2igP0cA==", + "version": "1.38.0", + "resolved": "https://registry.npmjs.org/document-model-libs/-/document-model-libs-1.38.0.tgz", + "integrity": "sha512-hS2bhC2ZgvXNIDyPTF/oPJLmtiCnymcCL/VuVUkZ1ehqwcebMWU+7fXOG7hoHR/SgW1BSgXgCDjK2G9rsIUvNA==", "dependencies": { "@acaldas/graphql-codegen-typescript-validation-schema": "^0.12.3", "@graphql-codegen/core": "^4.0.2", diff --git a/package.json b/package.json index a53ffd4d..e11e07aa 100644 --- a/package.json +++ b/package.json @@ -95,7 +95,7 @@ "did-key-creator": "^1.2.0", "document-drive": "^1.0.0-alpha.50", "document-model": "^1.0.53", - "document-model-libs": "^1.37.0", + "document-model-libs": "^1.38.0", "electron-is-dev": "^3.0.1", "electron-squirrel-startup": "^1.0.0", "electron-store": "^8.1.0",