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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Ingest Manager] Fix config selection in enrollment flyout from config page. #73833

Merged
merged 1 commit into from
Jul 30, 2020
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ export const EnrollmentStepAgentConfig: React.FC<Props> = (props) => {
useEffect(
function useDefaultConfigEffect() {
if (agentConfigs && agentConfigs.length && !selectedState.agentConfigId) {
if (agentConfigs.length === 1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

is a 'length' a 0 based count? should it be greater than 1 ?

I'm not strong with typescript / js, and so don't yet see how this changes the case where there are 2 configs. If you tested it then thats great - just checking so I can understand the code base better.

Copy link
Member Author

Choose a reason for hiding this comment

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

it should be greater than 1 one when we are in the scenario where the flyout is open not for a specific config, for a specific config we load the flyout with only one config.

Copy link
Contributor

Choose a reason for hiding this comment

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

oh, ok - thanks much. it looks great then. :)

setSelectedState({
...selectedState,
agentConfigId: agentConfigs[0].id,
});
return;
}

const defaultConfig = agentConfigs.find((config) => config.is_default);
if (defaultConfig) {
setSelectedState({
Expand Down