Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PM-13818] Allow user to edit self-hosted url during registration #11790

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

alec-livefront
Copy link
Collaborator

@alec-livefront alec-livefront commented Oct 30, 2024

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-13818?atlOrigin=eyJpIjoiZmQ2Njc1OTg0NTg5NGI1NDkxMjdhZmQ0NThiOGJmZjciLCJwIjoiaiJ9

📔 Objective

Re-launch the self-hosted-env-config-dialog after a user has previously selected the self hosted option from the "Creating account on" select. This allows a user to go back and edit values after the dialog has closed.

📸 Screenshots

Screenshot 2024-10-30 at 9 12 54 AM
Screenshot 2024-10-30 at 9 13 04 AM

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

Copy link

codecov bot commented Oct 30, 2024

Codecov Report

Attention: Patch coverage is 0% with 10 lines in your changes missing coverage. Please review.

Project coverage is 33.55%. Comparing base (4a2c14d) to head (6270014).

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...nv-selector/registration-env-selector.component.ts 0.00% 7 Missing ⚠️
libs/components/src/select/select.component.ts 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11790      +/-   ##
==========================================
- Coverage   33.55%   33.55%   -0.01%     
==========================================
  Files        2814     2814              
  Lines       87435    87440       +5     
  Branches    16674    16676       +2     
==========================================
  Hits        29337    29337              
- Misses      55793    55798       +5     
  Partials     2305     2305              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines 115 to 121
private handleSelfHostedSelection(prevSelectedRegion: RegionConfig | Region.SelfHosted | null) {
return from(SelfHostedEnvConfigDialogComponent.open(this.dialogService)).pipe(
tap((result: boolean | undefined) =>
this.handleSelfHostedEnvConfigDialogResult(result, prevSelectedRegion),
),
);
}
Copy link
Contributor

@willmartian willmartian Oct 30, 2024

Choose a reason for hiding this comment

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

Converting the open promise to an observable requires a lot of ceremony that isn't buying us anything, since we are effectively converting it back to a promise with take(1) and subscribe() in onSelectClosed.

What do you think of this alternative?

type RegionSelection = RegionConfig | Region.SelfHosted | null;

protected async onSelectClosed(selection: RegionSelection) {
    if (selection === Region.SelfHosted) {
      const result = await SelfHostedEnvConfigDialogComponent.open(this.dialogService)
      return this.handleSelfHostedEnvConfigDialogResult(result, selection);
    }
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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


protected selectedValue: T;
protected selectedOption: Option<T>;
protected searchInputId = `bit-select-search-input-${nextId++}`;
protected lastSelectedValue: T;
Copy link
Contributor

Choose a reason for hiding this comment

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

How does this differ from selectedValue?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is tricky because the selectedValue doesn't update when we select the option twice. registration-env-selector.component.ts doesn't pick up the changes(this.selectedRegion.valueChanges). When onClose is called this.selectedValue doesn't seem to reflect the currently selected value, but the previously selected value (maybe some race condition or async call somewhere?). Any ideas?

I updated the variable name to userSelectedValue which is maybe a little clearer on the intent?

Comment on lines 169 to 171
if (this.lastSelectedValue !== undefined) {
this.closed.emit(this.lastSelectedValue);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like we should always emit, since the event is called "closed" and the select is indeed closing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

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.

2 participants