Add hints for rules (#29539)

This commit is contained in:
Eugen Rochko 2024-03-11 09:57:07 +01:00 committed by GitHub
parent 98ef38e34e
commit 5b3a8737d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 29 additions and 4 deletions

View file

@ -53,7 +53,7 @@ module Admin
end end
def resource_params def resource_params
params.require(:rule).permit(:text, :priority) params.require(:rule).permit(:text, :hint, :priority)
end end
end end
end end

View file

@ -170,7 +170,8 @@ class About extends PureComponent {
<ol className='rules-list'> <ol className='rules-list'>
{server.get('rules').map(rule => ( {server.get('rules').map(rule => (
<li key={rule.get('id')}> <li key={rule.get('id')}>
<span className='rules-list__text'>{rule.get('text')}</span> <div className='rules-list__text'>{rule.get('text')}</div>
{rule.get('hint').length > 0 && (<div className='rules-list__hint'>{rule.get('hint')}</div>)}
</li> </li>
))} ))}
</ol> </ol>

View file

@ -53,4 +53,10 @@ $fluid-breakpoint: $maximum-width + 20px;
border-bottom: 0; border-bottom: 0;
} }
} }
&__hint {
font-size: 14px;
font-weight: 400;
color: $darker-text-color;
}
} }

View file

@ -10,6 +10,7 @@
# text :text default(""), not null # text :text default(""), not null
# created_at :datetime not null # created_at :datetime not null
# updated_at :datetime not null # updated_at :datetime not null
# hint :text default(""), not null
# #
class Rule < ApplicationRecord class Rule < ApplicationRecord
include Discard::Model include Discard::Model

View file

@ -1,7 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
class REST::RuleSerializer < ActiveModel::Serializer class REST::RuleSerializer < ActiveModel::Serializer
attributes :id, :text attributes :id, :text, :hint
def id def id
object.id.to_s object.id.to_s

View file

@ -7,5 +7,8 @@
.fields-group .fields-group
= f.input :text, wrapper: :with_block_label = f.input :text, wrapper: :with_block_label
.fields-group
= f.input :hint, wrapper: :with_block_label
.actions .actions
= f.button :button, t('generic.save_changes'), type: :submit = f.button :button, t('generic.save_changes'), type: :submit

View file

@ -12,6 +12,9 @@
.fields-group .fields-group
= f.input :text, wrapper: :with_block_label = f.input :text, wrapper: :with_block_label
.fields-group
= f.input :hint, wrapper: :with_block_label
.actions .actions
= f.button :button, t('admin.rules.add_new'), type: :submit = f.button :button, t('admin.rules.add_new'), type: :submit

View file

@ -20,6 +20,7 @@
- @rules.each do |rule| - @rules.each do |rule|
%li %li
.rules-list__text= rule.text .rules-list__text= rule.text
.rules-list__hint= rule.hint
.stacked-actions .stacked-actions
- accept_path = @invite_code.present? ? public_invite_url(invite_code: @invite_code, accept: @accept_token) : new_user_registration_path(accept: @accept_token) - accept_path = @invite_code.present? ? public_invite_url(invite_code: @invite_code, accept: @accept_token) : new_user_registration_path(accept: @accept_token)

View file

@ -116,6 +116,7 @@ en:
sign_up_requires_approval: New sign-ups will require your approval sign_up_requires_approval: New sign-ups will require your approval
severity: Choose what will happen with requests from this IP severity: Choose what will happen with requests from this IP
rule: 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 text: Describe a rule or requirement for users on this server. Try to keep it short and simple
sessions: sessions:
otp: 'Enter the two-factor code generated by your phone app or use one of your recovery codes:' 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 patch: Notify on bugfix updates
trending_tag: New trend requires review trending_tag: New trend requires review
rule: rule:
hint: Additional information
text: Rule text: Rule
settings: settings:
indexable: Include profile page in search engines indexable: Include profile page in search engines

View file

@ -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

View file

@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # 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 # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" 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.text "text", default: "", null: false
t.datetime "created_at", precision: nil, null: false t.datetime "created_at", precision: nil, null: false
t.datetime "updated_at", precision: nil, null: false t.datetime "updated_at", precision: nil, null: false
t.text "hint", default: "", null: false
end end
create_table "scheduled_statuses", force: :cascade do |t| create_table "scheduled_statuses", force: :cascade do |t|