forked from usebruno/bruno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent losing unsaved environment variable data when attempting to c…
…hange env (usebruno#2034) * trying to begin changes * Env bug fixed with only switching env when saved * dialog box working, formik in EnvironmentSettings to pass props, selectedEnvironment in EnvrionmentSettings to pass props * Removing some uneccessary comments * no immediate following dialog pop up after warning dialog * Wrapping commit warning moidal in CreatePortal, removing unnecessary isModified state, removing comments * modifying dialog and adding formik back to EnvironmentVariables * Removing unnecessary comments --------- Co-authored-by: Anoop M D <[email protected]>
- Loading branch information
1 parent
16861c9
commit c17e4ef
Showing
5 changed files
with
129 additions
and
19 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
...o-app/src/components/Environments/EnvironmentSettings/EnvironmentList/ConfirmSwitchEnv.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import React from 'react'; | ||
import { IconAlertTriangle } from '@tabler/icons'; | ||
import Modal from 'components/Modal'; | ||
import { createPortal } from 'react-dom'; | ||
|
||
const ConfirmSwitchEnv = ({ onCancel }) => { | ||
return createPortal( | ||
<Modal | ||
size="md" | ||
title="Unsaved changes" | ||
confirmText="Save and Close" | ||
cancelText="Close without saving" | ||
disableEscapeKey={true} | ||
disableCloseOnOutsideClick={true} | ||
closeModalFadeTimeout={150} | ||
handleCancel={onCancel} | ||
onClick={(e) => { | ||
e.stopPropagation(); | ||
e.preventDefault(); | ||
}} | ||
hideFooter={true} | ||
> | ||
<div className="flex items-center font-normal"> | ||
<IconAlertTriangle size={32} strokeWidth={1.5} className="text-yellow-600" /> | ||
<h1 className="ml-2 text-lg font-semibold">Hold on..</h1> | ||
</div> | ||
<div className="font-normal mt-4">You have unsaved changes in this environment.</div> | ||
|
||
<div className="flex justify-between mt-6"> | ||
<div> | ||
<button className="btn btn-sm btn-danger" onClick={onCancel}> | ||
Close | ||
</button> | ||
</div> | ||
<div></div> | ||
</div> | ||
</Modal>, | ||
document.body | ||
); | ||
}; | ||
|
||
export default ConfirmSwitchEnv; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters