Skip to content

Commit 91341f3

Browse files
chore: migrate to gitguardian [IDE-1536] (#350)
* chore: migrate to gitguardian [IDE-1536] * chore: update settings-fallback.html to fix check
1 parent 85eaabb commit 91341f3

File tree

2 files changed

+38
-8
lines changed

2 files changed

+38
-8
lines changed

.pre-commit-config.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# See https://pre-commit.com for more information
22
# See https://pre-commit.com/hooks.html for more hooks
33
repos:
4-
- repo: https://github.com/gitleaks/gitleaks
5-
rev: v8.17.0
4+
- repo: https://github.com/gitguardian/ggshield
5+
rev: v1.43.0
66
hooks:
7-
- id: gitleaks
7+
- id: ggshield
8+
language_version: python3
9+
stages: [pre-commit]

plugin/src/main/resources/ui/html/settings-fallback.html

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ <h2>CLI Configuration</h2>
243243
</div>
244244

245245
<div class="form-group">
246-
<label for="cliBaseDownloadURL">Base URL <span class="badge bg-secondary" data-bs-toggle="tooltip" title="Base URL for downloading Snyk CLI binaries. The default is https://downloads.snyk.io. For FIPS-enabled CLIs (Windows/Linux only), use https://downloads.snyk.io/fips">?</span></label>
246+
<label for="cliBaseDownloadURL">CLI Download Base URL <span class="badge bg-secondary" data-bs-toggle="tooltip" title="Base URL for downloading Snyk CLI binaries. The default is https://downloads.snyk.io. For FIPS-enabled CLIs (Windows/Linux only), use https://downloads.snyk.io/fips">?</span></label>
247247
<input type="text" id="cliBaseDownloadURL" name="cliBaseDownloadURL" value="{{CLI_BASE_DOWNLOAD_URL}}" placeholder="https://downloads.snyk.io">
248248
</div>
249249

@@ -275,12 +275,18 @@ <h2>CLI Configuration</h2>
275275
(function() {
276276
window.__modified__ = false;
277277

278+
// Check if auto-save is enabled (default false)
279+
if (typeof window.__IS_IDE_AUTOSAVE_ENABLED__ === "undefined") {
280+
window.__IS_IDE_AUTOSAVE_ENABLED__ = false;
281+
}
282+
278283
function get(id) {
279284
return document.getElementById(id);
280285
}
281286

282287
function collectData() {
283288
return {
289+
isFallbackForm: true,
284290
cliPath: get('cliPath').value,
285291
manageBinariesAutomatically: get('manageBinariesAutomatically').checked,
286292
cliBaseDownloadURL: get('cliBaseDownloadURL').value,
@@ -289,11 +295,16 @@ <h2>CLI Configuration</h2>
289295
};
290296
}
291297

292-
function markModified() {
298+
function markDirtyAndSave() {
293299
window.__modified__ = true;
294300
if (typeof window.__onFormDirtyChange__ === 'function') {
295301
window.__onFormDirtyChange__(true);
296302
}
303+
304+
// Auto-save if enabled
305+
if (window.__IS_IDE_AUTOSAVE_ENABLED__) {
306+
window.getAndSaveIdeConfig();
307+
}
297308
}
298309

299310
window.getAndSaveIdeConfig = function() {
@@ -303,12 +314,22 @@ <h2>CLI Configuration</h2>
303314
if (typeof window.__saveIdeConfig__ === 'function') {
304315
window.__saveIdeConfig__(jsonString);
305316
window.__modified__ = false;
317+
318+
// Notify dirty state change
319+
if (typeof window.__onFormDirtyChange__ === 'function') {
320+
window.__onFormDirtyChange__(false);
321+
}
306322
}
307323
} catch (e) {
308324
console.error('Error saving configuration:', e);
309325
}
310326
};
311327

328+
// Expose dirty state query function
329+
window.__isFormDirty__ = function() {
330+
return window.__modified__;
331+
};
332+
312333
window.addEventListener('load', function() {
313334
var form = get('configForm');
314335
if (!form) return;
@@ -317,12 +338,19 @@ <h2>CLI Configuration</h2>
317338
var selects = form.getElementsByTagName('select');
318339

319340
for (var i = 0; i < inputs.length; i++) {
320-
inputs[i].addEventListener('input', markModified);
321-
inputs[i].addEventListener('change', markModified);
341+
var input = inputs[i];
342+
if (input.type === 'checkbox') {
343+
// Checkboxes: use change event (blur is unreliable)
344+
input.addEventListener('change', markDirtyAndSave);
345+
} else {
346+
// Text inputs: use blur event
347+
input.addEventListener('blur', markDirtyAndSave);
348+
}
322349
}
323350

324351
for (var j = 0; j < selects.length; j++) {
325-
selects[j].addEventListener('change', markModified);
352+
// Selects: use change event
353+
selects[j].addEventListener('change', markDirtyAndSave);
326354
}
327355
});
328356
})();

0 commit comments

Comments
 (0)