handleCloseWithoutSave([item])}
- onSaveAndClose={() => handleSaveAndClose([item])}
- />
- );
- }
-
return (
-
diff --git a/packages/bruno-app/src/providers/App/ConfirmAppClose/SaveRequestsModal.js b/packages/bruno-app/src/components/SaveRequestsModal/index.js
similarity index 62%
rename from packages/bruno-app/src/providers/App/ConfirmAppClose/SaveRequestsModal.js
rename to packages/bruno-app/src/components/SaveRequestsModal/index.js
index 76a5f1a8b..764095730 100644
--- a/packages/bruno-app/src/providers/App/ConfirmAppClose/SaveRequestsModal.js
+++ b/packages/bruno-app/src/components/SaveRequestsModal/index.js
@@ -1,11 +1,61 @@
import React, { useEffect } from 'react';
+import { useDispatch } from 'react-redux';
import { pluralizeWord } from 'utils/common';
import { IconAlertTriangle } from '@tabler/icons';
import Modal from 'components/Modal';
+import { saveMultipleRequests } from 'providers/ReduxStore/slices/collections/actions';
+
+const SingleRequestMessage = ({ item }) => {
+ return (
+
+ You have unsaved changes in request {item.name}.
+
+ )
+}
+
+const MultipleRequestsMessage = ({ items, maxItems }) => {
+ return (
+ <>
+
+ Do you want to save the changes you made to the following{' '}
+ {items.length} {pluralizeWord('request', items.length)}?
+
+
+
+ {items.slice(0, maxItems).map((item) => {
+ return (
+ -
+ {item.filename}
+
+ );
+ })}
+
+
+ {items.length > maxItems && (
+
+ ...{items.length - maxItems} additional{' '}
+ {pluralizeWord('request', items.length - maxItems)} not shown
+
+ )}
+ >
+ )
+}
const SaveRequestsModal = ({ onSaveAndClose, onCloseWithoutSave, onCancel, items = [] }) => {
+
+ const dispatch = useDispatch();
const MAX_UNSAVED_REQUESTS_TO_SHOW = 5;
+ const handleSaveAndClose = async () => {
+ await dispatch(saveMultipleRequests(items));
+ onSaveAndClose(items);
+ }
+
+ const handleCloseWithoutSave = async () => {
+ onCloseWithoutSave(items);
+ }
+
+
useEffect(() => {
if (items.length === 0) {
return onCloseWithoutSave([]);
@@ -32,31 +82,13 @@ const SaveRequestsModal = ({ onSaveAndClose, onCloseWithoutSave, onCancel, items
Hold on..
-
- Do you want to save the changes you made to the following{' '}
- {items.length} {pluralizeWord('request', items.length)}?
-
-
-
- {items.slice(0, MAX_UNSAVED_REQUESTS_TO_SHOW).map((item) => {
- return (
- -
- {item.filename}
-
- );
- })}
-
-
- {items.length > MAX_UNSAVED_REQUESTS_TO_SHOW && (
-
- ...{items.length - MAX_UNSAVED_REQUESTS_TO_SHOW} additional{' '}
- {pluralizeWord('request', items.length - MAX_UNSAVED_REQUESTS_TO_SHOW)} not shown
-
- )}
-
+ {items.length > 1 ?
+ :
+
+ }
-
@@ -64,7 +96,7 @@ const SaveRequestsModal = ({ onSaveAndClose, onCloseWithoutSave, onCancel, items
Cancel
-
onSaveAndClose(items)}>
+
{items.length > 1 ? 'Save All' : 'Save'}
diff --git a/packages/bruno-app/src/providers/App/ConfirmAppClose/index.js b/packages/bruno-app/src/providers/App/ConfirmAppClose/index.js
index 8b37feaa6..1b1bd3fa3 100644
--- a/packages/bruno-app/src/providers/App/ConfirmAppClose/index.js
+++ b/packages/bruno-app/src/providers/App/ConfirmAppClose/index.js
@@ -5,9 +5,8 @@ import { findCollectionByUid, flattenItems, isItemARequest } from 'utils/collect
import each from 'lodash/each';
import filter from 'lodash/filter';
import groupBy from 'lodash/groupBy';
-import SaveRequestsModal from './SaveRequestsModal';
+import SaveRequestsModal from 'components/SaveRequestsModal';
import { isElectron } from 'utils/common/platform';
-import { saveMultipleRequests } from 'providers/ReduxStore/slices/collections/actions';
import { completeQuitFlow } from 'providers/ReduxStore/slices/app';
const ConfirmAppClose = () => {
@@ -56,15 +55,10 @@ const ConfirmAppClose = () => {
const quit = () => dispatch(completeQuitFlow());
- const handleSaveAndClose = async items => {
- await dispatch(saveMultipleRequests(items));
- quit();
- }
-
return setShowConfirmClose(false)}
onCloseWithoutSave={quit}
- onSaveAndClose={handleSaveAndClose} />;
+ onSaveAndClose={quit} />;
};
export default ConfirmAppClose;