diff --git a/app/controllers/admin/rules_controller.rb b/app/controllers/admin/rules_controller.rb index d31aec6ea8..b8def22ba3 100644 --- a/app/controllers/admin/rules_controller.rb +++ b/app/controllers/admin/rules_controller.rb @@ -53,7 +53,7 @@ module Admin end def resource_params - params.require(:rule).permit(:text, :priority) + params.require(:rule).permit(:text, :hint, :priority) end end end diff --git a/app/javascript/mastodon/features/about/index.jsx b/app/javascript/mastodon/features/about/index.jsx index 3287631ed1..5197d338cd 100644 --- a/app/javascript/mastodon/features/about/index.jsx +++ b/app/javascript/mastodon/features/about/index.jsx @@ -170,7 +170,8 @@ class About extends PureComponent {
    {server.get('rules').map(rule => (
  1. - {rule.get('text')} +
    {rule.get('text')}
    + {rule.get('hint').length > 0 && (
    {rule.get('hint')}
    )}
  2. ))}
diff --git a/app/javascript/styles/mastodon/about.scss b/app/javascript/styles/mastodon/about.scss index 0f02563b48..9d23ef41ab 100644 --- a/app/javascript/styles/mastodon/about.scss +++ b/app/javascript/styles/mastodon/about.scss @@ -53,4 +53,10 @@ $fluid-breakpoint: $maximum-width + 20px; border-bottom: 0; } } + + &__hint { + font-size: 14px; + font-weight: 400; + color: $darker-text-color; + } } diff --git a/app/models/rule.rb b/app/models/rule.rb index 602e5d5874..f28dc2ffeb 100644 --- a/app/models/rule.rb +++ b/app/models/rule.rb @@ -10,6 +10,7 @@ # text :text default(""), not null # created_at :datetime not null # updated_at :datetime not null +# hint :text default(""), not null # class Rule < ApplicationRecord include Discard::Model diff --git a/app/serializers/rest/rule_serializer.rb b/app/serializers/rest/rule_serializer.rb index fc925925a9..9e2bcda15e 100644 --- a/app/serializers/rest/rule_serializer.rb +++ b/app/serializers/rest/rule_serializer.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class REST::RuleSerializer < ActiveModel::Serializer - attributes :id, :text + attributes :id, :text, :hint def id object.id.to_s diff --git a/app/views/admin/rules/edit.html.haml b/app/views/admin/rules/edit.html.haml index ba7e6451a1..77815588d2 100644 --- a/app/views/admin/rules/edit.html.haml +++ b/app/views/admin/rules/edit.html.haml @@ -7,5 +7,8 @@ .fields-group = f.input :text, wrapper: :with_block_label + .fields-group + = f.input :hint, wrapper: :with_block_label + .actions = f.button :button, t('generic.save_changes'), type: :submit diff --git a/app/views/admin/rules/index.html.haml b/app/views/admin/rules/index.html.haml index aa6a4c1b6a..dd15ce03c0 100644 --- a/app/views/admin/rules/index.html.haml +++ b/app/views/admin/rules/index.html.haml @@ -12,6 +12,9 @@ .fields-group = f.input :text, wrapper: :with_block_label + .fields-group + = f.input :hint, wrapper: :with_block_label + .actions = f.button :button, t('admin.rules.add_new'), type: :submit diff --git a/app/views/auth/registrations/rules.html.haml b/app/views/auth/registrations/rules.html.haml index 234f4a601d..3a05ed54f0 100644 --- a/app/views/auth/registrations/rules.html.haml +++ b/app/views/auth/registrations/rules.html.haml @@ -20,6 +20,7 @@ - @rules.each do |rule| %li .rules-list__text= rule.text + .rules-list__hint= rule.hint .stacked-actions - accept_path = @invite_code.present? ? public_invite_url(invite_code: @invite_code, accept: @accept_token) : new_user_registration_path(accept: @accept_token) diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml index 7ece81290f..4ba6e88f41 100644 --- a/config/locales/simple_form.en.yml +++ b/config/locales/simple_form.en.yml @@ -116,6 +116,7 @@ en: sign_up_requires_approval: New sign-ups will require your approval severity: Choose what will happen with requests from this IP rule: + hint: Optional. Provide more details about the rule text: Describe a rule or requirement for users on this server. Try to keep it short and simple sessions: otp: 'Enter the two-factor code generated by your phone app or use one of your recovery codes:' @@ -299,6 +300,7 @@ en: patch: Notify on bugfix updates trending_tag: New trend requires review rule: + hint: Additional information text: Rule settings: indexable: Include profile page in search engines diff --git a/db/migrate/20240310123453_add_hint_to_rules.rb b/db/migrate/20240310123453_add_hint_to_rules.rb new file mode 100644 index 0000000000..06822ad96a --- /dev/null +++ b/db/migrate/20240310123453_add_hint_to_rules.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class AddHintToRules < ActiveRecord::Migration[7.1] + def change + add_column :rules, :hint, :text, null: false, default: '' + end +end diff --git a/db/schema.rb b/db/schema.rb index 97917d0456..b98253a6c1 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[7.1].define(version: 2024_03_04_090449) do +ActiveRecord::Schema[7.1].define(version: 2024_03_10_123453) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -915,6 +915,7 @@ ActiveRecord::Schema[7.1].define(version: 2024_03_04_090449) do t.text "text", default: "", null: false t.datetime "created_at", precision: nil, null: false t.datetime "updated_at", precision: nil, null: false + t.text "hint", default: "", null: false end create_table "scheduled_statuses", force: :cascade do |t|