Skip to content

Commit 1165ad3

Browse files
authored
Merge pull request #24 from mhmaidi789/warningModal
Added warning screen when changing tests without saving
2 parents b7630de + 40a3cd0 commit 1165ad3

File tree

7 files changed

+52
-6
lines changed

7 files changed

+52
-6
lines changed

src/components/Modals/Modal.jsx

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,52 @@ const Modal = ({
9696
dispatchToGlobal(setTabIndex(2));
9797
};
9898

99+
// Warning that tests will not be saved while transitioning between test types
100+
if (title === 'New Test') {
101+
return (
102+
<ReactModal
103+
className={styles.modal}
104+
isOpen={isModalOpen}
105+
onRequestClose={closeModal}
106+
contentLabel="Save?"
107+
shouldCloseOnOverlayClick={true}
108+
shouldCloseOnEsc={true}
109+
ariaHideApp={false}
110+
style={{
111+
content: {
112+
top: '20%',
113+
left: isFileDirectoryOpen ? '22%' : '11%',
114+
},
115+
overlay: {
116+
zIndex: 3,
117+
left: isFileDirectoryOpen ? '276px' : '46px',
118+
minWidth: isFileDirectoryOpen ? '600px' : '600px',
119+
width: isFileDirectoryOpen ? 'calc(59.9% - 276px)':'calc(49.9% - 46px)',
120+
},
121+
}}>
122+
<div id={styles.title}>
123+
<p>{title}</p>
124+
</div>
125+
126+
<div id={styles.body}>
127+
<p id={styles.text}>
128+
Do you want to start a new test? All unsaved changes
129+
<br/>
130+
will be lost.
131+
</p>
132+
<span id={styles.newTestButtons} style={{justifyContent: 'center', alignItems: 'center'}}>
133+
<button id={styles.save} onClick={handleNewTest}>
134+
{title}
135+
</button>
136+
<button id={styles.save} onClick={closeModal}>
137+
Cancel
138+
</button>
139+
</span>
140+
</div>
141+
</ReactModal>
142+
);
143+
}
144+
99145
return (
100146
<ReactModal
101147
className={styles.modal2}

src/components/TestMenu/AccTestMenu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const AccTestMenu = () => {
6060
<div id='test'>
6161
<div id={styles.testMenu}>
6262
<div id={styles.left}>
63-
<button id={styles.newTestBtn} autoFocus onClick={openNewTestModal}>New Test +</button>
63+
<button id={styles.newTestBtn} autoFocus onClick={openModal}>New Test +</button>
6464
<button onClick={fileHandle}>Preview</button>
6565
<button id={styles.example} onClick={openScriptModal} >
6666
Run Test

src/components/TestMenu/EndpointTestMenu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ const EndpointTestMenu = () => {
7777
<div id='test'>
7878
<div id={styles.testMenu}>
7979
<div id={styles.left}>
80-
<button onClick={openNewTestModal} autoFocus >New Test +</button>
80+
<button onClick={openModal} autoFocus >New Test +</button>
8181
<button id={styles.preview} onClick={fileHandle}>
8282
Preview
8383
</button>

src/components/TestMenu/HooksTestMenu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ const HooksTestMenu = () => {
6767
<div id='test'>
6868
<div id={styles.testMenu}>
6969
<div id={styles.left}>
70-
<button type='button' autoFocus onClick={openNewTestModal}>
70+
<button type='button' autoFocus onClick={openModal}>
7171
New Test +
7272
</button>
7373
<button id={styles.example} onClick={fileHandle}>

src/components/TestMenu/PuppeteerTestMenu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const PuppeteerTestMenu = () => {
6262
<div id='test'>
6363
<div id={styles.testMenu}>
6464
<div id={styles.left}>
65-
<button type='button' autoFocus data-testid='puppeteerNewTestButton' onClick={openNewTestModal}>
65+
<button type='button' autoFocus data-testid='puppeteerNewTestButton' onClick={openModal}>
6666
New Test +
6767
</button>
6868
<button onClick={fileHandle}>Preview</button>

src/components/TestMenu/ReactTestMenu.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const ReactTestMenu = () => {
5858
<div id='test'>
5959
<div id={styles.testMenu}>
6060
<div id={styles.left}>
61-
<button onClick={openNewTestModal} autoFocus >New Test +</button>
61+
<button onClick={openModal} autoFocus >New Test +</button>
6262
<button onClick={fileHandle}>Preview</button>
6363
<button id={styles.example} onClick={openScriptModal}>
6464
Run Test

src/components/TestMenu/ReduxTestMenu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ const ReduxTestMenu = () => {
7575
<div id='test'>
7676
<div id={styles.testMenu}>
7777
<div id={styles.left}>
78-
<button onClick={openNewTestModal} autoFocus >New Test +</button>
78+
<button onClick={openModal} autoFocus >New Test +</button>
7979
<button id={styles.preview} onClick={fileHandle}>
8080
Preview
8181
</button>

0 commit comments

Comments
 (0)