Skip to content

Commit

Permalink
fix: Closing of folder settings when deleting folder
Browse files Browse the repository at this point in the history
Also show an info text, if an item was not found
this was a regression, after the main-content rewrite

Closes usebruno#3606
  • Loading branch information
Its-treason committed Dec 7, 2024
1 parent 963a12a commit cbe9737
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const RequestTab = ({ tab, collection, tabIndex, collectionRequestTabs, folderUi
return folderUid ? findItemInCollection(collection, folderUid) : null;
}, [folderUid]);
if (['collection-settings', 'folder-settings', 'variables', 'collection-runner'].includes(tab.type)) {
console.log(folder);
return (
<RequestTabMenu
collection={collection}
Expand All @@ -66,7 +67,11 @@ const RequestTab = ({ tab, collection, tabIndex, collectionRequestTabs, folderUi
className="flex items-center justify-between tab-container px-1"
>
{tab.type === 'folder-settings' ? (
<SpecialTab handleCloseClick={handleCloseClick} type={tab.type} tabName={folder?.name} />
!folder ? (
<RequestTabNotFound handleCloseClick={handleCloseClick} />
) : (
<SpecialTab handleCloseClick={handleCloseClick} type={tab.type} tabName={folder?.name} />
)
) : (
<SpecialTab handleCloseClick={handleCloseClick} type={tab.type} />
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { RequestUrlBar } from 'src/feature/request-url-bar';
import { HttpRequestPane } from './panes/http/HttpRequestPane';
import { GraphqlRequestPane } from './panes/graphql/GraphqlRequestPane';
import { ResponsePane } from './panes/response/ResponsePane';
import { Text } from '@mantine/core';

type MainContentProps = {
collection: CollectionSchema;
Expand All @@ -24,8 +25,14 @@ export const MainContent: React.FC<MainContentProps> = ({ collection, focusedTab
case 'collection-settings':
return <CollectionSettings collection={collection} />;
case 'folder-settings':
if (!item) {
return <Text p="md">Folder not found! It was probably manually deleted. You can close this tab.</Text>;
}
return <FolderSettings collection={collection} folder={item} />;
default:
if (!item) {
return <Text p="md">Request not found! It was probably manually deleted. You can close this tab.</Text>;
}
return (
<>
<RequestUrlBar item={item} collection={collection} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const DeleteItemModalContent: React.FC<DeleteItemModalProps> = ({ onClose

await dispatch(deleteItem(item.uid, collectionUid));

const tabUids = item.type === 'folder' ? recursivelyGetAllItemUids(item.items) : [item.uid];
const tabUids = item.type === 'folder' ? [...recursivelyGetAllItemUids(item.items), item.uid] : [item.uid];
dispatch(
closeTabs({
tabUids
Expand Down

0 comments on commit cbe9737

Please sign in to comment.