Skip to content

Commit 8bb93c4

Browse files
committed
feat(form): add environment variable overlap dialog and handling
1 parent dcee2d3 commit 8bb93c4

File tree

7 files changed

+165
-3
lines changed

7 files changed

+165
-3
lines changed

client/src/components/apps/form.vue

Lines changed: 121 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,6 +1164,43 @@
11641164
</div>
11651165
<Addons :addons="addons" :appname="name" />
11661166

1167+
<!-- ENV VAR OVERLAP DIALOG -->
1168+
<v-dialog v-model="envOverlapDialog" max-width="800px" persistent>
1169+
<v-card>
1170+
<v-card-title class="headline">
1171+
{{ $t("app.form.envVarConflicts") }}
1172+
</v-card-title>
1173+
<v-card-text>
1174+
<p class="mb-4">
1175+
{{ $t("app.form.envVarConflictsDescription") }}
1176+
</p>
1177+
<v-data-table
1178+
v-model="selectedOverlaps"
1179+
:headers="overlapHeaders"
1180+
:items="envOverlaps"
1181+
item-value="name"
1182+
show-select
1183+
>
1184+
<template v-slot:item.oldValue="{ item }">
1185+
<code class="text-caption">{{ item.oldValue }}</code>
1186+
</template>
1187+
<template v-slot:item.newValue="{ item }">
1188+
<code class="text-caption">{{ item.newValue }}</code>
1189+
</template>
1190+
</v-data-table>
1191+
</v-card-text>
1192+
<v-card-actions>
1193+
<v-spacer></v-spacer>
1194+
<v-btn variant="text" @click="cancelOverlapDialog">
1195+
{{ $t("global.cancel") }}
1196+
</v-btn>
1197+
<v-btn color="primary" @click="applyOverlapChanges">
1198+
{{ $t("global.applyChanges") }}
1199+
</v-btn>
1200+
</v-card-actions>
1201+
</v-card>
1202+
</v-dialog>
1203+
11671204
<!-- SUBMIT -->
11681205
<v-row class="pt-5">
11691206
<v-col cols="12" md="4">
@@ -1194,8 +1231,8 @@ import axios from "axios";
11941231
import Addons from "./addons.vue";
11951232
import { defineComponent } from "vue";
11961233
import { useKuberoStore } from "../../stores/kubero";
1197-
import { mapState } from "pinia";
11981234
import Breadcrumbs from "../breadcrumbs.vue";
1235+
import Swal from "sweetalert2";
11991236
12001237
type App = {
12011238
name: string;
@@ -1668,6 +1705,11 @@ export default defineComponent({
16681705
timeoutSeconds: 3,
16691706
periodSeconds: 10,
16701707
},
1708+
// Environment variable overlap dialog state
1709+
envOverlapDialog: false,
1710+
envOverlaps: [] as { name: string; oldValue: string; newValue: string }[],
1711+
selectedOverlaps: [] as string[],
1712+
pendingEnvVars: [] as EnvVar[],
16711713
nameRules: [
16721714
(v: any) => !!v || "Name is required",
16731715
(v: any) => v.length <= 60 || "Name must be less than 60 characters",
@@ -1721,6 +1763,13 @@ export default defineComponent({
17211763
const store = useKuberoStore();
17221764
return store.kubero;
17231765
},
1766+
overlapHeaders() {
1767+
return [
1768+
{ title: this.$t('app.form.variableName'), key: 'name' },
1769+
{ title: this.$t('app.form.currentValue'), key: 'oldValue' },
1770+
{ title: this.$t('app.form.newValue'), key: 'newValue' },
1771+
];
1772+
},
17241773
},
17251774
watch: {
17261775
advanced(newValue) {
@@ -2555,6 +2604,10 @@ export default defineComponent({
25552604
},
25562605
parseEnvFile(text: any) {
25572606
const lines = text.split("\n");
2607+
const newEnvVars: EnvVar[] = [];
2608+
const overlaps: { name: string; oldValue: string; newValue: string }[] =
2609+
[];
2610+
25582611
for (const line of lines) {
25592612
const trimmedLine = line.trim();
25602613
// Skip empty lines and comments
@@ -2573,10 +2626,51 @@ export default defineComponent({
25732626
// Remove quotes if present
25742627
const cleanValue = value.replace(/^["']|["']$/g, "");
25752628
2576-
if (name && !this.envVars.some((envVar) => envVar.name === name)) {
2577-
this.envVars.push({ name, value: cleanValue });
2629+
if (name) {
2630+
const existingVar = this.envVars.find(
2631+
(envVar) => envVar.name === name
2632+
);
2633+
if (existingVar) {
2634+
// skip if value is the same
2635+
if (existingVar.value === cleanValue) {
2636+
continue;
2637+
}
2638+
2639+
// Found overlap - add to overlaps list
2640+
overlaps.push({
2641+
name,
2642+
oldValue: existingVar.value,
2643+
newValue: cleanValue,
2644+
});
2645+
} else {
2646+
// No overlap - can add directly
2647+
newEnvVars.push({ name, value: cleanValue });
2648+
}
25782649
}
25792650
}
2651+
2652+
// Add non-overlapping variables immediately
2653+
this.envVars.push(...newEnvVars);
2654+
2655+
// If there are overlaps, show dialog
2656+
if (overlaps.length > 0) {
2657+
this.envOverlaps = overlaps;
2658+
this.selectedOverlaps = overlaps.map((overlap) => overlap.name); // Default all selected
2659+
this.envOverlapDialog = true;
2660+
} else if (newEnvVars.length === 0) {
2661+
// Show notification if no new environment variables were found
2662+
Swal.fire({
2663+
toast: true,
2664+
position: 'top-end',
2665+
showConfirmButton: false,
2666+
timer: 3000,
2667+
timerProgressBar: true,
2668+
icon: 'info',
2669+
title: this.$t('app.form.noNewEnvVarsFound'),
2670+
background: "rgb(var(--v-theme-cardBackground))",
2671+
color: "rgba(var(--v-theme-on-background),var(--v-high-emphasis-opacity))",
2672+
});
2673+
}
25802674
},
25812675
addVolumeLine() {
25822676
this.extraVolumes.push({
@@ -2632,6 +2726,30 @@ export default defineComponent({
26322726
});
26332727
return cronjobs;
26342728
},
2729+
// Environment variable overlap dialog methods
2730+
cancelOverlapDialog() {
2731+
this.envOverlapDialog = false;
2732+
this.envOverlaps = [];
2733+
this.selectedOverlaps = [];
2734+
},
2735+
applyOverlapChanges() {
2736+
// Update existing environment variables with selected new values
2737+
for (const overlap of this.envOverlaps) {
2738+
if (this.selectedOverlaps.includes(overlap.name)) {
2739+
const existingVar = this.envVars.find(
2740+
(envVar) => envVar.name === overlap.name
2741+
);
2742+
if (existingVar) {
2743+
existingVar.value = overlap.newValue;
2744+
}
2745+
}
2746+
}
2747+
2748+
// Close dialog and reset state
2749+
this.envOverlapDialog = false;
2750+
this.envOverlaps = [];
2751+
this.selectedOverlaps = [];
2752+
},
26352753
},
26362754
});
26372755
</script>

client/src/locale/de-CH.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ const messages = {
8686
abort: "Abbräche",
8787
cancel: "Abbräche",
8888
save: "Speichere",
89+
applyChanges: "Änderige aawände",
8990
},
9091
pipeline: {
9192
name: 'Pipeline',
@@ -222,6 +223,12 @@ const messages = {
222223
healthCheckStartupSeconds: 'Startup Sekunde',
223224
healthCheckTimeoutSeconds: 'Timeout Sekunde',
224225
healthCheckIntervalSeconds: 'Intervall Sekunde',
226+
noNewEnvVarsFound: 'Kei neui Umgäbigsvariable id hochladeni Datei gfunde',
227+
envVarConflicts: 'Umgäbigsvariable-Konflikt',
228+
envVarConflictsDescription: 'Die hochladeni .env-Datei enthalt Variable, wo scho existiere. Bitte wähl us, weli Wert du behalte möchtisch:',
229+
variableName: 'Variable Name',
230+
currentValue: 'Aktuälle Wert',
231+
newValue: 'Neue Wert',
225232
},
226233
strategy: {
227234
name: 'Strategie',

client/src/locale/de.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ const messages = {
99
size: "Größe",
1010
create: "Erstellen",
1111
update: "Aktualisieren",
12+
cancel: "Abbrechen",
13+
save: "Speichern",
14+
applyChanges: "Änderungen anwenden",
1215
},
1316
navigation: {
1417
pipelines: 'Pipelines',
@@ -222,6 +225,12 @@ const messages = {
222225
healthCheckStartupSeconds: 'Startup Sekunden',
223226
healthCheckTimeoutSeconds: 'Timeout Sekunden',
224227
healthCheckIntervalSeconds: 'Interval Sekunden',
228+
noNewEnvVarsFound: 'Keine neuen Umgebungsvariablen in der hochgeladenen Datei gefunden',
229+
envVarConflicts: 'Umgebungsvariablen-Konflikte',
230+
envVarConflictsDescription: 'Die hochgeladene .env-Datei enthält Variablen, die bereits existieren. Bitte wählen Sie aus, welche Werte Sie behalten möchten:',
231+
variableName: 'Variablenname',
232+
currentValue: 'Aktueller Wert',
233+
newValue: 'Neuer Wert',
225234
},
226235
strategy: {
227236
name: 'Strategie',

client/src/locale/en.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const messages = {
3131
abort: "Abort",
3232
cancel: "Cancel",
3333
save: "Save",
34+
applyChanges: "Apply Changes",
3435
},
3536
pipeline: {
3637
name: 'Pipeline',
@@ -167,6 +168,12 @@ const messages = {
167168
healthCheckStartupSeconds: 'Startup Seconds',
168169
healthCheckTimeoutSeconds: 'Timeout Seconds',
169170
healthCheckIntervalSeconds: 'Interval Seconds',
171+
noNewEnvVarsFound: 'No new environment variables found in the uploaded file',
172+
envVarConflicts: 'Environment Variable Conflicts',
173+
envVarConflictsDescription: 'The uploaded .env file contains variables that already exist. Please select which values you want to keep:',
174+
variableName: 'Variable Name',
175+
currentValue: 'Current Value',
176+
newValue: 'New Value',
170177
},
171178
strategy: {
172179
name: 'Strategy',

client/src/locale/ja.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ const messages = {
8787
abort: "中止",
8888
cancel: "キャンセル",
8989
save: "保存",
90+
applyChanges: "変更を適用",
9091
},
9192
pipeline: {
9293
name: 'パイプライン',
@@ -223,6 +224,12 @@ const messages = {
223224
healthCheckStartupSeconds: '起動秒数',
224225
healthCheckTimeoutSeconds: 'タイムアウト秒数',
225226
healthCheckIntervalSeconds: 'インターバル秒数',
227+
noNewEnvVarsFound: 'アップロードされたファイルに新しい環境変数が見つかりませんでした',
228+
envVarConflicts: '環境変数の競合',
229+
envVarConflictsDescription: 'アップロードされた.envファイルには、既に存在する変数が含まれています。保持する値を選択してください:',
230+
variableName: '変数名',
231+
currentValue: '現在の値',
232+
newValue: '新しい値',
226233
},
227234
strategy: {
228235
name: '戦略',

client/src/locale/pt.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const messages = {
3030
abort: 'Abortar',
3131
cancel: 'Cancelar',
3232
save: 'Salvar',
33+
applyChanges: 'Aplicar Alterações',
3334
},
3435
pipeline: {
3536
name: 'Pipeline',
@@ -165,6 +166,12 @@ const messages = {
165166
healthCheckStartupSeconds: 'Segundos de Inicialização',
166167
healthCheckTimeoutSeconds: 'Segundos de Timeout',
167168
healthCheckIntervalSeconds: 'Segundos de Intervalo',
169+
noNewEnvVarsFound: 'Nenhuma nova variável de ambiente encontrada no arquivo enviado',
170+
envVarConflicts: 'Conflitos de Variáveis de Ambiente',
171+
envVarConflictsDescription: 'O arquivo .env enviado contém variáveis que já existem. Por favor, selecione quais valores deseja manter:',
172+
variableName: 'Nome da Variável',
173+
currentValue: 'Valor Atual',
174+
newValue: 'Novo Valor',
168175
},
169176
strategy: {
170177
name: 'Estratégia',

client/src/locale/zhHans.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ const messages = {
8686
abort: "中止",
8787
cancel: "取消",
8888
save: "保存",
89+
applyChanges: "应用更改",
8990
},
9091
pipeline: {
9192
name: '流水线',
@@ -222,6 +223,12 @@ const messages = {
222223
healthCheckStartupSeconds: '启动秒数',
223224
healthCheckTimeoutSeconds: '超时时间(秒)',
224225
healthCheckIntervalSeconds: '间隔时间(秒)',
226+
noNewEnvVarsFound: '上传的文件中未找到新的环境变量',
227+
envVarConflicts: '环境变量冲突',
228+
envVarConflictsDescription: '上传的.env文件包含已存在的变量。请选择要保留的值:',
229+
variableName: '变量名',
230+
currentValue: '当前值',
231+
newValue: '新值',
225232
},
226233
strategy: {
227234
name: '策略',

0 commit comments

Comments
 (0)