Skip to content

Commit

Permalink
Fix sidecar undefined error (#19487)
Browse files Browse the repository at this point in the history
* Fix sidecar undefined error

* changelog file

* use ifs instead of switch
  • Loading branch information
gally47 committed May 31, 2024
1 parent d6ea2d3 commit d019301
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
4 changes: 4 additions & 0 deletions changelog/unreleased/pr-19487.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
type = "f"
message = "Fix sidecar undefined error"

pulls = ["19487"]
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,9 @@ const CollectorsAdministration = ({
onPageChange(page, pageSize);
};

const selectedSidecarCollectorPairs = selected.map((selectedSidecarCollectorId) => sidecarCollectorPairs.find(({ sidecar, collector }) => sidecarCollectorId(sidecar, collector) === selectedSidecarCollectorId));
const selectedSidecarCollectorPairs = selected.map((selectedSidecarCollectorId) => sidecarCollectorPairs.find(
({ sidecar, collector }) => sidecarCollectorId(sidecar, collector) === selectedSidecarCollectorId),
).filter((sidecarCollectorPair) => !!sidecarCollectorPair?.collector && !!sidecarCollectorPair?.sidecar);

let formattedCollectors;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,26 @@ const CollectorsAdministrationActions = ({
const onCancelConfigurationModal = useCallback(() => setShowConfigurationModal(false), []);

const selectedLogCollectorsNames = uniq(selectedSidecarCollectorPairs.map(({ collector }) => collector.name));
const configButtonTooltip = `Cannot change configurations of ${selectedLogCollectorsNames.join(', ')} collectors simultaneously`;
const disableConfigButton = !selectedSidecarCollectorPairs.length || selectedLogCollectorsNames.length !== 1;

const getConfigButtonTooltip = () => {
if (!selectedSidecarCollectorPairs.length) {
return 'Incompatible collectors, please check your sidecar configuration.';
}

if (selectedLogCollectorsNames.length !== 1) {
return `Cannot change configurations of ${selectedLogCollectorsNames.join(', ')} collectors simultaneously.`;
}

return 'Assign Configurations';
};

return (
<ButtonToolbar>
<ConfigurationButton title={(selectedLogCollectorsNames.length > 1) ? configButtonTooltip : undefined}
<ConfigurationButton title={getConfigButtonTooltip()}
bsStyle="primary"
bsSize="small"
disabled={selectedLogCollectorsNames.length !== 1}
disabled={disableConfigButton}
onClick={() => setShowConfigurationModal(true)}>
<Icon name="edit_square" /> Assign Configurations
</ConfigurationButton>
Expand Down

0 comments on commit d019301

Please sign in to comment.