Skip to content

Commit

Permalink
[8.x] [Fleet] Agent upgrade form validation fix (#204846) (#205003)
Browse files Browse the repository at this point in the history
# Backport

This will backport the following commits from `main` to `8.x`:
- [[Fleet] Agent upgrade form validation fix
(#204846)](#204846)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Mason
Herron","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-12-19T19:49:36Z","message":"[Fleet]
Agent upgrade form validation fix (#204846)\n\n## Summary\r\n\r\nCloses
#197399 \r\n\r\nImplemented a fix when trying to bulk upgrade agents
that are on the\r\ncurrent version (see issue for further explanation).
Instead of a\r\ncombobox, a text field would be shown but the current
version (in line\r\nwith the kibana version) wasn't automatically being
added to the field\r\nas intended due to the wrong variable being passed
as the `value` prop.\r\nHowever the correct version was being applied to
the behind-the-scenes\r\ncheck, allowing the user to submit even though
it looked like nothing\r\nhad been entered in the field.\r\n\r\n- Fixed
`value` prop on input to use the correct pre-filled
value\r\ninitially\r\n- Added a check so that if there were errors with
the version being\r\ntyped in, the button would also get disabled to
stop submissions with\r\ninvalid versions\r\n\r\n\r\n###
Checklist\r\n\r\nCheck the PR satisfies following conditions.
\r\n\r\nReviewers should verify this PR satisfies this list as
well.\r\n\r\n- [ ] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[
]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials\r\n- [ ] [Unit
or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] If a plugin
configuration key changed, check if it needs to be\r\nallowlisted in the
cloud and added to the
[docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n-
[ ] This was checked for breaking HTTP API changes, and any
breaking\r\nchanges have been approved by the breaking-change committee.
The\r\n`release_note:breaking` label should be applied in these
situations.\r\n- [ ] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests changed\r\n- [ ] The PR description includes
the appropriate Release Notes section,\r\nand the correct
`release_note:*` label is applied per
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n###
Identify
risks\r\n\r\nn/a","sha":"37df2060958a2835875e96db064bb0ed212b7677","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:skip","Team:Fleet","v9.0.0","backport:prev-minor"],"title":"[Fleet]
Agent upgrade form validation
fix","number":204846,"url":"https://github.com/elastic/kibana/pull/204846","mergeCommit":{"message":"[Fleet]
Agent upgrade form validation fix (#204846)\n\n## Summary\r\n\r\nCloses
#197399 \r\n\r\nImplemented a fix when trying to bulk upgrade agents
that are on the\r\ncurrent version (see issue for further explanation).
Instead of a\r\ncombobox, a text field would be shown but the current
version (in line\r\nwith the kibana version) wasn't automatically being
added to the field\r\nas intended due to the wrong variable being passed
as the `value` prop.\r\nHowever the correct version was being applied to
the behind-the-scenes\r\ncheck, allowing the user to submit even though
it looked like nothing\r\nhad been entered in the field.\r\n\r\n- Fixed
`value` prop on input to use the correct pre-filled
value\r\ninitially\r\n- Added a check so that if there were errors with
the version being\r\ntyped in, the button would also get disabled to
stop submissions with\r\ninvalid versions\r\n\r\n\r\n###
Checklist\r\n\r\nCheck the PR satisfies following conditions.
\r\n\r\nReviewers should verify this PR satisfies this list as
well.\r\n\r\n- [ ] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[
]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials\r\n- [ ] [Unit
or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] If a plugin
configuration key changed, check if it needs to be\r\nallowlisted in the
cloud and added to the
[docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n-
[ ] This was checked for breaking HTTP API changes, and any
breaking\r\nchanges have been approved by the breaking-change committee.
The\r\n`release_note:breaking` label should be applied in these
situations.\r\n- [ ] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests changed\r\n- [ ] The PR description includes
the appropriate Release Notes section,\r\nand the correct
`release_note:*` label is applied per
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n###
Identify
risks\r\n\r\nn/a","sha":"37df2060958a2835875e96db064bb0ed212b7677"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/204846","number":204846,"mergeCommit":{"message":"[Fleet]
Agent upgrade form validation fix (#204846)\n\n## Summary\r\n\r\nCloses
#197399 \r\n\r\nImplemented a fix when trying to bulk upgrade agents
that are on the\r\ncurrent version (see issue for further explanation).
Instead of a\r\ncombobox, a text field would be shown but the current
version (in line\r\nwith the kibana version) wasn't automatically being
added to the field\r\nas intended due to the wrong variable being passed
as the `value` prop.\r\nHowever the correct version was being applied to
the behind-the-scenes\r\ncheck, allowing the user to submit even though
it looked like nothing\r\nhad been entered in the field.\r\n\r\n- Fixed
`value` prop on input to use the correct pre-filled
value\r\ninitially\r\n- Added a check so that if there were errors with
the version being\r\ntyped in, the button would also get disabled to
stop submissions with\r\ninvalid versions\r\n\r\n\r\n###
Checklist\r\n\r\nCheck the PR satisfies following conditions.
\r\n\r\nReviewers should verify this PR satisfies this list as
well.\r\n\r\n- [ ] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[
]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials\r\n- [ ] [Unit
or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] If a plugin
configuration key changed, check if it needs to be\r\nallowlisted in the
cloud and added to the
[docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n-
[ ] This was checked for breaking HTTP API changes, and any
breaking\r\nchanges have been approved by the breaking-change committee.
The\r\n`release_note:breaking` label should be applied in these
situations.\r\n- [ ] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests changed\r\n- [ ] The PR description includes
the appropriate Release Notes section,\r\nand the correct
`release_note:*` label is applied per
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n###
Identify
risks\r\n\r\nn/a","sha":"37df2060958a2835875e96db064bb0ed212b7677"}}]}]
BACKPORT-->

Co-authored-by: Mason Herron <[email protected]>
  • Loading branch information
kibanamachine and Supplementing authored Dec 19, 2024
1 parent ce4641f commit f17e8a9
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ export const AgentUpgradeAgentModal: React.FunctionComponent<AgentUpgradeAgentMo
},
];
const [selectedVersion, setSelectedVersion] = useState(preselected);
const [selectedVersionStr, setSelectedVersionStr] = useState('');

// latest agent version might be earlier than kibana version
const latestAgentVersion = useAgentVersion();
Expand Down Expand Up @@ -296,6 +295,7 @@ export const AgentUpgradeAgentModal: React.FunctionComponent<AgentUpgradeAgentMo
isSubmitting ||
(isUpdating && updatingAgents === 0) ||
!selectedVersion[0].value ||
!semverValid(selectedVersion[0].value) ||
(isSingleAgent && !isAgentUpgradeableToVersion(agents[0], selectedVersion[0].value)) ||
(isSingleAgent &&
!isSingleAgentFleetServer &&
Expand Down Expand Up @@ -566,11 +566,11 @@ export const AgentUpgradeAgentModal: React.FunctionComponent<AgentUpgradeAgentMo
<EuiFieldText
fullWidth
placeholder="Enter version"
value={selectedVersionStr}
value={selectedVersion[0].value}
data-test-subj="agentUpgradeModal.VersionInput"
onChange={(e) => {
const newValue = e.target.value;
setSelectedVersionStr(newValue);

setSelectedVersion([{ label: newValue, value: newValue }]);
}}
isInvalid={!!semverErrors}
Expand Down

0 comments on commit f17e8a9

Please sign in to comment.