Skip to content
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