From e0dc73527a478188cfa28b456b64798639aa73c9 Mon Sep 17 00:00:00 2001 From: Jarka Kadlecova Date: Fri, 24 Mar 2017 11:11:36 +0100 Subject: Project deploy keys json end point --- app/controllers/projects/deploy_keys_controller.rb | 9 +++++++-- app/presenters/projects/settings/deploy_keys_presenter.rb | 11 +++++++++++ app/serializers/deploy_key_entity.rb | 12 ++++++++++++ app/serializers/deploy_key_serializer.rb | 3 +++ app/serializers/project_entity.rb | 12 ++++++++++++ 5 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 app/serializers/deploy_key_entity.rb create mode 100644 app/serializers/deploy_key_serializer.rb create mode 100644 app/serializers/project_entity.rb (limited to 'app') diff --git a/app/controllers/projects/deploy_keys_controller.rb b/app/controllers/projects/deploy_keys_controller.rb index d0c44e297e3..a47e15a192b 100644 --- a/app/controllers/projects/deploy_keys_controller.rb +++ b/app/controllers/projects/deploy_keys_controller.rb @@ -8,7 +8,12 @@ class Projects::DeployKeysController < Projects::ApplicationController layout "project_settings" def index - redirect_to_repository_settings(@project) + respond_to do |format| + format.html { redirect_to_repository_settings(@project) } + format.json do + render json: Projects::Settings::DeployKeysPresenter.new(@project, current_user: current_user).as_json + end + end end def new @@ -19,7 +24,7 @@ class Projects::DeployKeysController < Projects::ApplicationController @key = DeployKey.new(deploy_key_params.merge(user: current_user)) unless @key.valid? && @project.deploy_keys << @key - flash[:alert] = @key.errors.full_messages.join(', ').html_safe + flash[:alert] = @key.errors.full_messages.join(', ').html_safe end redirect_to_repository_settings(@project) end diff --git a/app/presenters/projects/settings/deploy_keys_presenter.rb b/app/presenters/projects/settings/deploy_keys_presenter.rb index 86ac513b3c0..070b0c35e36 100644 --- a/app/presenters/projects/settings/deploy_keys_presenter.rb +++ b/app/presenters/projects/settings/deploy_keys_presenter.rb @@ -48,6 +48,17 @@ module Projects available_public_keys.any? end + def as_json + serializer = DeployKeySerializer.new + opts = { user: current_user } + + { + enabled_keys: serializer.represent(enabled_keys, opts), + available_project_keys: serializer.represent(available_project_keys, opts), + public_keys: serializer.represent(available_public_keys, opts) + } + end + def to_partial_path 'projects/deploy_keys/index' end diff --git a/app/serializers/deploy_key_entity.rb b/app/serializers/deploy_key_entity.rb new file mode 100644 index 00000000000..cdedc2c7bd0 --- /dev/null +++ b/app/serializers/deploy_key_entity.rb @@ -0,0 +1,12 @@ +class DeployKeyEntity < Grape::Entity + expose :id + expose :user_id + expose :title + expose :fingerprint + expose :can_push + expose :created_at + expose :updated_at + expose :projects, using: ProjectEntity do |deploy_key| + deploy_key.projects.select { |project| options[:user].can?(:read_project, project) } + end +end diff --git a/app/serializers/deploy_key_serializer.rb b/app/serializers/deploy_key_serializer.rb new file mode 100644 index 00000000000..8f849eb88b7 --- /dev/null +++ b/app/serializers/deploy_key_serializer.rb @@ -0,0 +1,3 @@ +class DeployKeySerializer < BaseSerializer + entity DeployKeyEntity +end diff --git a/app/serializers/project_entity.rb b/app/serializers/project_entity.rb new file mode 100644 index 00000000000..6f8061f7530 --- /dev/null +++ b/app/serializers/project_entity.rb @@ -0,0 +1,12 @@ +class ProjectEntity < Grape::Entity + expose :id + expose :name + + expose :full_path do |project| + project.full_path + end + + expose :full_name do |project| + project.full_name + end +end -- cgit v1.2.3 From 703df2881bb137a79284baafe2cc12ff32ab9ff5 Mon Sep 17 00:00:00 2001 From: Jarka Kadlecova Date: Fri, 7 Apr 2017 13:34:39 +0200 Subject: expose additional values in deploy key entity --- app/serializers/deploy_key_entity.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'app') diff --git a/app/serializers/deploy_key_entity.rb b/app/serializers/deploy_key_entity.rb index cdedc2c7bd0..d75a83d0fa5 100644 --- a/app/serializers/deploy_key_entity.rb +++ b/app/serializers/deploy_key_entity.rb @@ -4,6 +4,8 @@ class DeployKeyEntity < Grape::Entity expose :title expose :fingerprint expose :can_push + expose :destroyed_when_orphaned?, as: :destroyed_when_orphaned + expose :almost_orphaned?, as: :almost_orphaned expose :created_at expose :updated_at expose :projects, using: ProjectEntity do |deploy_key| -- cgit v1.2.3 From bd86796dd0edae7e5db2bfbb887d3196498ebd49 Mon Sep 17 00:00:00 2001 From: Ruben Davila Date: Wed, 12 Apr 2017 23:23:02 -0500 Subject: Add support to change language in profile form --- app/controllers/profiles_controller.rb | 3 ++- app/views/profiles/show.html.haml | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb index 987b95e89b9..57e23cea00e 100644 --- a/app/controllers/profiles_controller.rb +++ b/app/controllers/profiles_controller.rb @@ -85,7 +85,8 @@ class ProfilesController < Profiles::ApplicationController :twitter, :username, :website_url, - :organization + :organization, + :preferred_language ) end end diff --git a/app/views/profiles/show.html.haml b/app/views/profiles/show.html.haml index c74b3249a13..dc71a04cbf0 100644 --- a/app/views/profiles/show.html.haml +++ b/app/views/profiles/show.html.haml @@ -72,6 +72,9 @@ = f.label :public_email, class: "label-light" = f.select :public_email, options_for_select(@user.all_emails, selected: @user.public_email), { include_blank: 'Do not show on profile' }, class: "select2" %span.help-block This email will be displayed on your public profile. + .form-group + = f.label :preferred_language, class: "label-light" + = f.select :preferred_language, Gitlab::I18n::AVAILABLE_LANGUAGES, {}, class: "select2" .form-group = f.label :skype, class: "label-light" = f.text_field :skype, class: "form-control" -- cgit v1.2.3 From 73d0730d09b5f9a9b68f158cc72ad30c7a2b35d0 Mon Sep 17 00:00:00 2001 From: Ruben Davila Date: Thu, 13 Apr 2017 01:03:47 -0500 Subject: Set locale through controller filter --- app/controllers/application_controller.rb | 6 ++++++ app/controllers/profiles_controller.rb | 1 + app/views/profiles/show.html.haml | 3 ++- 3 files changed, 9 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e77094fe2a8..5a3bd4040cc 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -265,4 +265,10 @@ class ApplicationController < ActionController::Base def u2f_app_id request.base_url end + + def set_locale + requested_locale = current_user&.preferred_language || request.env['HTTP_ACCEPT_LANGUAGE'] || I18n.default_locale + locale = FastGettext.set_locale(requested_locale) + I18n.locale = locale + end end diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb index 57e23cea00e..0f01bf7e706 100644 --- a/app/controllers/profiles_controller.rb +++ b/app/controllers/profiles_controller.rb @@ -3,6 +3,7 @@ class ProfilesController < Profiles::ApplicationController before_action :user before_action :authorize_change_username!, only: :update_username + before_action :set_locale, only: :show skip_before_action :require_email, only: [:show, :update] def show diff --git a/app/views/profiles/show.html.haml b/app/views/profiles/show.html.haml index dc71a04cbf0..d8ef64ceb72 100644 --- a/app/views/profiles/show.html.haml +++ b/app/views/profiles/show.html.haml @@ -74,7 +74,8 @@ %span.help-block This email will be displayed on your public profile. .form-group = f.label :preferred_language, class: "label-light" - = f.select :preferred_language, Gitlab::I18n::AVAILABLE_LANGUAGES, {}, class: "select2" + = f.select :preferred_language, Gitlab::I18n::AVAILABLE_LANGUAGES.map { |lang| [_(lang[0]), lang[1]] }, + {}, class: "select2" .form-group = f.label :skype, class: "label-light" = f.text_field :skype, class: "form-control" -- cgit v1.2.3 From 90ba69d224eb7ef3d91332f1b7944c68ad16affd Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Sat, 15 Apr 2017 16:07:31 +0100 Subject: Started internationalising cycyle analytics --- app/assets/javascripts/locale/de/app.js | 1 + app/assets/javascripts/locale/en/app.js | 1 + app/assets/javascripts/locale/es/app.js | 1 + app/assets/javascripts/locale/index.js | 15 +++++++++++++++ app/views/layouts/_head.html.haml | 1 + app/views/layouts/application.html.haml | 2 +- 6 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 app/assets/javascripts/locale/de/app.js create mode 100644 app/assets/javascripts/locale/en/app.js create mode 100644 app/assets/javascripts/locale/es/app.js create mode 100644 app/assets/javascripts/locale/index.js (limited to 'app') diff --git a/app/assets/javascripts/locale/de/app.js b/app/assets/javascripts/locale/de/app.js new file mode 100644 index 00000000000..643e82a90a0 --- /dev/null +++ b/app/assets/javascripts/locale/de/app.js @@ -0,0 +1 @@ +var locales = locales || {}; locales['de'] = {"domain":"app","locale_data":{"app":{"":{"Project-Id-Version":"gitlab 1.0.0","Report-Msgid-Bugs-To":"","PO-Revision-Date":"2017-04-12 22:37-0500","Last-Translator":"FULL NAME ","Language-Team":"German","Language":"de","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Plural-Forms":"nplurals=2; plural=n != 1;","lang":"de","domain":"app","plural_forms":"nplurals=2; plural=n != 1;"},"Deutsch":[""],"English":[""],"Spanish":[""]}}}; \ No newline at end of file diff --git a/app/assets/javascripts/locale/en/app.js b/app/assets/javascripts/locale/en/app.js new file mode 100644 index 00000000000..9070b519ff3 --- /dev/null +++ b/app/assets/javascripts/locale/en/app.js @@ -0,0 +1 @@ +var locales = locales || {}; locales['en'] = {"domain":"app","locale_data":{"app":{"":{"Project-Id-Version":"gitlab 1.0.0","Report-Msgid-Bugs-To":"","PO-Revision-Date":"2017-04-12 22:36-0500","Last-Translator":"FULL NAME ","Language-Team":"English","Language":"en","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Plural-Forms":"nplurals=2; plural=n != 1;","lang":"en","domain":"app","plural_forms":"nplurals=2; plural=n != 1;"},"Deutsch":[""],"English":[""],"Spanish":[""]}}}; diff --git a/app/assets/javascripts/locale/es/app.js b/app/assets/javascripts/locale/es/app.js new file mode 100644 index 00000000000..41f6ddef5b8 --- /dev/null +++ b/app/assets/javascripts/locale/es/app.js @@ -0,0 +1 @@ +var locales = locales || {}; locales['es'] = {"domain":"app","locale_data":{"app":{"":{"Project-Id-Version":"gitlab 1.0.0","Report-Msgid-Bugs-To":"","PO-Revision-Date":"2017-04-13 00:07-0500","Language-Team":"Spanish","Language":"es","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Plural-Forms":"nplurals=2; plural=n != 1;","Last-Translator":"","X-Generator":"Poedit 2.0.1","lang":"es","domain":"app","plural_forms":"nplurals=2; plural=n != 1;"},"Deutsch":["Alemán"],"English":["Inglés"],"Spanish":["Español"]}}}; diff --git a/app/assets/javascripts/locale/index.js b/app/assets/javascripts/locale/index.js new file mode 100644 index 00000000000..0feb9eb5d43 --- /dev/null +++ b/app/assets/javascripts/locale/index.js @@ -0,0 +1,15 @@ +import Jed from 'jed'; +import de from './de/app'; +import es from './es/app'; +import en from './en/app'; + +const locales = { + de, + es, + en, +}; + +const lang = document.querySelector('html').getAttribute('lang'); + +export { lang }; +export default new Jed(locales[lang]); diff --git a/app/views/layouts/_head.html.haml b/app/views/layouts/_head.html.haml index 19473b6ab27..7e198679489 100644 --- a/app/views/layouts/_head.html.haml +++ b/app/views/layouts/_head.html.haml @@ -31,6 +31,7 @@ = webpack_bundle_tag "runtime" = webpack_bundle_tag "common" = webpack_bundle_tag "main" + = webpack_bundle_tag "locale" - if content_for?(:page_specific_javascripts) = yield :page_specific_javascripts diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 36543edc040..dc926a615c7 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -1,5 +1,5 @@ !!! 5 -%html{ lang: "en", class: "#{page_class}" } +%html{ lang: I18n.locale, class: "#{page_class}" } = render "layouts/head" %body{ class: @body_class, data: { page: body_data_page, project: "#{@project.path if @project}", group: "#{@group.path if @group}" } } = Gon::Base.render_data -- cgit v1.2.3 From 7963c2c25114e871eb42c0859b6d24fc37437a8a Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Tue, 18 Apr 2017 14:55:09 +0100 Subject: Added Vue filters & directives for translating --- .../components/limit_warning_component.js | 2 +- .../components/stage_code_component.js | 4 ++-- .../components/stage_issue_component.js | 4 ++-- .../components/stage_plan_component.js | 4 ++-- .../components/stage_production_component.js | 4 ++-- .../components/stage_review_component.js | 4 ++-- .../components/stage_staging_component.js | 2 +- .../components/total_time_component.js | 6 +++--- .../cycle_analytics/cycle_analytics_bundle.js | 3 +++ .../cycle_analytics/cycle_analytics_store.js | 16 +++++++++------- app/assets/javascripts/vue_shared/translate.js | 14 ++++++++++++++ .../cycle_analytics/_empty_stage.html.haml | 2 +- .../projects/cycle_analytics/_no_access.html.haml | 4 ++-- app/views/projects/cycle_analytics/show.html.haml | 22 +++++++++++----------- 14 files changed, 55 insertions(+), 36 deletions(-) create mode 100644 app/assets/javascripts/vue_shared/translate.js (limited to 'app') diff --git a/app/assets/javascripts/cycle_analytics/components/limit_warning_component.js b/app/assets/javascripts/cycle_analytics/components/limit_warning_component.js index abe48572347..a7b187a0a36 100644 --- a/app/assets/javascripts/cycle_analytics/components/limit_warning_component.js +++ b/app/assets/javascripts/cycle_analytics/components/limit_warning_component.js @@ -11,7 +11,7 @@ export default { aria-hidden="true" title="Limited to showing 50 events at most" data-placement="top"> - Showing 50 events + {{ 'Showing 50 events' | translate }} `, }; diff --git a/app/assets/javascripts/cycle_analytics/components/stage_code_component.js b/app/assets/javascripts/cycle_analytics/components/stage_code_component.js index 80bd2df6f42..f72882872cd 100644 --- a/app/assets/javascripts/cycle_analytics/components/stage_code_component.js +++ b/app/assets/javascripts/cycle_analytics/components/stage_code_component.js @@ -28,11 +28,11 @@ global.cycleAnalytics.StageCodeComponent = Vue.extend({ !{{ mergeRequest.iid }} · - Opened + {{ 'Opened' | translate }} {{ mergeRequest.createdAt }} - by + {{ 'by' | translate }} {{ mergeRequest.author.name }} diff --git a/app/assets/javascripts/cycle_analytics/components/stage_issue_component.js b/app/assets/javascripts/cycle_analytics/components/stage_issue_component.js index 20a43798fbe..bb265c8316f 100644 --- a/app/assets/javascripts/cycle_analytics/components/stage_issue_component.js +++ b/app/assets/javascripts/cycle_analytics/components/stage_issue_component.js @@ -28,11 +28,11 @@ global.cycleAnalytics.StageIssueComponent = Vue.extend({ #{{ issue.iid }} · - Opened + {{ 'Opened' | translate }} {{ issue.createdAt }} - by + {{ 'by' | translate }} {{ issue.author.name }} diff --git a/app/assets/javascripts/cycle_analytics/components/stage_plan_component.js b/app/assets/javascripts/cycle_analytics/components/stage_plan_component.js index f33cac3da82..32b685faece 100644 --- a/app/assets/javascripts/cycle_analytics/components/stage_plan_component.js +++ b/app/assets/javascripts/cycle_analytics/components/stage_plan_component.js @@ -31,10 +31,10 @@ global.cycleAnalytics.StagePlanComponent = Vue.extend({ - First + {{ 'First' | translate }} ${iconCommit} {{ commit.shortSha }} - pushed by + {{ 'pushed by' | translate }} {{ commit.author.name }} diff --git a/app/assets/javascripts/cycle_analytics/components/stage_production_component.js b/app/assets/javascripts/cycle_analytics/components/stage_production_component.js index 657f5385374..5c9186a2e49 100644 --- a/app/assets/javascripts/cycle_analytics/components/stage_production_component.js +++ b/app/assets/javascripts/cycle_analytics/components/stage_production_component.js @@ -28,11 +28,11 @@ global.cycleAnalytics.StageProductionComponent = Vue.extend({ #{{ issue.iid }} · - Opened + {{ 'Opened' | translate }} {{ issue.createdAt }} - by + {{ 'by' | translate }} {{ issue.author.name }} diff --git a/app/assets/javascripts/cycle_analytics/components/stage_review_component.js b/app/assets/javascripts/cycle_analytics/components/stage_review_component.js index 8a801300647..a047573548d 100644 --- a/app/assets/javascripts/cycle_analytics/components/stage_review_component.js +++ b/app/assets/javascripts/cycle_analytics/components/stage_review_component.js @@ -28,11 +28,11 @@ global.cycleAnalytics.StageReviewComponent = Vue.extend({ !{{ mergeRequest.iid }} · - Opened + {{ 'Opened' | translate }} {{ mergeRequest.createdAt }} - by + {{ 'by' | translate }} {{ mergeRequest.author.name }}