feat(web): When adding the first action, display it in edit mode (#556)

When adding the first action, display it in edit mode
This commit is contained in:
Viktor Elofsson 2022-12-03 17:16:26 +01:00 committed by GitHub
parent 0f2ce26ba2
commit 4623921cbb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -84,7 +84,7 @@ export function FilterActions({ filter, values }: FilterActionsProps) {
{values.actions.length > 0 ?
<ul className="divide-y divide-gray-200 dark:divide-gray-700">
{values.actions.map((action: Action, index: number) => (
<FilterActionsItem action={action} clients={data ?? []} idx={index} remove={remove} key={index}/>
<FilterActionsItem action={action} clients={data ?? []} idx={index} initialEdit={values.actions.length === 1} remove={remove} key={index}/>
))}
</ul>
: <EmptyListState text="No actions yet!"/>
@ -405,14 +405,15 @@ interface FilterActionsItemProps {
action: Action;
clients: DownloadClient[];
idx: number;
initialEdit: boolean;
remove: <T>(index: number) => T | undefined;
}
function FilterActionsItem({ action, clients, idx, remove }: FilterActionsItemProps) {
function FilterActionsItem({ action, clients, idx, initialEdit, remove }: FilterActionsItemProps) {
const cancelButtonRef = useRef(null);
const [deleteModalIsOpen, toggleDeleteModal] = useToggle(false);
const [edit, toggleEdit] = useToggle(false);
const [edit, toggleEdit] = useToggle(initialEdit);
return (
<li>