mirror of
https://github.com/portainer/portainer.git
synced 2025-07-25 08:19:40 +02:00
refactor(app): migrate configmap and secret form sections [EE-6233] (#10528)
* refactor(app): migrate configmap and secret form sections [EE-6233]
This commit is contained in:
parent
391b85da41
commit
7a2412b1be
18 changed files with 631 additions and 447 deletions
|
@ -71,7 +71,11 @@ interface Props<T> {
|
|||
errors?: ArrayError<T[]>;
|
||||
textTip?: string;
|
||||
isAddButtonHidden?: boolean;
|
||||
addButtonDataCy?: string;
|
||||
isDeleteButtonHidden?: boolean;
|
||||
deleteButtonDataCy?: string;
|
||||
disabled?: boolean;
|
||||
addButtonError?: string;
|
||||
readOnly?: boolean;
|
||||
'aria-label'?: string;
|
||||
}
|
||||
|
@ -91,12 +95,17 @@ export function InputList<T = DefaultType>({
|
|||
errors,
|
||||
textTip,
|
||||
isAddButtonHidden = false,
|
||||
addButtonDataCy,
|
||||
isDeleteButtonHidden = false,
|
||||
deleteButtonDataCy,
|
||||
disabled,
|
||||
addButtonError,
|
||||
readOnly,
|
||||
'aria-label': ariaLabel,
|
||||
}: Props<T>) {
|
||||
const initialItemsCount = useRef(value.length);
|
||||
const isAddButtonVisible = !(isAddButtonHidden || readOnly);
|
||||
const isDeleteButtonVisible = !(isDeleteButtonHidden || readOnly);
|
||||
return (
|
||||
<div className="form-group" aria-label={ariaLabel || label}>
|
||||
{label && (
|
||||
|
@ -160,16 +169,17 @@ export function InputList<T = DefaultType>({
|
|||
/>
|
||||
</>
|
||||
)}
|
||||
{!readOnly && !canUndoDelete && (
|
||||
{isDeleteButtonVisible && !canUndoDelete && (
|
||||
<Button
|
||||
color="dangerlight"
|
||||
size="medium"
|
||||
onClick={() => handleRemoveItem(key, item)}
|
||||
className="vertical-center btn-only-icon"
|
||||
data-cy={`${deleteButtonDataCy}_${index}`}
|
||||
icon={Trash2}
|
||||
/>
|
||||
)}
|
||||
{!readOnly &&
|
||||
{isDeleteButtonVisible &&
|
||||
canUndoDelete &&
|
||||
hasKey(item, 'needsDeletion') && (
|
||||
<CanUndoDeleteButton
|
||||
|
@ -188,19 +198,27 @@ export function InputList<T = DefaultType>({
|
|||
)}
|
||||
|
||||
{isAddButtonVisible && (
|
||||
<div className="col-sm-12 mt-3">
|
||||
<Button
|
||||
onClick={handleAdd}
|
||||
disabled={disabled}
|
||||
type="button"
|
||||
color="default"
|
||||
className="!ml-0"
|
||||
size="small"
|
||||
icon={Plus}
|
||||
>
|
||||
{addLabel}
|
||||
</Button>
|
||||
</div>
|
||||
<>
|
||||
<div className="col-sm-12 mt-3">
|
||||
<Button
|
||||
onClick={handleAdd}
|
||||
disabled={disabled}
|
||||
type="button"
|
||||
color="default"
|
||||
className="!ml-0"
|
||||
size="small"
|
||||
icon={Plus}
|
||||
data-cy={addButtonDataCy}
|
||||
>
|
||||
{addLabel}
|
||||
</Button>
|
||||
</div>
|
||||
{addButtonError && (
|
||||
<div className="col-sm-12">
|
||||
<FormError>{addButtonError}</FormError>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue