From 48783824eeaeea7f902720af48a6c09a481f002c Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Fri, 3 Oct 2025 16:55:00 -0400 Subject: [PATCH 1/3] Fix some small things related to accounts --- bin/dev | 1 + test/fixtures/accounts.yml | 3 --- test/test_helper.rb | 3 ++- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/bin/dev b/bin/dev index 1c77800e3..1c3b7427a 100755 --- a/bin/dev +++ b/bin/dev @@ -4,6 +4,7 @@ bin/rails runner - < 0 puts " - #{Account.sole.name}: http://fizzy.localhost:3006#{Account.sole.slug}" end EOF diff --git a/test/fixtures/accounts.yml b/test/fixtures/accounts.yml index 205eee369..587f05a44 100644 --- a/test/fixtures/accounts.yml +++ b/test/fixtures/accounts.yml @@ -1,6 +1,3 @@ 37s: name: 37signals join_code: "ejpP-THlQ-Cc2f" -<% if Account.reflect_on_association :external_account %> - tenant_id: <%= ActiveRecord::FixtureSet.identify :'37s_fizzy' %> -<% end %> diff --git a/test/test_helper.rb b/test/test_helper.rb index fbb2b1149..13ca29e55 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,7 +1,8 @@ ENV["RAILS_ENV"] ||= "test" require_relative "../config/environment" -Rails.application.config.active_record_tenanted.default_tenant = ActiveRecord::FixtureSet.identify :'37s_fizzy' +# there's no fixture for this, we're just generating a stable integer +Rails.application.config.active_record_tenanted.default_tenant = ActiveRecord::FixtureSet.identify "37s_fizzy" require "rails/test_help" require "webmock/minitest" From f26b0b72561f42a59450ca2a51028f1c96a90d8f Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Fri, 3 Oct 2025 17:21:01 -0400 Subject: [PATCH 2/3] Rename accounts.tenant_id to external_account_id and simplify the params to Account.create_with_admin_user --- app/models/account.rb | 14 +++------- ...counts_tenant_id_to_external_account_id.rb | 5 ++++ db/schema.rb | 6 ++--- db/schema_cache.yml | 26 +++++++++---------- db/seeds.rb | 12 ++++++--- test/models/account_test.rb | 16 +++++++----- 6 files changed, 42 insertions(+), 37 deletions(-) create mode 100644 db/migrate/20251003205559_rename_accounts_tenant_id_to_external_account_id.rb diff --git a/app/models/account.rb b/app/models/account.rb index 5ee007e0e..5e97480ce 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -4,17 +4,9 @@ class Account < ApplicationRecord has_many_attached :uploads class << self - def create_with_admin_user(tenant_id:, account_name:, owner_name:, owner_email:) - account = create!(tenant_id:, name: account_name) - - User.create!( - name: owner_name, - email_address: owner_email, - role: "admin", - password: SecureRandom.hex(16) - ) - - account + def create_with_admin_user(account:, owner:) + User.create!(**owner.reverse_merge(role: "admin", password: SecureRandom.hex(16))) + create!(**account) end end diff --git a/db/migrate/20251003205559_rename_accounts_tenant_id_to_external_account_id.rb b/db/migrate/20251003205559_rename_accounts_tenant_id_to_external_account_id.rb new file mode 100644 index 000000000..3a9cb5656 --- /dev/null +++ b/db/migrate/20251003205559_rename_accounts_tenant_id_to_external_account_id.rb @@ -0,0 +1,5 @@ +class RenameAccountsTenantIdToExternalAccountId < ActiveRecord::Migration[8.1] + def change + rename_column :accounts, :tenant_id, :external_account_id + end +end diff --git a/db/schema.rb b/db/schema.rb index 5e2c6ac59..0e8674c4a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.1].define(version: 2025_10_01_181713) do +ActiveRecord::Schema[8.1].define(version: 2025_10_03_205559) do create_table "accesses", force: :cascade do |t| t.datetime "accessed_at" t.integer "collection_id", null: false @@ -26,11 +26,11 @@ ActiveRecord::Schema[8.1].define(version: 2025_10_01_181713) do create_table "accounts", force: :cascade do |t| t.datetime "created_at", null: false + t.integer "external_account_id" t.string "join_code" t.string "name", null: false - t.integer "tenant_id" t.datetime "updated_at", null: false - t.index ["tenant_id"], name: "index_accounts_on_tenant_id", unique: true + t.index ["external_account_id"], name: "index_accounts_on_external_account_id", unique: true end create_table "action_text_rich_texts", force: :cascade do |t| diff --git a/db/schema_cache.yml b/db/schema_cache.yml index 074393719..90b7ccacb 100644 --- a/db/schema_cache.yml +++ b/db/schema_cache.yml @@ -102,6 +102,16 @@ columns: comment: accounts: - *5 + - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + auto_increment: + name: external_account_id + cast_type: *3 + sql_type_metadata: *4 + 'null': true + default: + default_function: + collation: + comment: - *6 - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: @@ -123,16 +133,6 @@ columns: default_function: collation: comment: - - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column - auto_increment: - name: tenant_id - cast_type: *3 - sql_type_metadata: *4 - 'null': true - default: - default_function: - collation: - comment: - *9 action_text_rich_texts: - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column @@ -1666,10 +1666,10 @@ indexes: accounts: - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition table: accounts - name: index_accounts_on_tenant_id + name: index_accounts_on_external_account_id unique: true columns: - - tenant_id + - external_account_id lengths: {} orders: {} opclasses: {} @@ -3222,4 +3222,4 @@ indexes: comment: valid: true workflows: [] -version: 20251001181713 +version: 20251003205559 diff --git a/db/seeds.rb b/db/seeds.rb index 5542dd3d1..26e1a40ff 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -20,10 +20,14 @@ def create_tenant(signal_account_name, bare: false) ApplicationRecord.destroy_tenant tenant_id ApplicationRecord.create_tenant(tenant_id) do account = Account.create_with_admin_user( - tenant_id: tenant_id, - account_name: signal_account_name, - owner_name: "David Heinemeier Hansson", - owner_email: "david@37signals.com", + account: { + external_account_id: tenant_id, + name: signal_account_name + }, + owner: { + name: "David Heinemeier Hansson", + email_address: "david@37signals.com" + } ) account.setup_basic_template end diff --git a/test/models/account_test.rb b/test/models/account_test.rb index 446af4623..50a338d67 100644 --- a/test/models/account_test.rb +++ b/test/models/account_test.rb @@ -9,15 +9,19 @@ class AccountTest < ActiveSupport::TestCase test ".create_with_admin_user creates a new local account" do ApplicationRecord.create_tenant("account-create-with-dependents") do account = Account.create_with_admin_user( - tenant_id: ActiveRecord::FixtureSet.identify("account-create-with-admin-user-test"), - account_name: "Account Create With Admin", - owner_name: "David", - owner_email: "david@37signals.com") - + account: { + external_account_id: ActiveRecord::FixtureSet.identify("account-create-with-admin-user-test"), + name: "Account Create With Admin" + }, + owner: { + name: "David", + email_address: "david@37signals.com" + } + ) assert_not_nil account assert account.persisted? assert_equal 1, Account.count - assert_equal ActiveRecord::FixtureSet.identify("account-create-with-admin-user-test"), account.tenant_id + assert_equal ActiveRecord::FixtureSet.identify("account-create-with-admin-user-test"), account.external_account_id assert_equal "Account Create With Admin", account.name assert_equal 1, User.count From 56069d14e3efafc5c3ab13a25bd11d42ec327736 Mon Sep 17 00:00:00 2001 From: Jason Zimdars Date: Fri, 3 Oct 2025 18:02:10 -0500 Subject: [PATCH 3/3] Tighten filter input --- app/assets/stylesheets/filters.css | 21 ++++++++++++++++++--- app/views/filters/settings/_terms.html.erb | 2 +- app/views/filters/settings/_toggle.html.erb | 2 +- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/app/assets/stylesheets/filters.css b/app/assets/stylesheets/filters.css index 7eeedc3a5..b911649da 100644 --- a/app/assets/stylesheets/filters.css +++ b/app/assets/stylesheets/filters.css @@ -103,11 +103,26 @@ } } - .filter__terms { + .filter__terms:is(.input) { --input-background: var(--color-canvas); + --input-border-radius: 5em; + --input-padding: 0.5em 2.3em 0.5em 1.3em; - .filters:not(.filters--expanded) & { - min-inline-size: 40ch; + inline-size: 22ch; + min-inline-size: 22ch; + + .filters:not(.filters--expanded, .filters--has-filters-set) & { + margin-inline-end: calc((var(--btn-size) + var(--inline-space-half) + 0.25em) * -1); + } + } + + .filter-toggle { + .filters:not(.filters--expanded, .filters--has-filters-set) & { + --btn-background: transparent; + --btn-border-size: 0; + + transform: translateX(calc(var(--inline-space-half) * -1)); + position: relative; } } diff --git a/app/views/filters/settings/_terms.html.erb b/app/views/filters/settings/_terms.html.erb index 06e586df9..0d2f48b4e 100644 --- a/app/views/filters/settings/_terms.html.erb +++ b/app/views/filters/settings/_terms.html.erb @@ -1,4 +1,4 @@ -<%= form.text_field "terms[]", placeholder: "Filter these cards…", class: "filter__terms input txt-x-small", +<%= form.search_field "terms[]", placeholder: "Filter these cards…", class: "filter__terms input txt-x-small", autofocus: false, autocomplete: :off, autocorrect: "off", data: { "1p-ignore": "true", filter_settings_target: "field", diff --git a/app/views/filters/settings/_toggle.html.erb b/app/views/filters/settings/_toggle.html.erb index a731373fa..1f6459e0a 100644 --- a/app/views/filters/settings/_toggle.html.erb +++ b/app/views/filters/settings/_toggle.html.erb @@ -5,7 +5,7 @@ <%= icon_tag "filter" %> <% else %> - <% end %>