feat: prevent downloading empty config

This commit is contained in:
sokol
2026-02-20 10:19:27 +03:00
parent 1b3f3b3110
commit 7e1f7dd24c
3 changed files with 30 additions and 3 deletions

View File

@@ -60,7 +60,7 @@ export function FileChooser({ onSelected, config }: FileChooserProps) {
URL.revokeObjectURL(url);
}
const hasConfig = !!config;
const hasConfig = !!config && !config.isEmpty();
return (
<div className="bg-white rounded-xl shadow-md p-4 border border-slate-200">

View File

@@ -171,4 +171,22 @@ export class Config {
cloned.template = this.template;
return cloned;
}
/**
* Checks if config is empty (no environments or only DEFAULT with no params and empty template)
*/
public isEmpty(): boolean {
if (this.envs.length === 0) {
return true;
}
// Check if only DEFAULT exists with no params
if (this.envs.length === 1 && this.envs[0].name === 'DEFAULT') {
const hasParams = this.envs[0].params.length > 0;
const hasTemplate = this.template.content.trim() && this.template.content !== '{}';
return !hasParams && !hasTemplate;
}
return false;
}
}