-
Notifications
You must be signed in to change notification settings - Fork 3k
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
fix: Don't show Billings on settings navbar when self-hosted #1912
Conversation
Can't reproduce test failures locally. |
tests fail when running with seed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tonyvince thanks for the fix here, but I think instead of trying to fix this error, we should never be experiencing it in the first place.
I think in self hosted mode, we should remove the "Billing" page entirely from the application and disable all Stripe / Billing related code when SELF_HOSTED=true
@zachgoll changed implementation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we'll need to add condition: :self_hosted?
in our settings helper too:
maybe/app/helpers/settings_helper.rb
Lines 2 to 15 in f7064fd
SETTINGS_ORDER = [ | |
{ name: I18n.t("settings.settings_nav.profile_label"), path: :settings_profile_path }, | |
{ name: I18n.t("settings.settings_nav.preferences_label"), path: :settings_preferences_path }, | |
{ name: I18n.t("settings.settings_nav.security_label"), path: :settings_security_path }, | |
{ name: I18n.t("settings.settings_nav.self_hosting_label"), path: :settings_hosting_path, condition: :self_hosted? }, | |
{ name: I18n.t("settings.settings_nav.billing_label"), path: :settings_billing_path }, | |
{ name: I18n.t("settings.settings_nav.accounts_label"), path: :accounts_path }, | |
{ name: I18n.t("settings.settings_nav.imports_label"), path: :imports_path }, | |
{ name: I18n.t("settings.settings_nav.tags_label"), path: :tags_path }, | |
{ name: I18n.t("settings.settings_nav.categories_label"), path: :categories_path }, | |
{ name: I18n.t("settings.settings_nav.merchants_label"), path: :merchants_path }, | |
{ name: I18n.t("settings.settings_nav.whats_new_label"), path: :changelog_path }, | |
{ name: I18n.t("settings.settings_nav.feedback_label"), path: :feedback_path } | |
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than the Stripe error handling, looks good!
before_action :redirect_to_root_if_self_hosted | ||
rescue_from Stripe::AuthenticationError do | ||
redirect_to settings_billing_path, alert: "Invalid Stripe secret key." | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reasoning behind this rescue_from
block? My preference would be to avoid any "swallowing" of errors silently as we'd want to hit an error in our hosted version if something is wrong with Stripe.
If we're getting an error like this, I think that indicates that there is a problem upstream somewhere in the configuration for self hosted instances that we need to address to ensure we aren't calling Stripe-related code on self hosted apps at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
close #1911