mirror of
https://github.com/hatchet-dev/hatchet.git
synced 2026-05-08 11:20:17 -05:00
fix: editing (#1587)
This commit is contained in:
@@ -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]]);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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]]);
|
||||
}
|
||||
};
|
||||
|
||||
+1
-1
@@ -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(
|
||||
|
||||
+1
-1
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user