fleet/frontend/components/forms/fields/Radio/Radio.tsx
Gabriel Hernandez 0d459359a4
Feat UI create policies fleet app (#23842)
relates to #23136

This is the UI for the creating of policies when adding fleet maintained
software. This includes only the creating of the policy and there will
be another PR for viewing more information on the software titles
details page.


**new install type options. this determines if a policy should be
created or not.**

![image](https://github.com/user-attachments/assets/20538c66-bc1c-4903-aa70-83d24da97617)


there are also some new icons for the software titles.

- [] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
- [x] Manual QA for all new/changed functionality
2024-11-20 11:41:40 +00:00

68 lines
1.7 KiB
TypeScript

import React, { ReactNode } from "react";
import classnames from "classnames";
import TooltipWrapper from "components/TooltipWrapper";
const baseClass = "radio";
export interface IRadioProps {
label: ReactNode;
value: string;
id: string;
onChange: (value: string) => void;
checked?: boolean;
/** Allows tabbing to the group, then using arrow keys to move between options with same name attribute */
name?: string;
className?: string;
disabled?: boolean;
tooltip?: React.ReactNode;
helpText?: React.ReactNode;
testId?: string;
}
const Radio = ({
className,
id,
name,
value,
checked,
disabled,
label,
tooltip,
helpText,
testId,
onChange,
}: IRadioProps): JSX.Element => {
const wrapperClasses = classnames(baseClass, className, {
[`${baseClass}__disabled`]: disabled,
});
return (
<div className={wrapperClasses} data-testid={testId}>
<label htmlFor={id} className={`${baseClass}__radio-control`}>
<span className={`${baseClass}__input`}>
<input
type="radio"
id={id}
disabled={disabled}
name={name}
value={value}
checked={checked}
onChange={(event) => onChange(event.target.value)}
/>
<span className={`${baseClass}__control-button`} />
</span>
<span className={`${baseClass}__label`}>
{tooltip ? (
<TooltipWrapper tipContent={tooltip}>{label}</TooltipWrapper>
) : (
<>{label}</>
)}
</span>
</label>
{helpText && <div className={`${baseClass}__help-text`}>{helpText}</div>}
</div>
);
};
export default Radio;