Skip to content

Conversation

hakansa
Copy link
Member

@hakansa hakansa commented Aug 5, 2025

[client] Add Edit Button to Profile Window

Describe your changes

Issue ticket number and link

Stack

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)
  • Extended the README / documentation, if necessary

By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.

@Copilot Copilot AI review requested due to automatic review settings August 5, 2025 15:01
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds an Edit button to the NetBird client's profile window that allows users to edit active profiles. The changes enhance the user interface by providing a more intuitive way to access profile settings directly from the profiles list.

Key changes:

  • Added an Edit button that appears only for active profiles and opens the settings window
  • Enhanced profile display to show email addresses alongside profile names when available
  • Increased window width to accommodate the additional UI elements

// Try to get email from profile state
email := ""
profileState, err := s.profileManager.GetProfileState(profile.Name)
if err == nil && profileState.Email != "" {
Copy link
Preview

Copilot AI Aug 5, 2025

Choose a reason for hiding this comment

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

The profile state is fetched for every profile in a loop, which could result in N+1 query performance issues. Consider batching these operations or caching profile states if this method is called frequently.

Suggested change
if err == nil && profileState.Email != "" {
// Batch fetch profile states to avoid N+1 queries
profileNames := make([]string, 0, len(profilesResp.Profiles))
for _, profile := range profilesResp.Profiles {
profileNames = append(profileNames, profile.Name)
}
profileStates := batchGetProfileStates(s.profileManager, profileNames)
for _, profile := range profilesResp.Profiles {
// Try to get email from profile state
email := ""
if profileState, ok := profileStates[profile.Name]; ok && profileState != nil && profileState.Email != "" {

Copilot uses AI. Check for mistakes.

profileState, err := p.profileManager.GetProfileState(profile.Name)
if err == nil && profileState.Email != "" {
email = profileState.Email
}
Copy link
Preview

Copilot AI Aug 5, 2025

Choose a reason for hiding this comment

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

The logic for fetching profile state and email is duplicated between two methods. Consider extracting this into a helper function to reduce code duplication and improve maintainability.

Suggested change
}
email := p.getProfileEmail(profile.Name)

Copilot uses AI. Check for mistakes.

s.wProfiles = s.app.NewWindow("NetBird Profiles")
s.wProfiles.SetContent(content)
s.wProfiles.Resize(fyne.NewSize(400, 300))
s.wProfiles.Resize(fyne.NewSize(600, 300))
Copy link
Preview

Copilot AI Aug 5, 2025

Choose a reason for hiding this comment

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

[nitpick] The hardcoded window dimensions (600, 300) should be defined as constants or computed based on content to improve maintainability and make the UI more responsive to different screen sizes.

Suggested change
s.wProfiles.Resize(fyne.NewSize(600, 300))
s.wProfiles.Resize(fyne.NewSize(profilesWindowWidth, profilesWindowHeight))

Copilot uses AI. Check for mistakes.

Copy link

sonarqubecloud bot commented Aug 5, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant