From 38b6e30bea1e9d28df16d232c44b07fa8df14918 Mon Sep 17 00:00:00 2001 From: Josh Pigford Date: Thu, 1 May 2025 17:01:40 -0500 Subject: [PATCH 1/3] Add conditional rendering for sync all button in transactions index view - The "Dev only: Sync all" button is now only displayed in the development environment to prevent accidental usage in production. --- app/views/transactions/index.html.erb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/transactions/index.html.erb b/app/views/transactions/index.html.erb index 6ab1cc44..9781672f 100644 --- a/app/views/transactions/index.html.erb +++ b/app/views/transactions/index.html.erb @@ -4,7 +4,9 @@
<%= render MenuComponent.new do |menu| %> - <% menu.with_item(variant: "button", text: "Dev only: Sync all", href: sync_all_accounts_path, method: :post, icon: "refresh-cw") %> + <% if Rails.env.development? %> + <% menu.with_item(variant: "button", text: "Dev only: Sync all", href: sync_all_accounts_path, method: :post, icon: "refresh-cw") %> + <% end %> <% menu.with_item(variant: "link", text: "New rule", href: new_rule_path(resource_type: "transaction"), icon: "plus", data: { turbo_frame: :modal }) %> <% menu.with_item(variant: "link", text: "Edit rules", href: rules_path, icon: "git-branch", data: { turbo_frame: :_top }) %> <% menu.with_item(variant: "link", text: "Edit categories", href: categories_path, icon: "shapes", data: { turbo_frame: :_top }) %> From 17fa5413f6c3ffd7fe1c450dc837ff7ee3ad8c9e Mon Sep 17 00:00:00 2001 From: Josh Pigford Date: Thu, 1 May 2025 17:14:59 -0500 Subject: [PATCH 2/3] Enhance onboarding logic to account for recent trial starts - Added a check to determine if a trial was started within the last few seconds, allowing for the assumption that onboarding was just completed even if the onboarded_at timestamp appears blank momentarily. This improves the user experience during onboarding transitions. --- app/controllers/concerns/onboardable.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/concerns/onboardable.rb b/app/controllers/concerns/onboardable.rb index 804667b4..66f89ba9 100644 --- a/app/controllers/concerns/onboardable.rb +++ b/app/controllers/concerns/onboardable.rb @@ -18,7 +18,11 @@ module Onboardable return unless Current.user return unless redirectable_path?(request.path) - if Current.user.onboarded_at.blank? + # Check if trial was started VERY recently (e.g., within the last few seconds) + # If so, assume onboarding was just completed in the previous request, even if onboarded_at appears blank momentarily. + trial_just_started = Current.family.trial_started_at.present? && Current.family.trial_started_at > 10.seconds.ago + + if Current.user.onboarded_at.blank? && !trial_just_started redirect_to onboarding_path elsif !Current.family.subscribed? && !Current.family.trialing? redirect_to upgrade_subscription_path From 194dad702dcebbc8d3f482696865a661cc4eb8db Mon Sep 17 00:00:00 2001 From: Alex Hatzenbuhler Date: Thu, 1 May 2025 17:43:21 -0500 Subject: [PATCH 3/3] Fix initials + profile pictures (#2186) * Improve initials + profile pictures * Change to url_options --- app/components/menu_component.html.erb | 2 +- app/components/menu_component.rb | 5 +++-- app/controllers/application_controller.rb | 9 +++++++++ app/models/user.rb | 2 +- app/views/settings/profiles/show.html.erb | 4 ++-- app/views/users/_user_menu.html.erb | 4 ++-- 6 files changed, 18 insertions(+), 8 deletions(-) diff --git a/app/components/menu_component.html.erb b/app/components/menu_component.html.erb index 527e5e36..00f19b2a 100644 --- a/app/components/menu_component.html.erb +++ b/app/components/menu_component.html.erb @@ -6,7 +6,7 @@ <% elsif variant == :avatar %> <% end %> diff --git a/app/components/menu_component.rb b/app/components/menu_component.rb index 012b2f62..850031fa 100644 --- a/app/components/menu_component.rb +++ b/app/components/menu_component.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class MenuComponent < ViewComponent::Base - attr_reader :variant, :avatar_url, :placement, :offset, :icon_vertical, :no_padding, :testid + attr_reader :variant, :avatar_url, :initials, :placement, :offset, :icon_vertical, :no_padding, :testid renders_one :button, ->(**button_options, &block) do options_with_target = button_options.merge(data: { menu_target: "button" }) @@ -23,9 +23,10 @@ class MenuComponent < ViewComponent::Base VARIANTS = %i[icon button avatar].freeze - def initialize(variant: "icon", avatar_url: nil, placement: "bottom-end", offset: 12, icon_vertical: false, no_padding: false, testid: nil) + def initialize(variant: "icon", avatar_url: nil, initials: nil, placement: "bottom-end", offset: 12, icon_vertical: false, no_padding: false, testid: nil) @variant = variant.to_sym @avatar_url = avatar_url + @initials = initials @placement = placement @offset = offset @icon_vertical = icon_vertical diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 44a94d12..a54dc088 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -4,6 +4,7 @@ class ApplicationController < ActionController::Base before_action :detect_os before_action :set_default_chat + before_action :set_active_storage_url_options private def detect_os @@ -23,4 +24,12 @@ class ApplicationController < ActionController::Base @last_viewed_chat = Current.user&.last_viewed_chat @chat = @last_viewed_chat end + + def set_active_storage_url_options + ActiveStorage::Current.url_options = { + protocol: request.protocol, + host: request.host, + port: request.optional_port + } + end end diff --git a/app/models/user.rb b/app/models/user.rb index e997a58f..00dfd5af 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -21,7 +21,7 @@ class User < ApplicationRecord has_one_attached :profile_image do |attachable| attachable.variant :thumbnail, resize_to_fill: [ 300, 300 ], convert: :webp, saver: { quality: 80 } - attachable.variant :small, resize_to_fill: [ 72, 72 ], convert: :webp, saver: { quality: 80 } + attachable.variant :small, resize_to_fill: [ 72, 72 ], convert: :webp, saver: { quality: 80 }, preprocessed: true end validate :profile_image_size diff --git a/app/views/settings/profiles/show.html.erb b/app/views/settings/profiles/show.html.erb index 00858024..fa97c57e 100644 --- a/app/views/settings/profiles/show.html.erb +++ b/app/views/settings/profiles/show.html.erb @@ -41,9 +41,9 @@

<%= Current.family.name %> · <%= Current.family.users.size %>

<% @users.each do |user| %> -
+
- <%= render "settings/user_avatar", avatar_url: user.profile_image.url %> + <%= render "settings/user_avatar", avatar_url: user.profile_image&.variant(:small)&.url, initials: user.initials %>

<%= user.display_name %>

diff --git a/app/views/users/_user_menu.html.erb b/app/views/users/_user_menu.html.erb index 92566c49..69d64d81 100644 --- a/app/views/users/_user_menu.html.erb +++ b/app/views/users/_user_menu.html.erb @@ -1,11 +1,11 @@ <%# locals: (user:, placement: "right-start", offset: 16) %>
- <%= render MenuComponent.new(variant: "avatar", avatar_url: user.profile_image&.variant(:small)&.url, placement: placement, offset: offset) do |menu| %> + <%= render MenuComponent.new(variant: "avatar", avatar_url: user.profile_image&.variant(:small)&.url, initials: user.initials, placement: placement, offset: offset) do |menu| %> <%= menu.with_header do %>
- <%= render "settings/user_avatar", avatar_url: user.profile_image&.variant(:small)&.url, lazy: true %> + <%= render "settings/user_avatar", avatar_url: user.profile_image&.variant(:small)&.url, initials: user.initials, lazy: true %>