diff --git a/packages/bruno-app/src/components/FolderSettings/Auth/index.js b/packages/bruno-app/src/components/FolderSettings/Auth/index.js index 89b109f82..138503fec 100644 --- a/packages/bruno-app/src/components/FolderSettings/Auth/index.js +++ b/packages/bruno-app/src/components/FolderSettings/Auth/index.js @@ -16,7 +16,7 @@ import NTLMAuth from 'components/RequestPane/Auth/NTLMAuth'; import WsseAuth from 'components/RequestPane/Auth/WsseAuth'; import ApiKeyAuth from 'components/RequestPane/Auth/ApiKeyAuth'; import AwsV4Auth from 'components/RequestPane/Auth/AwsV4Auth'; -import { findItemInCollection, findParentItemInCollection, humanizeRequestAuthMode } from 'utils/collections/index'; + import { humanizeRequestAuthMode, getTreePathFromCollectionToItem } from 'utils/collections/index'; const GrantTypeComponentMap = ({ collection, folder }) => { const dispatch = useDispatch(); @@ -45,15 +45,7 @@ const Auth = ({ collection, folder }) => { let request = get(folder, 'root.request', {}); const authMode = get(folder, 'root.request.auth.mode'); - const getTreePathFromCollectionToFolder = (collection, _folder) => { - let path = []; - let item = findItemInCollection(collection, _folder?.uid); - while (item) { - path.unshift(item); - item = findParentItemInCollection(collection, item?.uid); - } - return path; - }; + const getEffectiveAuthSource = () => { if (authMode !== 'inherit') return null; @@ -66,7 +58,7 @@ const Auth = ({ collection, folder }) => { }; // Get path from collection to current folder - const folderTreePath = getTreePathFromCollectionToFolder(collection, folder); + const folderTreePath = getTreePathFromCollectionToItem(collection, folder); // Check parent folders to find closest auth configuration // Skip the last item which is the current folder diff --git a/packages/bruno-app/src/components/RequestPane/Auth/index.js b/packages/bruno-app/src/components/RequestPane/Auth/index.js index 8ca23ab8d..51a69bddd 100644 --- a/packages/bruno-app/src/components/RequestPane/Auth/index.js +++ b/packages/bruno-app/src/components/RequestPane/Auth/index.js @@ -9,6 +9,7 @@ import WsseAuth from './WsseAuth'; import NTLMAuth from './NTLMAuth'; import { updateAuth } from 'providers/ReduxStore/slices/collections'; import { saveRequest } from 'providers/ReduxStore/slices/collections/actions'; +import { useDispatch } from 'react-redux'; import ApiKeyAuth from './ApiKeyAuth'; import StyledWrapper from './StyledWrapper'; @@ -27,6 +28,7 @@ const getTreePathFromCollectionToItem = (collection, _item) => { }; const Auth = ({ item, collection }) => { + const dispatch = useDispatch(); const authMode = item.draft ? get(item, 'draft.request.auth.mode') : get(item, 'request.auth.mode'); const requestTreePath = getTreePathFromCollectionToItem(collection, item); @@ -37,7 +39,7 @@ const Auth = ({ item, collection }) => { // Save function for request level const save = () => { - return saveRequest(item.uid, collection.uid); + return dispatch(saveRequest(item.uid, collection.uid)); }; const getEffectiveAuthSource = () => {