mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 15:59:41 +02:00
refactor(containers): migrate caps tab to react [EE-5215] (#10366)
This commit is contained in:
parent
9dde610da3
commit
57e04c3544
14 changed files with 324 additions and 190 deletions
|
@ -0,0 +1,39 @@
|
|||
import { FormSection } from '@@/form-components/FormSection';
|
||||
import { SwitchField } from '@@/form-components/SwitchField';
|
||||
|
||||
import { capabilities } from './types';
|
||||
|
||||
export type Values = string[];
|
||||
|
||||
export function CapabilitiesTab({
|
||||
values,
|
||||
onChange,
|
||||
}: {
|
||||
values: Values;
|
||||
onChange: (values: Values) => void;
|
||||
}) {
|
||||
return (
|
||||
<FormSection title="Container capabilities">
|
||||
<div className="form-group flex flex-wrap gap-y-2 px-5">
|
||||
{capabilities.map((cap) => (
|
||||
<div key={cap.key} className="w-1/3 text-center">
|
||||
<SwitchField
|
||||
labelClass="col-sm-6"
|
||||
tooltip={cap.description}
|
||||
checked={values.includes(cap.key)}
|
||||
label={cap.key}
|
||||
name={`${cap.key}-capability`}
|
||||
onChange={(value) => {
|
||||
if (value) {
|
||||
onChange([...values, cap.key]);
|
||||
} else {
|
||||
onChange(values.filter((v) => v !== cap.key));
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</FormSection>
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue