Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor to createOptionRenderer helper #2034

Merged
merged 1 commit into from
Nov 27, 2023
Merged

Conversation

dottorblaster
Copy link
Contributor

Description

Add a createOptionRenderer to the Select component to encapsulate the all handling logic

How was this tested?

Jest tests updated 馃憤

@dottorblaster dottorblaster self-assigned this Nov 27, 2023
Comment on lines +19 to +36
const providerOptionRenderer = createOptionRenderer(
'All providers',
(provider) => <ProviderLabel provider={provider} />
);
const targetTypeOptionRenderer = (targetType) => (
<TargetIcon targetType={targetType} className="inline mr-2 h-4">
{targetType === TARGET_CLUSTER && 'Clusters'}
{targetType === TARGET_HOST && 'Hosts'}
</TargetIcon>

const clusterTypeRenderer = createOptionRenderer(
'All cluster types',
getClusterTypeLabel
);

const targetTypeOptionRenderer = createOptionRenderer(
'All targets',
(targetType) => (
<TargetIcon targetType={targetType} className="inline mr-2 h-4">
{targetType === TARGET_CLUSTER && 'Clusters'}
{targetType === TARGET_HOST && 'Hosts'}
</TargetIcon>
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe it would make sense to move these to a separate file

Copy link
Member

@nelsonkopliku nelsonkopliku left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@dottorblaster dottorblaster merged commit 2f2e789 into main Nov 27, 2023
30 checks passed
@dottorblaster dottorblaster deleted the select-helper-functions branch November 27, 2023 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

None yet

2 participants