From 9927df83add34bcdb339c9be5a51b92fe0959377 Mon Sep 17 00:00:00 2001 From: mayaeh Date: Fri, 1 Dec 2017 09:35:47 +0900 Subject: [PATCH 1/7] Update Japanese translations for KeyboardShortcuts. (#5858) --- app/javascript/mastodon/locales/ja.json | 34 ++++++++++++------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/app/javascript/mastodon/locales/ja.json b/app/javascript/mastodon/locales/ja.json index 05e935d52..4d3881ff2 100644 --- a/app/javascript/mastodon/locales/ja.json +++ b/app/javascript/mastodon/locales/ja.json @@ -102,23 +102,23 @@ "home.column_settings.show_reblogs": "ブースト表示", "home.column_settings.show_replies": "返信表示", "home.settings": "カラム設定", - "keyboard_shortcuts.back": "to navigate back", - "keyboard_shortcuts.boost": "to boost", - "keyboard_shortcuts.column": "to focus a status in one of the columns", - "keyboard_shortcuts.compose": "to focus the compose textarea", - "keyboard_shortcuts.description": "Description", - "keyboard_shortcuts.down": "to move down in the list", - "keyboard_shortcuts.enter": "to open status", - "keyboard_shortcuts.favourite": "to favourite", - "keyboard_shortcuts.heading": "Keyboard Shortcuts", - "keyboard_shortcuts.hotkey": "Hotkey", - "keyboard_shortcuts.legend": "to display this legend", - "keyboard_shortcuts.mention": "to mention author", - "keyboard_shortcuts.reply": "to reply", - "keyboard_shortcuts.search": "to focus search", - "keyboard_shortcuts.toot": "to start a brand new toot", - "keyboard_shortcuts.unfocus": "to un-focus compose textarea/search", - "keyboard_shortcuts.up": "to move up in the list", + "keyboard_shortcuts.back": "戻る", + "keyboard_shortcuts.boost": "ブースト", + "keyboard_shortcuts.column": "左からn番目のカラム内最新トゥートに移動", + "keyboard_shortcuts.compose": "トゥート入力欄に移動", + "keyboard_shortcuts.description": "説明", + "keyboard_shortcuts.down": "カラム内一つ下に移動", + "keyboard_shortcuts.enter": "トゥートの詳細を表示", + "keyboard_shortcuts.favourite": "お気に入り", + "keyboard_shortcuts.heading": "キーボードショートカット一覧", + "keyboard_shortcuts.hotkey": "ホットキー", + "keyboard_shortcuts.legend": "この一覧を表示", + "keyboard_shortcuts.mention": "メンション", + "keyboard_shortcuts.reply": "返信", + "keyboard_shortcuts.search": "検索欄に移動", + "keyboard_shortcuts.toot": "新規トゥート", + "keyboard_shortcuts.unfocus": "トゥート入力欄・検索欄から離れる", + "keyboard_shortcuts.up": "カラム内一つ上に移動", "lightbox.close": "閉じる", "lightbox.next": "次", "lightbox.previous": "前", From df03042a6ed84aad7ea21e683aa56726466a7790 Mon Sep 17 00:00:00 2001 From: Yamagishi Kazutoshi Date: Fri, 1 Dec 2017 20:26:19 +0900 Subject: [PATCH 2/7] Allow admin to deactivate invite created by users (#5860) --- app/policies/invite_policy.rb | 2 +- app/views/admin/invites/_invite.html.haml | 4 +++- app/views/invites/_invite.html.haml | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/policies/invite_policy.rb b/app/policies/invite_policy.rb index e5c68af19..a2a65f934 100644 --- a/app/policies/invite_policy.rb +++ b/app/policies/invite_policy.rb @@ -10,7 +10,7 @@ class InvitePolicy < ApplicationPolicy end def destroy? - owner? || staff? + owner? || (Setting.min_invite_role == 'admin' ? admin? : staff?) end private diff --git a/app/views/admin/invites/_invite.html.haml b/app/views/admin/invites/_invite.html.haml index 9555a8976..d7b697286 100644 --- a/app/views/admin/invites/_invite.html.haml +++ b/app/views/admin/invites/_invite.html.haml @@ -16,4 +16,6 @@ %time.formatted{ datetime: invite.expires_at.iso8601, title: l(invite.expires_at) } = l invite.expires_at %td= table_link_to 'link', public_invite_url(invite_code: invite.code), public_invite_url(invite_code: invite.code) - %td= table_link_to 'times', t('invites.delete'), invite_path(invite), method: :delete if policy(invite).destroy? + %td + - if !invite.expired? && policy(invite).destroy? + = table_link_to 'times', t('invites.delete'), admin_invite_path(invite), method: :delete diff --git a/app/views/invites/_invite.html.haml b/app/views/invites/_invite.html.haml index 3f5f7936c..81d67eb7d 100644 --- a/app/views/invites/_invite.html.haml +++ b/app/views/invites/_invite.html.haml @@ -12,4 +12,6 @@ %time.formatted{ datetime: invite.expires_at.iso8601, title: l(invite.expires_at) } = l invite.expires_at %td= table_link_to 'link', public_invite_url(invite_code: invite.code), public_invite_url(invite_code: invite.code) - %td= table_link_to 'times', t('invites.delete'), invite_path(invite), method: :delete if policy(invite).destroy? + %td + - if invite.expired? && policy(invite).destroy? + = table_link_to 'times', t('invites.delete'), invite_path(invite), method: :delete From eee3b32b7714a302ae384c92ef13601167ec892a Mon Sep 17 00:00:00 2001 From: Yamagishi Kazutoshi Date: Fri, 1 Dec 2017 20:26:57 +0900 Subject: [PATCH 3/7] Fix invites form path (#5861) --- app/controllers/admin/invites_controller.rb | 6 ++++++ app/views/invites/_form.html.haml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/admin/invites_controller.rb b/app/controllers/admin/invites_controller.rb index f4207e3e2..607588d90 100644 --- a/app/controllers/admin/invites_controller.rb +++ b/app/controllers/admin/invites_controller.rb @@ -29,5 +29,11 @@ module Admin @invite.expire! redirect_to admin_invites_path end + + private + + def resource_params + params.require(:invite).permit(:max_uses, :expires_in) + end end end diff --git a/app/views/invites/_form.html.haml b/app/views/invites/_form.html.haml index 99647f597..a01cf5946 100644 --- a/app/views/invites/_form.html.haml +++ b/app/views/invites/_form.html.haml @@ -1,4 +1,4 @@ -= simple_form_for(@invite) do |f| += simple_form_for(@invite, url: controller.is_a?(Admin::InvitesController) ? admin_invites_path : invites_path) do |f| = render 'shared/error_messages', object: @invite .fields-group From 74320971e2cc9f605dbcc23c52ac36e18b80716f Mon Sep 17 00:00:00 2001 From: Yamagishi Kazutoshi Date: Sat, 2 Dec 2017 00:40:02 +0900 Subject: [PATCH 4/7] Add invite filter (#5862) --- app/controllers/admin/invites_controller.rb | 10 ++++++- app/helpers/admin/filter_helper.rb | 3 +- app/models/invite.rb | 3 ++ app/models/invite_filter.rb | 32 +++++++++++++++++++++ app/views/admin/invites/index.html.haml | 8 ++++++ config/locales/en.yml | 5 ++++ 6 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 app/models/invite_filter.rb diff --git a/app/controllers/admin/invites_controller.rb b/app/controllers/admin/invites_controller.rb index 607588d90..faccaa7c8 100644 --- a/app/controllers/admin/invites_controller.rb +++ b/app/controllers/admin/invites_controller.rb @@ -5,7 +5,7 @@ module Admin def index authorize :invite, :index? - @invites = Invite.includes(user: :account).page(params[:page]) + @invites = filtered_invites.includes(user: :account).page(params[:page]) @invite = Invite.new end @@ -35,5 +35,13 @@ module Admin def resource_params params.require(:invite).permit(:max_uses, :expires_in) end + + def filtered_invites + InviteFilter.new(filter_params).results + end + + def filter_params + params.permit(:available, :expired) + end end end diff --git a/app/helpers/admin/filter_helper.rb b/app/helpers/admin/filter_helper.rb index e0fae9d9a..73250cbf5 100644 --- a/app/helpers/admin/filter_helper.rb +++ b/app/helpers/admin/filter_helper.rb @@ -3,8 +3,9 @@ module Admin::FilterHelper ACCOUNT_FILTERS = %i(local remote by_domain silenced suspended recent username display_name email ip).freeze REPORT_FILTERS = %i(resolved account_id target_account_id).freeze + INVITE_FILTER = %i(available expired).freeze - FILTERS = ACCOUNT_FILTERS + REPORT_FILTERS + FILTERS = ACCOUNT_FILTERS + REPORT_FILTERS + INVITE_FILTER def filter_link_to(text, link_to_params, link_class_params = link_to_params) new_url = filtered_url_for(link_to_params) diff --git a/app/models/invite.rb b/app/models/invite.rb index 7626f4cfa..6907c1f1d 100644 --- a/app/models/invite.rb +++ b/app/models/invite.rb @@ -17,6 +17,9 @@ class Invite < ApplicationRecord belongs_to :user, required: true has_many :users, inverse_of: :invite + scope :available, -> { where(expires_at: nil).or(where('expires_at >= ?', Time.now.utc)) } + scope :expired, -> { where.not(expires_at: nil).where('expires_at < ?', Time.now.utc) } + before_validation :set_code attr_reader :expires_in diff --git a/app/models/invite_filter.rb b/app/models/invite_filter.rb new file mode 100644 index 000000000..7d89bad4a --- /dev/null +++ b/app/models/invite_filter.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +class InviteFilter + attr_reader :params + + def initialize(params) + @params = params + end + + def results + scope = Invite.order(created_at: :desc) + + params.each do |key, value| + scope.merge!(scope_for(key, value)) if value.present? + end + + scope + end + + private + + def scope_for(key, _value) + case key.to_s + when 'available' + Invite.available + when 'expired' + Invite.expired + else + raise "Unknown filter: #{key}" + end + end +end diff --git a/app/views/admin/invites/index.html.haml b/app/views/admin/invites/index.html.haml index 52a748fe0..944a60471 100644 --- a/app/views/admin/invites/index.html.haml +++ b/app/views/admin/invites/index.html.haml @@ -1,6 +1,14 @@ - content_for :page_title do = t('admin.invites.title') +.filters + .filter-subset + %strong= t('admin.invites.filter.title') + %ul + %li= filter_link_to t('admin.invites.filter.all'), available: nil, expired: nil + %li= filter_link_to t('admin.invites.filter.available'), available: 1, expired: nil + %li= filter_link_to t('admin.invites.filter.expired'), available: nil, expired: 1 + - if policy(:invite).create? %p= t('invites.prompt') diff --git a/config/locales/en.yml b/config/locales/en.yml index 2719a4f8c..5b9d43b9f 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -232,6 +232,11 @@ en: search: Search title: Known instances invites: + filter: + all: All + available: Available + expired: Expired + title: Filter title: Invites reports: action_taken_by: Action taken by From b15482ce71c69d13a3af77f5063712b64d6310f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Miko=C5=82ajczak?= Date: Fri, 1 Dec 2017 19:19:30 +0100 Subject: [PATCH 5/7] =?UTF-8?q?i18n:=20=F0=9F=87=B5=F0=9F=87=B1=20(#5865)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/locales/pl.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/config/locales/pl.yml b/config/locales/pl.yml index 3c778658e..50d211ac3 100644 --- a/config/locales/pl.yml +++ b/config/locales/pl.yml @@ -232,6 +232,13 @@ pl: reset: Przywróć search: Szukaj title: Znane instancje + invites: + filter: + all: Wszystkie + available: Dostępne + expired: Wygasłe + title: Filtruj + title: Zaproszenia reports: action_taken_by: Działanie podjęte przez are_you_sure: Czy na pewno? From bdf6d0a68464fc7d80c257b4c4705818e4a1a8d5 Mon Sep 17 00:00:00 2001 From: cormo Date: Sat, 2 Dec 2017 08:42:20 +0900 Subject: [PATCH 6/7] Remove redundant import statement in SCSS (#5864) * Remove redudant import statement in SCSS * Fix wrong chmod --- app/javascript/styles/mastodon/components.scss | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/javascript/styles/mastodon/components.scss b/app/javascript/styles/mastodon/components.scss index 80060a00f..26ff8bf00 100644 --- a/app/javascript/styles/mastodon/components.scss +++ b/app/javascript/styles/mastodon/components.scss @@ -1,5 +1,3 @@ -@import 'variables'; - .app-body { -webkit-overflow-scrolling: touch; -ms-overflow-style: -ms-autohiding-scrollbar; From 51f2eca8877d8c56a19e1b8ce4edf407c2d236fb Mon Sep 17 00:00:00 2001 From: mayaeh Date: Sat, 2 Dec 2017 23:09:56 +0900 Subject: [PATCH 7/7] Add Japanese translations for invite filter. (#5869) --- config/locales/ja.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/config/locales/ja.yml b/config/locales/ja.yml index fd4e63135..a008d9cc4 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -232,6 +232,11 @@ ja: search: 検索 title: 既知のインスタンス invites: + filter: + all: すべて + available: 使用可能 + expired: 期限切れ + title: フィルター title: 招待 reports: action_taken_by: レポート処理者