1
0
Fork 0
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:
Chaim Lev-Ari 2023-09-25 19:36:50 +03:00 committed by GitHub
parent 9dde610da3
commit 57e04c3544
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 324 additions and 190 deletions

View file

@ -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>
);
}