Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions frontend/src/components/AcmDataForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import {
WizardFooterType,
WizardStepProps,
WizardHeader,
Radio,
} from '@patternfly/react-core'
import { Select, SelectGroup, SelectOption, SelectOptionObject, SelectProps } from '@patternfly/react-core/deprecated'
import { ValidatedOptions } from '@patternfly/react-core/dist/js/helpers/constants'
Expand Down Expand Up @@ -915,6 +916,25 @@ function AcmInputDescription(props: { input: Input }): JSX.Element {
</DescriptionListGroup>
)
}
case 'Radio':{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to refactor to not have this duplicate code in lines 920-937 and 1268-1286?

return (
<FormGroup label={input.label} isRequired={input.isRequired} fieldId={input.id}>
{input.options.map((option) => (
<Radio
key={option.id}
id={option.id}
name={input.id}
label={option.text}
value={option.value}
isChecked={input.value === option.value}
onChange={() => input.onChange(option.value)}
/>
))}
</FormGroup>
)
}
case 'Custom':
return input.component
}
}

Expand Down Expand Up @@ -1245,6 +1265,25 @@ export function AcmDataFormInput(props: { input: Input; validated?: 'error'; isR
</Alert>
)
}
case 'Radio':{
return (
<FormGroup label={input.label} isRequired={input.isRequired} fieldId={input.id} isInline>
{input.options.map((option) => (
<Radio
key={option.id}
id={option.id}
name={input.id}
label={option.text}
value={option.value}
isChecked={input.value === option.value}
onChange={() => input.onChange(option.value)}
/>
))}
</FormGroup>
)
}
case 'Custom':
return input.component
}
}

Expand Down
14 changes: 14 additions & 0 deletions frontend/src/components/AcmFormData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,18 @@ export interface NumberInput extends InputBase<number> {
unit?: ReactNode
}

export interface RadioInput extends SelectOptionsBase<string> {
type: 'Radio'
isInline?: boolean
}

export interface CustomInput {
id: string
type: 'Custom'
component: JSX.Element
isHidden?: boolean
}

export interface FormDataOrderedInput<T = any> extends InputBase<T[]> {
type: 'OrderedItems'
keyFn: (item: T, index: number) => string
Expand All @@ -181,3 +193,5 @@ export type Input =
| NumberInput
| FormDataOrderedInput
| CheckboxInput
| RadioInput
| CustomInput
2 changes: 1 addition & 1 deletion frontend/src/resources/access-control.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const AccessControlDefinition: IResourceDefinition = {
kind: AccessControlKind
}

interface RoleBinding {
export interface RoleBinding {
namespace: string
roleRef: {
apiGroup: string
Expand Down
Loading