Skip to content

Commit 0067605

Browse files
refactor: streamline cluster node selection logic in configuration components
- Simplified the logic for selecting the master node in both the WzEditConfiguration and WzRefreshClusterInfoButton components by directly finding the master node in the affected items array. - Removed the intermediate variable for masterNode to enhance code clarity and maintainability.
1 parent 634f78a commit 0067605

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

plugins/main/public/controllers/management/components/management/configuration/edit-configuration/edit-configuration.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,13 +216,11 @@ class WzEditConfiguration extends Component {
216216
nodes.data.data.affected_items.find(
217217
node => node.name === this.props.clusterNodeSelected,
218218
);
219-
const masterNode = nodes.data.data.affected_items.find(
220-
node => node.type === 'master',
221-
);
222219
this.props.updateClusterNodeSelected(
223220
existsClusterCurrentNodeSelected
224221
? existsClusterCurrentNodeSelected.name
225-
: masterNode?.name || nodes.data.data.affected_items[0]?.name,
222+
: nodes.data.data.affected_items.find(node => node.type === 'master')
223+
.name,
226224
);
227225
this.props.updateConfigurationSection(
228226
'edit-configuration',

plugins/main/public/controllers/management/components/management/configuration/util-components/refresh-cluster-info-button.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,11 @@ class WzRefreshClusterInfoButton extends Component {
4242
nodes.data.data.affected_items.find(
4343
node => node.name === this.props.clusterNodeSelected,
4444
);
45-
const masterNode = nodes.data.data.affected_items.find(
46-
node => node.type === 'master',
47-
);
4845
this.props.updateClusterNodeSelected(
4946
existsClusterCurrentNodeSelected
5047
? existsClusterCurrentNodeSelected.name
51-
: masterNode?.name || nodes.data.data.affected_items[0]?.name,
48+
: nodes.data.data.affected_items.find(node => node.type === 'master')
49+
.name,
5250
);
5351
} catch (error) {
5452
// do nothing if it isn't a cluster

0 commit comments

Comments
 (0)