fix: editing (#1587)

This commit is contained in:
Gabe Ruttner
2025-04-21 12:03:17 -04:00
committed by GitHub
parent 28bc541d85
commit 5f6265b85a
4 changed files with 21 additions and 13 deletions
+11 -7
View File
@@ -1,7 +1,7 @@
import React, { useEffect } from 'react';
import { Input } from '@/components/ui/input';
import { Textarea } from '@/components/ui/textarea';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/v1/ui/input';
import { Textarea } from './textarea';
import { Button } from '@/components/v1/ui/button';
import { cn } from '@/lib/utils';
import { TrashIcon } from '@radix-ui/react-icons';
@@ -48,9 +48,13 @@ const EnvGroupArray: React.FC<PropsType> = ({
const newValues = [...values];
const entry = newValues[index];
// If this is an existing secret and we're editing the value, set isEditing to true
if (key === 'value' && entry.hint && value !== entry.hint) {
newValues[index] = { ...entry, [key]: value, isEditing: true };
// If this is an existing secret and we're editing the value
if (key === 'value' && entry.hint) {
// Only set isEditing to true if the value is different from the hint
// and not empty (which would be the case when no changes are made)
if (value !== entry.hint && value !== '') {
newValues[index] = { ...entry, [key]: value, isEditing: true };
}
} else {
newValues[index] = { ...entry, [key]: value };
}
@@ -58,7 +62,7 @@ const EnvGroupArray: React.FC<PropsType> = ({
setValues(newValues);
// If this is an existing entry (has an ID), notify about updates
if (entry.id && onUpdate) {
if (entry.id && onUpdate && value !== entry.hint) {
onUpdate([newValues[index]]);
}
};
+8 -4
View File
@@ -48,9 +48,13 @@ const EnvGroupArray: React.FC<PropsType> = ({
const newValues = [...values];
const entry = newValues[index];
// If this is an existing secret and we're editing the value, set isEditing to true
if (key === 'value' && entry.hint && value !== entry.hint) {
newValues[index] = { ...entry, [key]: value, isEditing: true };
// If this is an existing secret and we're editing the value
if (key === 'value' && entry.hint) {
// Only set isEditing to true if the value is different from the hint
// and not empty (which would be the case when no changes are made)
if (value !== entry.hint && value !== '') {
newValues[index] = { ...entry, [key]: value, isEditing: true };
}
} else {
newValues[index] = { ...entry, [key]: value };
}
@@ -58,7 +62,7 @@ const EnvGroupArray: React.FC<PropsType> = ({
setValues(newValues);
// If this is an existing entry (has an ID), notify about updates
if (entry.id && onUpdate) {
if (entry.id && onUpdate && value !== entry.hint) {
onUpdate([newValues[index]]);
}
};
@@ -375,7 +375,7 @@ export default function UpdateWorkerForm({
useEffect(() => {
// Split secrets into add/update/delete
const toAdd = secrets.filter((s) => !s.id && !s.deleted);
const toUpdate = secrets.filter((s) => s.id && !s.deleted);
const toUpdate = secrets.filter((s) => s.id && !s.deleted && s.isEditing);
const toDelete = secrets.filter((s) => s.id && s.deleted).map((s) => s.id!);
setValue(
@@ -375,7 +375,7 @@ export default function UpdateWorkerForm({
useEffect(() => {
// Split secrets into add/update/delete
const toAdd = secrets.filter((s) => !s.id && !s.deleted);
const toUpdate = secrets.filter((s) => s.id && !s.deleted);
const toUpdate = secrets.filter((s) => s.id && !s.deleted && s.isEditing);
const toDelete = secrets.filter((s) => s.id && s.deleted).map((s) => s.id!);
setValue(