Skip to content

Commit 6503e0e

Browse files
authored
Merge pull request #211 from psiinon/edge-dl-fix2
2 parents 1dfa82f + 9e13513 commit 6503e0e

File tree

7 files changed

+20
-26
lines changed

7 files changed

+20
-26
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
88
### Fixed
99
- Download on script completion on Chrome.
1010
- Download file date string.
11+
- Download via popup on Edge.
12+
- Close notification dialog when script downloaded directly.
1113

1214
## 0.1.2 - 2025-06-17
1315

CHANGELOG.rec.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
88
### Fixed
99
- Download on script completion on Chrome.
1010
- Download file date string.
11+
- Download via popup on Edge.
12+
- Close notification dialog when script downloaded directly.
1113

1214
## 0.1.2 - 2025-06-17
1315

source/Background/index.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import {
3030
REPORT_OBJECT,
3131
RESET_ZEST_SCRIPT,
3232
SESSION_STORAGE,
33-
SET_SAVE_SCRIPT_ENABLE,
3433
STOP_RECORDING,
3534
ZEST_SCRIPT,
3635
} from '../utils/constants';
@@ -249,11 +248,6 @@ async function handleMessage(
249248
}
250249
break;
251250
}
252-
case SET_SAVE_SCRIPT_ENABLE:
253-
Browser.storage.sync.set({
254-
zapenablesavescript: zestScript.getZestStatementCount() > 0,
255-
});
256-
break;
257251

258252
default:
259253
// Handle unknown request type

source/Popup/index.tsx

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import {
2525
GET_ZEST_SCRIPT,
2626
IS_FULL_EXTENSION,
2727
RESET_ZEST_SCRIPT,
28-
SET_SAVE_SCRIPT_ENABLE,
2928
STOP_RECORDING,
3029
UPDATE_TITLE,
3130
ZAP_START_RECORDING,
@@ -57,9 +56,6 @@ const loginUrlInput = document.getElementById(
5756
const scriptNameInput = document.getElementById(
5857
'script-name-input'
5958
) as HTMLInputElement;
60-
const saveScriptButton = document.getElementById(
61-
'save-script'
62-
) as HTMLButtonElement;
6359

6460
function sendMessageToContentScript(message: string, data = ''): void {
6561
Browser.tabs.query({active: true, currentWindow: true}).then((tabs) => {
@@ -90,14 +86,12 @@ function startedAnimation(): void {
9086

9187
async function restoreState(): Promise<void> {
9288
console.log('Restore state');
93-
await Browser.runtime.sendMessage({type: SET_SAVE_SCRIPT_ENABLE});
9489
optionsIcon.title = OPTIONS;
9590
downloadIcon.title = DOWNLOAD;
9691
Browser.storage.sync
9792
.get({
9893
zaprecordingactive: false,
9994
zapscriptname: '',
100-
zapenablesavescript: false,
10195
})
10296
.then((items) => {
10397
if (items.zaprecordingactive) {
@@ -111,11 +105,6 @@ async function restoreState(): Promise<void> {
111105
} else {
112106
done?.classList.add('invisible');
113107
}
114-
if (!items.zapenablesavescript) {
115-
saveScriptButton.classList.add('disabled');
116-
} else {
117-
saveScriptButton.classList.remove('disabled');
118-
}
119108
});
120109
}
121110

@@ -189,7 +178,14 @@ function openHelpPage(): void {
189178
closePopup();
190179
}
191180

192-
function downloadZestScript(zestScriptJSON: string, title: string): void {
181+
function downloadZestScript(
182+
zestScriptJSON: string,
183+
title: string,
184+
statementCount: number
185+
): void {
186+
if (statementCount === 0) {
187+
return;
188+
}
193189
if (title === '') {
194190
scriptNameInput?.focus();
195191
return;
@@ -211,11 +207,12 @@ async function handleSaveScript(): Promise<void> {
211207
zaprecordingactive: false,
212208
});
213209
if (storageItems.zaprecordingactive) {
210+
sendMessageToContentScript(ZAP_STOP_RECORDING);
214211
await Browser.runtime.sendMessage({type: STOP_RECORDING});
215212
}
216213
Browser.runtime.sendMessage({type: GET_ZEST_SCRIPT}).then((items) => {
217214
const msg = items as ZestScriptMessage;
218-
downloadZestScript(msg.script, msg.title);
215+
downloadZestScript(msg.script, msg.title, msg.statementCount);
219216
});
220217
}
221218

source/Popup/styles.scss

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -275,11 +275,6 @@ html {
275275
color: var(--primary);
276276
}
277277
&:hover {color: var(--primary);}
278-
279-
&.disabled {
280-
pointer-events: none;
281-
opacity: 0.5;
282-
}
283278
}
284279

285280
@keyframes waves {

source/types/zestScript/ZestScript.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import Browser from 'webextension-polyfill';
2222
interface ZestScriptMessage {
2323
script: string;
2424
title: string;
25+
statementCount: number;
2526
}
2627

2728
class ZestScript {
@@ -93,7 +94,11 @@ class ZestScript {
9394
return new Promise((resolve) => {
9495
Browser.storage.sync.get({zapscriptname: this.title}).then((items) => {
9596
this.title = items.zapscriptname as string;
96-
resolve({script: this.toJSON(), title: this.title});
97+
resolve({
98+
script: this.toJSON(),
99+
title: this.title,
100+
statementCount: this.getZestStatementCount(),
101+
});
97102
});
98103
});
99104
}

source/utils/constants.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ export const DEFAULT_WINDOW_HANDLE = 'windowHandle1';
3838

3939
export const ZAP_STOP_RECORDING = 'zapStopRecording';
4040
export const ZAP_START_RECORDING = 'zapStartRecording';
41-
export const SET_SAVE_SCRIPT_ENABLE = 'setSaveScriptEnable';
4241
export const ZEST_SCRIPT = 'zestScript';
4342

4443
export const STOP_RECORDING = 'stopRecording';

0 commit comments

Comments
 (0)