1
0
Fork 0
forked from fedi/mastodon

Fix up the applications area (#4664)

- Section it into "Development" area
- Improve UI of application form, index, and details
This commit is contained in:
Eugen Rochko 2017-08-23 00:59:35 +02:00 committed by GitHub
parent 696c2c6f2f
commit c1b086a538
14 changed files with 101 additions and 91 deletions

View file

@ -4,6 +4,7 @@ class Settings::ApplicationsController < ApplicationController
layout 'admin' layout 'admin'
before_action :authenticate_user! before_action :authenticate_user!
before_action :set_application, only: [:show, :update, :destroy, :regenerate]
def index def index
@applications = current_user.applications.page(params[:page]) @applications = current_user.applications.page(params[:page])
@ -16,22 +17,20 @@ class Settings::ApplicationsController < ApplicationController
) )
end end
def show def show; end
@application = current_user.applications.find(params[:id])
end
def create def create
@application = current_user.applications.build(application_params) @application = current_user.applications.build(application_params)
if @application.save if @application.save
redirect_to settings_applications_path, notice: I18n.t('application.created') redirect_to settings_applications_path, notice: I18n.t('applications.created')
else else
render :new render :new
end end
end end
def update def update
@application = current_user.applications.find(params[:id]) if @application.update(application_params)
if @application.update_attributes(application_params)
redirect_to settings_applications_path, notice: I18n.t('generic.changes_saved_msg') redirect_to settings_applications_path, notice: I18n.t('generic.changes_saved_msg')
else else
render :show render :show
@ -39,21 +38,23 @@ class Settings::ApplicationsController < ApplicationController
end end
def destroy def destroy
@application = current_user.applications.find(params[:id])
@application.destroy @application.destroy
redirect_to settings_applications_path, notice: t('application.destroyed') redirect_to settings_applications_path, notice: I18n.t('applications.destroyed')
end end
def regenerate def regenerate
@application = current_user.applications.find(params[:application_id])
@access_token = current_user.token_for_app(@application) @access_token = current_user.token_for_app(@application)
@access_token.destroy @access_token.destroy
redirect_to settings_application_path(@application), notice: t('access_token.regenerated') redirect_to settings_application_path(@application), notice: I18n.t('applications.token_regenerated')
end end
private private
def set_application
@application = current_user.applications.find(params[:id])
end
def application_params def application_params
params.require(:doorkeeper_application).permit( params.require(:doorkeeper_application).permit(
:name, :name,

View file

@ -1,4 +1,11 @@
= f.input :name, hint: t('activerecord.attributes.doorkeeper/application.name') .fields-group
= f.input :website, hint: t('activerecord.attributes.doorkeeper/application.website') = f.input :name, placeholder: t('activerecord.attributes.doorkeeper/application.name')
= f.input :redirect_uri, hint: t('activerecord.attributes.doorkeeper/application.redirect_uri') = f.input :website, placeholder: t('activerecord.attributes.doorkeeper/application.website')
= f.input :scopes, hint: t('activerecord.attributes.doorkeeper/application.scopes')
.fields-group
= f.input :redirect_uri, wrapper: :with_block_label, label: t('activerecord.attributes.doorkeeper/application.redirect_uri'), hint: t('doorkeeper.applications.help.redirect_uri')
%p.hint= t('doorkeeper.applications.help.native_redirect_uri', native_redirect_uri: Doorkeeper.configuration.native_redirect_uri)
.fields-group
= f.input :scopes, wrapper: :with_label, label: t('activerecord.attributes.doorkeeper/application.scopes'), hint: t('doorkeeper.applications.help.scopes')

View file

@ -6,15 +6,14 @@
%tr %tr
%th= t('doorkeeper.applications.index.application') %th= t('doorkeeper.applications.index.application')
%th= t('doorkeeper.applications.index.scopes') %th= t('doorkeeper.applications.index.scopes')
%th= t('doorkeeper.applications.index.created_at')
%th %th
%tbody %tbody
- @applications.each do |application| - @applications.each do |application|
%tr %tr
%td= link_to application.name, settings_application_path(application) %td= link_to application.name, settings_application_path(application)
%th= application.scopes.map { |scope| t(scope, scope: [:doorkeeper, :scopes]) }.join('<br />').html_safe %th= application.scopes
%td= l application.created_at %td
%td= table_link_to 'show', t('doorkeeper.applications.index.show'), settings_application_path(application) = table_link_to 'times', t('doorkeeper.applications.index.delete'), settings_application_path(application), method: :delete, data: { confirm: t('doorkeeper.applications.confirmations.destroy') }
%td= table_link_to 'times', t('doorkeeper.applications.index.delete'), settings_application_path(application), method: :delete, data: { confirm: t('doorkeeper.applications.confirmations.destroy') }
= paginate @applications = paginate @applications
= link_to t('add_new'), new_settings_application_path, class: 'button' = link_to t('doorkeeper.applications.index.new'), new_settings_application_path, class: 'button'

View file

@ -1,9 +1,8 @@
- content_for :page_title do - content_for :page_title do
= t('doorkeeper.applications.new.title') = t('doorkeeper.applications.new.title')
= simple_form_for @application, url: settings_applications_path do |f|
= render 'fields', f: f
.form-container .actions
= simple_form_for @application, url: settings_applications_path do |f| = f.button :button, t('doorkeeper.applications.buttons.submit'), type: :submit
= render 'fields', f:f
.actions
= f.button :button, t('.create'), type: :submit

View file

@ -1,27 +1,29 @@
- content_for :page_title do - content_for :page_title do
= t('doorkeeper.applications.show.title', name: @application.name) = t('doorkeeper.applications.show.title', name: @application.name)
%p.hint= t('applications.warning')
%p.hint= t('application.warning') %table.table
%tbody
%div %tr
%h3= t('application.uid') %th= t('doorkeeper.applications.show.application_id')
%code= @application.uid %td
%code= @application.uid
%tr
%th= t('doorkeeper.applications.show.secret')
%td
%code= @application.secret
%tr
%th{ rowspan: 2}= t('applications.your_token')
%td
%code= current_user.token_for_app(@application).token
%tr
%td= table_link_to 'refresh', t('applications.regenerate_token'), regenerate_settings_application_path(@application), method: :post
%div %hr/
%h3= t('application.secret')
%code= @application.secret
%div
%h3= t('access_token.your_token')
%code= current_user.token_for_app(@application).token
= link_to t('access_token.regenerate'), settings_application_regenerate_path(@application), method: :put, class: 'button'
%hr
= simple_form_for @application, url: settings_application_path(@application), method: :put do |f| = simple_form_for @application, url: settings_application_path(@application), method: :put do |f|
= render 'fields', f:f = render 'fields', f: f
.actions .actions
= f.button :button, t('generic.save_changes'), type: :submit = f.button :button, t('generic.save_changes'), type: :submit

View file

@ -3,10 +3,10 @@ en:
activerecord: activerecord:
attributes: attributes:
doorkeeper/application: doorkeeper/application:
name: Application Name name: Application name
website: Application Website
redirect_uri: Redirect URI redirect_uri: Redirect URI
scopes: Scopes scopes: Scopes
website: Application website
errors: errors:
models: models:
doorkeeper/application: doorkeeper/application:
@ -36,20 +36,19 @@ en:
scopes: Separate scopes with spaces. Leave blank to use the default scopes. scopes: Separate scopes with spaces. Leave blank to use the default scopes.
index: index:
callback_url: Callback URL callback_url: Callback URL
name: Name
new: New Application
title: Your applications
show: Show
delete: Delete delete: Delete
name: Name
new: New application
show: Show
title: Your applications
new: new:
title: New Application title: New application
show: show:
title: 'Application: %{name}'
actions: Actions actions: Actions
application_id: Application Id application_id: Client key
callback_urls: Callback urls callback_urls: Callback URLs
scopes: Scopes scopes: Scopes
secret: Secret secret: Client secret
title: 'Application: %{name}' title: 'Application: %{name}'
authorizations: authorizations:
buttons: buttons:

View file

@ -33,24 +33,20 @@ en:
user_count_after: users user_count_after: users
user_count_before: Home to user_count_before: Home to
what_is_mastodon: What is Mastodon? what_is_mastodon: What is Mastodon?
access_token:
your_token: Your Access Token
regenerate: Regenerate Access Token
regenerated: Access Token Regenerated
accounts: accounts:
follow: Follow follow: Follow
followers: Followers followers: Followers
following: Following following: Following
media: Media
nothing_here: There is nothing here! nothing_here: There is nothing here!
people_followed_by: People whom %{name} follows people_followed_by: People whom %{name} follows
people_who_follow: People who follow %{name} people_who_follow: People who follow %{name}
posts: Toots posts: Toots
posts_with_replies: Toots with replies posts_with_replies: Toots with replies
media: Media
roles:
admin: Admin
remote_follow: Remote follow remote_follow: Remote follow
reserved_username: The username is reserved reserved_username: The username is reserved
roles:
admin: Admin
unfollow: Unfollow unfollow: Unfollow
admin: admin:
accounts: accounts:
@ -230,14 +226,14 @@ en:
settings: 'Change e-mail preferences: %{link}' settings: 'Change e-mail preferences: %{link}'
signature: Mastodon notifications from %{instance} signature: Mastodon notifications from %{instance}
view: 'View:' view: 'View:'
application:
created: Application Created
destroyed: Application Destroyed
uid: Client ID
secret: Client Secret
warning: Be very careful with this data. Never share it with anyone other than authorized applications!
applications: applications:
created: Application successfully created
destroyed: Application successfully deleted
invalid_url: The provided URL is invalid invalid_url: The provided URL is invalid
regenerate_token: Regenerate access token
token_regenerated: Access token successfully regenerated
warning: Be very careful with this data. Never share it with anyone!
your_token: Your access token
auth: auth:
agreement_html: By signing up you agree to <a href="%{rules_path}">our terms of service</a> and <a href="%{terms_path}">privacy policy</a>. agreement_html: By signing up you agree to <a href="%{rules_path}">our terms of service</a> and <a href="%{terms_path}">privacy policy</a>.
change_password: Security change_password: Security
@ -426,6 +422,7 @@ en:
authorized_apps: Authorized apps authorized_apps: Authorized apps
back: Back to Mastodon back: Back to Mastodon
delete: Account deletion delete: Account deletion
development: Development
edit_profile: Edit profile edit_profile: Edit profile
export: Data export export: Data export
followers: Authorized followers followers: Authorized followers

View file

@ -37,16 +37,16 @@ ja:
follow: フォロー follow: フォロー
followers: フォロワー followers: フォロワー
following: フォロー中 following: フォロー中
media: メディア
nothing_here: 何もありません nothing_here: 何もありません
people_followed_by: "%{name} さんがフォロー中のアカウント" people_followed_by: "%{name} さんがフォロー中のアカウント"
people_who_follow: "%{name} さんをフォロー中のアカウント" people_who_follow: "%{name} さんをフォロー中のアカウント"
posts: トゥート posts: トゥート
posts_with_replies: トゥートと返信 posts_with_replies: トゥートと返信
media: メディア
roles:
admin: Admin
remote_follow: リモートフォロー remote_follow: リモートフォロー
reserved_username: このユーザー名は予約されています。 reserved_username: このユーザー名は予約されています。
roles:
admin: Admin
unfollow: フォロー解除 unfollow: フォロー解除
admin: admin:
accounts: accounts:

View file

@ -37,16 +37,16 @@ oc:
follow: Sègre follow: Sègre
followers: Seguidors followers: Seguidors
following: Abonaments following: Abonaments
media: Mèdias
nothing_here: I a pas res aquí ! nothing_here: I a pas res aquí !
people_followed_by: Lo mond que %{name} sèc people_followed_by: Lo mond que %{name} sèc
people_who_follow: Lo mond que sègon %{name} people_who_follow: Lo mond que sègon %{name}
posts: Tuts posts: Tuts
posts_with_replies: Tuts amb responsas posts_with_replies: Tuts amb responsas
media: Mèdias
roles:
admin: Admin
remote_follow: Sègre a distància remote_follow: Sègre a distància
reserved_username: Aqueste nom dutilizaire es reservat reserved_username: Aqueste nom dutilizaire es reservat
roles:
admin: Admin
unfollow: Quitar de sègre unfollow: Quitar de sègre
admin: admin:
accounts: accounts:
@ -221,7 +221,7 @@ oc:
body: "%{reporter} a senhalat %{target}" body: "%{reporter} a senhalat %{target}"
subject: Novèl senhalament per %{instance} (#%{id}) subject: Novèl senhalament per %{instance} (#%{id})
application_mailer: application_mailer:
salutation: '%{name},' salutation: "%{name},"
settings: 'Cambiar las preferéncias de corrièl : %{link}' settings: 'Cambiar las preferéncias de corrièl : %{link}'
signature: Notificacion de Mastodon sus %{instance} signature: Notificacion de Mastodon sus %{instance}
view: 'Veire :' view: 'Veire :'
@ -234,13 +234,13 @@ oc:
delete_account_html: Se volètz suprimir vòstre compte, podètz <a href="%{path}">o far aquí</a>. Vos demandarem que confirmetz. delete_account_html: Se volètz suprimir vòstre compte, podètz <a href="%{path}">o far aquí</a>. Vos demandarem que confirmetz.
didnt_get_confirmation: Avètz pas recebut las instruccions de confirmacion ? didnt_get_confirmation: Avètz pas recebut las instruccions de confirmacion ?
forgot_password: Senhal oblidat ? forgot_password: Senhal oblidat ?
invalid_reset_password_token: Lo geton de reïnicializacion es invalid o acabat. Tornatz demandar un geton se vos plai.
login: Se connectar login: Se connectar
logout: Se desconnectar logout: Se desconnectar
register: Se marcar register: Se marcar
resend_confirmation: Tornar mandar las instruccions de confirmacion resend_confirmation: Tornar mandar las instruccions de confirmacion
reset_password: Reïnicializar lo senhal reset_password: Reïnicializar lo senhal
set_new_password: Picar un nòu senhal set_new_password: Picar un nòu senhal
invalid_reset_password_token: Lo geton de reïnicializacion es invalid o acabat. Tornatz demandar un geton se vos plai.
authorize_follow: authorize_follow:
error: O planhèm, i a agut una error al moment de cercar lo compte error: O planhèm, i a agut una error al moment de cercar lo compte
follow: Sègre follow: Sègre
@ -337,12 +337,12 @@ oc:
x_months: x_months:
one: Fa un mes one: Fa un mes
other: Fa %{count} meses other: Fa %{count} meses
x_years:
one: Fa un an
other: Fa %{count} ans
x_seconds: x_seconds:
one: Fa una segonda one: Fa una segonda
other: Fa %{count} segondas other: Fa %{count} segondas
x_years:
one: Fa un an
other: Fa %{count} ans
deletes: deletes:
bad_password_msg: Ben ensajat pirata ! Senhal incorrècte bad_password_msg: Ben ensajat pirata ! Senhal incorrècte
confirm_password: Picatz vòstre senhal actual per verificar vòstra identitat confirm_password: Picatz vòstre senhal actual per verificar vòstra identitat

View file

@ -37,16 +37,16 @@ pl:
follow: Śledź follow: Śledź
followers: Śledzących followers: Śledzących
following: Śledzi following: Śledzi
media: Zawartość multimedialna
nothing_here: Niczego tu nie ma! nothing_here: Niczego tu nie ma!
people_followed_by: Konta śledzone przez %{name} people_followed_by: Konta śledzone przez %{name}
people_who_follow: Osoby, które śledzą konto %{name} people_who_follow: Osoby, które śledzą konto %{name}
posts: Wpisy posts: Wpisy
posts_with_replies: Wpisy z odpowiedziami posts_with_replies: Wpisy z odpowiedziami
media: Zawartość multimedialna
roles:
admin: Administrator
remote_follow: Śledź zdalnie remote_follow: Śledź zdalnie
reserved_username: Ta nazwa użytkownika jest zarezerwowana. reserved_username: Ta nazwa użytkownika jest zarezerwowana.
roles:
admin: Administrator
unfollow: Przestań śledzić unfollow: Przestań śledzić
admin: admin:
accounts: accounts:
@ -126,8 +126,8 @@ pl:
severity: Priorytet severity: Priorytet
show: show:
affected_accounts: affected_accounts:
one: Dotyczy jednego konta w bazie danych
many: Dotyczy %{count} kont w bazie danych many: Dotyczy %{count} kont w bazie danych
one: Dotyczy jednego konta w bazie danych
other: Dotyczy %{count} kont w bazie danych other: Dotyczy %{count} kont w bazie danych
retroactive: retroactive:
silence: Odwołaj wyciszenie wszystkich kont w tej domenie silence: Odwołaj wyciszenie wszystkich kont w tej domenie

View file

@ -12,10 +12,13 @@ SimpleNavigation::Configuration.run do |navigation|
settings.item :import, safe_join([fa_icon('cloud-upload fw'), t('settings.import')]), settings_import_url settings.item :import, safe_join([fa_icon('cloud-upload fw'), t('settings.import')]), settings_import_url
settings.item :export, safe_join([fa_icon('cloud-download fw'), t('settings.export')]), settings_export_url settings.item :export, safe_join([fa_icon('cloud-download fw'), t('settings.export')]), settings_export_url
settings.item :authorized_apps, safe_join([fa_icon('list fw'), t('settings.authorized_apps')]), oauth_authorized_applications_url settings.item :authorized_apps, safe_join([fa_icon('list fw'), t('settings.authorized_apps')]), oauth_authorized_applications_url
settings.item :your_apps, safe_join([fa_icon('list fw'), t('settings.your_apps')]), settings_applications_url
settings.item :follower_domains, safe_join([fa_icon('users fw'), t('settings.followers')]), settings_follower_domains_url settings.item :follower_domains, safe_join([fa_icon('users fw'), t('settings.followers')]), settings_follower_domains_url
end end
primary.item :development, safe_join([fa_icon('code fw'), t('settings.development')]), settings_applications_url do |development|
development.item :your_apps, safe_join([fa_icon('list fw'), t('settings.your_apps')]), settings_applications_url, highlights_on: %r{/settings/applications}
end
primary.item :admin, safe_join([fa_icon('cogs fw'), t('admin.title')]), admin_reports_url, if: proc { current_user.admin? } do |admin| primary.item :admin, safe_join([fa_icon('cogs fw'), t('admin.title')]), admin_reports_url, if: proc { current_user.admin? } do |admin|
admin.item :reports, safe_join([fa_icon('flag fw'), t('admin.reports.title')]), admin_reports_url, highlights_on: %r{/admin/reports} admin.item :reports, safe_join([fa_icon('flag fw'), t('admin.reports.title')]), admin_reports_url, highlights_on: %r{/admin/reports}
admin.item :accounts, safe_join([fa_icon('users fw'), t('admin.accounts.title')]), admin_accounts_url, highlights_on: %r{/admin/accounts} admin.item :accounts, safe_join([fa_icon('users fw'), t('admin.accounts.title')]), admin_accounts_url, highlights_on: %r{/admin/accounts}

View file

@ -80,8 +80,10 @@ Rails.application.routes.draw do
resource :follower_domains, only: [:show, :update] resource :follower_domains, only: [:show, :update]
resources :applications do resources :applications, except: [:edit] do
put :regenerate member do
post :regenerate
end
end end
resource :delete, only: [:show, :destroy] resource :delete, only: [:show, :destroy]

View file

@ -216,11 +216,11 @@ ActiveRecord::Schema.define(version: 20170720000000) do
t.string "scopes", default: "", null: false t.string "scopes", default: "", null: false
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.boolean "superapp", default: false, null: false t.boolean "superapp", default: false, null: false
t.string "website" t.string "website"
t.integer "owner_id" t.integer "owner_id"
t.string "owner_type" t.string "owner_type"
t.index ["owner_id", "owner_type"], name: "index_oauth_applications_on_owner_id_and_owner_type", using: :btree t.index ["owner_id", "owner_type"], name: "index_oauth_applications_on_owner_id_and_owner_type"
t.index ["uid"], name: "index_oauth_applications_on_uid", unique: true t.index ["uid"], name: "index_oauth_applications_on_uid", unique: true
end end
@ -423,6 +423,7 @@ ActiveRecord::Schema.define(version: 20170720000000) do
add_foreign_key "oauth_access_grants", "users", column: "resource_owner_id", on_delete: :cascade add_foreign_key "oauth_access_grants", "users", column: "resource_owner_id", on_delete: :cascade
add_foreign_key "oauth_access_tokens", "oauth_applications", column: "application_id", on_delete: :cascade add_foreign_key "oauth_access_tokens", "oauth_applications", column: "application_id", on_delete: :cascade
add_foreign_key "oauth_access_tokens", "users", column: "resource_owner_id", on_delete: :cascade add_foreign_key "oauth_access_tokens", "users", column: "resource_owner_id", on_delete: :cascade
add_foreign_key "oauth_applications", "users", column: "owner_id", on_delete: :cascade
add_foreign_key "preview_cards", "statuses", on_delete: :cascade add_foreign_key "preview_cards", "statuses", on_delete: :cascade
add_foreign_key "reports", "accounts", column: "action_taken_by_account_id", on_delete: :nullify add_foreign_key "reports", "accounts", column: "action_taken_by_account_id", on_delete: :nullify
add_foreign_key "reports", "accounts", column: "target_account_id", on_delete: :cascade add_foreign_key "reports", "accounts", column: "target_account_id", on_delete: :cascade

View file

@ -156,7 +156,7 @@ describe Settings::ApplicationsController do
let(:token) { user.token_for_app(app) } let(:token) { user.token_for_app(app) }
before do before do
expect(token).to_not be_nil expect(token).to_not be_nil
put :regenerate, params: { application_id: app.id } post :regenerate, params: { id: app.id }
end end
it 'should create new token' do it 'should create new token' do