Skip to content

Clear selected rows after update - #694

Open
Nikhil-Ashoka wants to merge 1 commit into
ibm-openbmc:1120-vue3from
Nikhil-Ashoka:usr-checkbox
Open

Clear selected rows after update#694
Nikhil-Ashoka wants to merge 1 commit into
ibm-openbmc:1120-vue3from
Nikhil-Ashoka:usr-checkbox

Conversation

@Nikhil-Ashoka

Copy link
Copy Markdown
Collaborator

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📋 Review Summary

This PR refactors the user selection clearing mechanism in the User Management page by replacing direct clearSelectedRows(tableRef) function calls with event-based communication using eventBus.emit('clear-selected'). The refactoring improves code maintainability by decoupling the selection clearing logic from the component, allowing the useTableSelectableComposable to handle the event centrally.

🔍 General Feedback

  • Good refactoring approach: Using event-based communication is a cleaner pattern that reduces coupling between components
  • Consistent implementation: The change is applied consistently across all four locations where selection clearing is needed
  • Event listener exists: The useTableSelectableComposable.js properly handles the clear-selected event
  • ⚠️ Timing consideration: Two instances emit the event immediately after calling userManagement.getUsers() without awaiting, which could lead to race conditions where selections are cleared before the user list is fully refreshed

authenticationStore.logout();
} else {
userManagement.getUsers();
eventBus.emit('clear-selected');

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 The event emission after userManagement.getUsers() may cause a race condition. The getUsers() call is asynchronous but not awaited, so clear-selected could be emitted before the user list is fully refreshed. This might lead to inconsistent UI state.

Consider awaiting the getUsers() call before emitting the event:

Suggested change
eventBus.emit('clear-selected');
await userManagement.getUsers();
eventBus.emit('clear-selected');

});
}
userManagement.getUsers();
eventBus.emit('clear-selected');

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Same race condition issue as above. The getUsers() call is asynchronous but not awaited before emitting clear-selected. This could lead to the selection being cleared before the user list is fully updated.

Suggested change
eventBus.emit('clear-selected');
await userManagement.getUsers();
eventBus.emit('clear-selected');

- Clear selected rows after update in User management page.
- Defect: https://jazz07.rchland.ibm.com:13443/jazz/web/projects/CSSD#action=com.ibm.team.workitem.viewWorkItem&id=800732

Signed-off-by: Nikhil Ashoka <a.nikhil@ibm.com>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📋 Review Summary

This PR standardizes the approach to clearing selected rows after CRUD operations across multiple components by replacing direct clearSelectedRows() calls with event bus emissions. The change improves code consistency and maintainability by centralizing the selection clearing logic.

🔍 General Feedback

  • Positive: The refactoring to use eventBus.emit('clear-selected') creates a more decoupled architecture and follows a consistent pattern across the application
  • Positive: Removal of redundant comments and duplicate function calls in Sessions.vue improves code cleanliness
  • Concern: EventLogs.vue manually sets checkbox states in addition to emitting the event, while other components only emit the event. This inconsistency suggests either the event handler doesn't fully clear all state, or EventLogs has unique state management requirements that should be documented
  • Note: Previous review comments about race conditions in UserManagement.vue (lines 532 and 587) remain valid - consider awaiting getUsers() before emitting the clear event to prevent UI state inconsistencies

this.reloadEventLogData();
eventBus.emit('clear-selected');
this.tableHeaderCheckboxModel = false;
this.tableHeaderCheckboxIndeterminate = false;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Inconsistent approach to clearing selection state. In EventLogs.vue, you're manually setting checkbox states (tableHeaderCheckboxModel and tableHeaderCheckboxIndeterminate), but in other files you're only emitting the event. This suggests the event handler might not be properly clearing all state, or EventLogs has additional state that other components don't have.

Consider either:

  1. Ensuring the clear-selected event handler clears all necessary state consistently across all components, or
  2. Documenting why EventLogs requires manual state clearing while others don't

// Clear selection and reset header checkbox after disconnecting sessions
clearSelectedRows(tableSessionsRef);
// Clear all selections after disconnect operation completes
eventBus.emit('clear-selected');

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Good cleanup removing redundant comments and duplicate clearSelectedRows call. The code is now cleaner with just the event emission.

.finally(() => {
// Clear selection and reset header checkbox after batch deletion
clearSelectedRows(tableRef);
eventBus.emit('clear-selected');

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Good refactoring to use the event bus pattern instead of direct function calls. This makes the code more maintainable and follows a consistent pattern across the application.

@tiwari-nishant tiwari-nishant left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants