From 511854369fd83bee9d4b840c2aeffd1355d9f983 Mon Sep 17 00:00:00 2001 From: Anoop M D Date: Sun, 24 Sep 2023 23:53:31 +0530 Subject: [PATCH] feat(#205): collection properties dropdown --- .../Collection/CollectionProperties/index.js | 50 +++++++++++++++++++ .../Sidebar/Collections/Collection/index.js | 14 ++++++ 2 files changed, 64 insertions(+) create mode 100644 packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionProperties/index.js diff --git a/packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionProperties/index.js b/packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionProperties/index.js new file mode 100644 index 00000000..a5718944 --- /dev/null +++ b/packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionProperties/index.js @@ -0,0 +1,50 @@ +import React from 'react'; +import Modal from 'components/Modal'; + +function countRequests(items) { + let count = 0; + + function recurse(item) { + if (item && typeof item === 'object') { + if (item.type !== 'folder') { + count++; + } + if (Array.isArray(item.items)) { + item.items.forEach(recurse); + } + } + } + + items.forEach(recurse); + + return count; +} + +const CollectionProperties = ({ collection, onClose }) => { + return ( + + + + + + + + + + + + + + + + + + + + +
Name :{collection.name}
Location :{collection.pathname}
Environments :{collection.environments.length}
Requests :{countRequests(collection.items)}
+
+ ); +}; + +export default CollectionProperties; diff --git a/packages/bruno-app/src/components/Sidebar/Collections/Collection/index.js b/packages/bruno-app/src/components/Sidebar/Collections/Collection/index.js index c31ed7e7..e81b53a8 100644 --- a/packages/bruno-app/src/components/Sidebar/Collections/Collection/index.js +++ b/packages/bruno-app/src/components/Sidebar/Collections/Collection/index.js @@ -12,6 +12,7 @@ import NewRequest from 'components/Sidebar/NewRequest'; import NewFolder from 'components/Sidebar/NewFolder'; import CollectionItem from './CollectionItem'; import RemoveCollection from './RemoveCollection'; +import CollectionProperties from './CollectionProperties'; import RunCollectionItem from './CollectionItem/RunCollectionItem'; import { doesCollectionHaveItemsMatchingSearchText } from 'utils/collections/search'; import { isItemAFolder, isItemARequest, transformCollectionToSaveToIdb } from 'utils/collections'; @@ -26,6 +27,7 @@ const Collection = ({ collection, searchText }) => { const [showRenameCollectionModal, setShowRenameCollectionModal] = useState(false); const [showRemoveCollectionModal, setShowRemoveCollectionModal] = useState(false); const [showRunCollectionModal, setShowRunCollectionModal] = useState(false); + const [collectionPropertiesModal, setCollectionPropertiesModal] = useState(false); const [collectionIsCollapsed, setCollectionIsCollapsed] = useState(collection.collapsed); const dispatch = useDispatch(); @@ -106,6 +108,9 @@ const Collection = ({ collection, searchText }) => { {showRunCollectionModal && ( setShowRunCollectionModal(false)} /> )} + {collectionPropertiesModal && ( + setCollectionPropertiesModal(false)} /> + )}
{ > Export
+
{ + menuDropdownTippyRef.current.hide(); + setCollectionPropertiesModal(true); + }} + > + Properties +
{