From b8c178cef0b2a8f514932d6293838581b0fccd20 Mon Sep 17 00:00:00 2001 From: Tim Zallmann Date: Mon, 17 Jul 2017 11:58:04 +0200 Subject: [PATCH 01/26] Google Analytics Script set to Ignore --- app/views/layouts/_google_analytics.html.haml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/layouts/_google_analytics.html.haml b/app/views/layouts/_google_analytics.html.haml index 81e03c7eff29..98ea96b0b776 100644 --- a/app/views/layouts/_google_analytics.html.haml +++ b/app/views/layouts/_google_analytics.html.haml @@ -1,3 +1,4 @@ +-# haml-lint:disable InlineJavaScript :javascript var _gaq = _gaq || []; _gaq.push(['_setAccount', '#{extra_config.google_analytics_id}']); -- GitLab From b0c48adb3a85eeb4d6c012c30ad30491c966a38b Mon Sep 17 00:00:00 2001 From: Tim Zallmann Date: Mon, 17 Jul 2017 17:15:29 +0200 Subject: [PATCH 02/26] Moved + Refactored Code from the UI Development Kit Page --- app/assets/javascripts/ui_development_kit.js | 22 +++++++++++++++++ app/views/help/ui.html.haml | 25 ++------------------ config/webpack.config.js | 2 ++ 3 files changed, 26 insertions(+), 23 deletions(-) create mode 100644 app/assets/javascripts/ui_development_kit.js diff --git a/app/assets/javascripts/ui_development_kit.js b/app/assets/javascripts/ui_development_kit.js new file mode 100644 index 000000000000..f503076715cf --- /dev/null +++ b/app/assets/javascripts/ui_development_kit.js @@ -0,0 +1,22 @@ +import Api from './api'; + +document.addEventListener('DOMContentLoaded', () => { + $('#js-project-dropdown').glDropdown({ + data: (term, callback) => { + Api.projects(term, { + order_by: 'last_activity_at', + }, (data) => { + callback(data); + }); + }, + text: project => (project.name_with_namespace || project.name), + selectable: true, + fieldName: 'author_id', + filterable: true, + search: { + fields: ['name_with_namespace'], + }, + id: data => data.id, + isSelected: data => (data.id === 2), + }); +}); diff --git a/app/views/help/ui.html.haml b/app/views/help/ui.html.haml index 48edbb8c16f9..f18c3a741200 100644 --- a/app/views/help/ui.html.haml +++ b/app/views/help/ui.html.haml @@ -1,5 +1,7 @@ - page_title "UI Development Kit", "Help" - lorem = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed fermentum nisi sapien, non consequat lectus aliquam ultrices. Suspendisse sodales est euismod nunc condimentum, a consectetur diam ornare." +- content_for :page_specific_javascripts do + = webpack_bundle_tag('ui_development_kit') .gitlab-ui-dev-kit %h1 GitLab UI development kit @@ -407,29 +409,6 @@ .dropdown-content .dropdown-loading = icon('spinner spin') - :javascript - $('#js-project-dropdown').glDropdown({ - data: function (term, callback) { - Api.projects(term, { order_by: 'last_activity_at' }, function (data) { - callback(data); - }); - }, - text: function (project) { - return project.name_with_namespace || project.name; - }, - selectable: true, - fieldName: "author_id", - filterable: true, - search: { - fields: ['name_with_namespace'] - }, - id: function (data) { - return data.id; - }, - isSelected: function (data) { - return data.id === 2; - } - }) .example %div diff --git a/config/webpack.config.js b/config/webpack.config.js index 2f85b89d5231..be7eead7c671 100644 --- a/config/webpack.config.js +++ b/config/webpack.config.js @@ -70,6 +70,8 @@ var config = { stl_viewer: './blob/stl_viewer.js', terminal: './terminal/terminal_bundle.js', u2f: ['vendor/u2f'], + ui_development_kit: './ui_development_kit.js', + users: './users/index.js', raven: './raven/index.js', vue_merge_request_widget: './vue_merge_request_widget/index.js', test: './test.js', -- GitLab From 634cbf8e83dce0732ceb02a33398c4a99a1f0b9c Mon Sep 17 00:00:00 2001 From: Tim Zallmann Date: Mon, 17 Jul 2017 17:26:21 +0200 Subject: [PATCH 03/26] Set Piwik to Ignore for Eslint Inline JS --- app/views/layouts/_piwik.html.haml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/layouts/_piwik.html.haml b/app/views/layouts/_piwik.html.haml index 259b4f7cdfc7..a888e8ae1878 100644 --- a/app/views/layouts/_piwik.html.haml +++ b/app/views/layouts/_piwik.html.haml @@ -1,4 +1,5 @@ +-# haml-lint:disable InlineJavaScript :javascript var _paq = _paq || []; _paq.push(['trackPageView']); -- GitLab From e6cbb1e14f9cc4d2cf8086185126b49f3c076b16 Mon Sep 17 00:00:00 2001 From: Tim Zallmann Date: Mon, 17 Jul 2017 18:21:32 +0200 Subject: [PATCH 04/26] Moved JS from the personal Access Token page to own JS File --- app/assets/javascripts/profile/personal_access_tokens.js | 8 ++++++++ app/views/profiles/personal_access_tokens/index.html.haml | 8 +++----- config/webpack.config.js | 1 + 3 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 app/assets/javascripts/profile/personal_access_tokens.js diff --git a/app/assets/javascripts/profile/personal_access_tokens.js b/app/assets/javascripts/profile/personal_access_tokens.js new file mode 100644 index 000000000000..0a6d601d3534 --- /dev/null +++ b/app/assets/javascripts/profile/personal_access_tokens.js @@ -0,0 +1,8 @@ +document.addEventListener('DOMContentLoaded', () => { + const createdTokenInput = document.getElementById('created-personal-access-token'); + if (createdTokenInput) { + createdTokenInput.addEventListener('click', () => { + createdTokenInput.select(); + }); + } +}); diff --git a/app/views/profiles/personal_access_tokens/index.html.haml b/app/views/profiles/personal_access_tokens/index.html.haml index cf750378e257..fcf53ab87edd 100644 --- a/app/views/profiles/personal_access_tokens/index.html.haml +++ b/app/views/profiles/personal_access_tokens/index.html.haml @@ -1,5 +1,8 @@ - page_title "Personal Access Tokens" - @content_class = "limit-container-width" unless fluid_layout +- content_for :page_specific_javascripts do + = webpack_bundle_tag('personal_access_tokens') + = render 'profiles/head' .row.prepend-top-default @@ -28,8 +31,3 @@ = render "shared/personal_access_tokens_form", path: profile_personal_access_tokens_path, impersonation: false, token: @personal_access_token, scopes: @scopes = render "shared/personal_access_tokens_table", impersonation: false, active_tokens: @active_personal_access_tokens, inactive_tokens: @inactive_personal_access_tokens - -:javascript - $("#created-personal-access-token").click(function() { - this.select(); - }); diff --git a/config/webpack.config.js b/config/webpack.config.js index be7eead7c671..9c20fe4dff9e 100644 --- a/config/webpack.config.js +++ b/config/webpack.config.js @@ -53,6 +53,7 @@ var config = { network: './network/network_bundle.js', notebook_viewer: './blob/notebook_viewer.js', pdf_viewer: './blob/pdf_viewer.js', + personal_access_tokens:'./profile/personal_access_tokens.js', pipelines: './pipelines/pipelines_bundle.js', pipelines_charts: './pipelines/pipelines_charts.js', pipelines_details: './pipelines/pipeline_details_bundle.js', -- GitLab From fc44fee0733cb80a0d31044bbcb5d2236066843f Mon Sep 17 00:00:00 2001 From: Tim Zallmann Date: Wed, 19 Jul 2017 12:24:04 +0200 Subject: [PATCH 05/26] Moved 2 Factor Authentication Inline Script Added data attributes Refactored to Vanilla JS --- app/assets/javascripts/two_factor_auth.js | 8 + .../profiles/two_factor_auths/show.html.haml | 163 +++++++++--------- config/webpack.config.js | 1 + 3 files changed, 88 insertions(+), 84 deletions(-) create mode 100644 app/assets/javascripts/two_factor_auth.js diff --git a/app/assets/javascripts/two_factor_auth.js b/app/assets/javascripts/two_factor_auth.js new file mode 100644 index 000000000000..852b32c28036 --- /dev/null +++ b/app/assets/javascripts/two_factor_auth.js @@ -0,0 +1,8 @@ +document.addEventListener('DOMContentLoaded', () => { + const skippable = document.querySelector('.js-two-factor-auth').dataset.two_factor_skippable === 'true'; + if (skippable) { + const button = "Configure it later"; + const flashAlert = document.querySelector('.flash-alert'); + if (flashAlert) flashAlert.insertAdjacentHTML('beforeend', button); + } +}); diff --git a/app/views/profiles/two_factor_auths/show.html.haml b/app/views/profiles/two_factor_auths/show.html.haml index 037cb30efb98..783bc4d2a306 100644 --- a/app/views/profiles/two_factor_auths/show.html.haml +++ b/app/views/profiles/two_factor_auths/show.html.haml @@ -7,97 +7,92 @@ = render 'profiles/head' -- if inject_u2f_api? - - content_for :page_specific_javascripts do +- content_for :page_specific_javascripts do + = page_specific_javascript_bundle_tag('two_factor_auth') + - if inject_u2f_api? = page_specific_javascript_bundle_tag('u2f') -.row.prepend-top-default - .col-lg-4 - %h4.prepend-top-0 - Register Two-Factor Authentication App - %p - Use an app on your mobile device to enable two-factor authentication (2FA). - .col-lg-8 - - if current_user.two_factor_otp_enabled? - = icon "check inverse", base: "circle", class: "text-success", text: "You've already enabled two-factor authentication using mobile authenticator applications. You can disable it from your account settings page." - - else +.js-two-factor-auth{ 'data-two_factor_skippable' => two_factor_skippable? } + .row.prepend-top-default + .col-lg-4 + %h4.prepend-top-0 + Register Two-Factor Authentication App %p - Download the Google Authenticator application from App Store or Google Play Store and scan this code. - More information is available in the #{link_to('documentation', help_page_path('profile/two_factor_authentication'))}. - .row.append-bottom-10 - .col-md-4 - = raw @qr_code - .col-md-8 - .account-well - %p.prepend-top-0.append-bottom-0 - Can't scan the code? - %p.prepend-top-0.append-bottom-0 - To add the entry manually, provide the following details to the application on your phone. - %p.prepend-top-0.append-bottom-0 - Account: - = @account_string - %p.prepend-top-0.append-bottom-0 - Key: - = current_user.otp_secret.scan(/.{4}/).join(' ') - %p.two-factor-new-manual-content - Time based: Yes - = form_tag profile_two_factor_auth_path, method: :post do |f| - - if @error - .alert.alert-danger - = @error - .form-group - = label_tag :pin_code, nil, class: "label-light" - = text_field_tag :pin_code, nil, class: "form-control", required: true - .prepend-top-default - = submit_tag 'Register with two-factor app', class: 'btn btn-success' + Use an app on your mobile device to enable two-factor authentication (2FA). + .col-lg-8 + - if current_user.two_factor_otp_enabled? + = icon "check inverse", base: "circle", class: "text-success", text: "You've already enabled two-factor authentication using mobile authenticator applications. You can disable it from your account settings page." + - else + %p + Download the Google Authenticator application from App Store or Google Play Store and scan this code. + More information is available in the #{link_to('documentation', help_page_path('profile/two_factor_authentication'))}. + .row.append-bottom-10 + .col-md-4 + = raw @qr_code + .col-md-8 + .account-well + %p.prepend-top-0.append-bottom-0 + Can't scan the code? + %p.prepend-top-0.append-bottom-0 + To add the entry manually, provide the following details to the application on your phone. + %p.prepend-top-0.append-bottom-0 + Account: + = @account_string + %p.prepend-top-0.append-bottom-0 + Key: + = current_user.otp_secret.scan(/.{4}/).join(' ') + %p.two-factor-new-manual-content + Time based: Yes + = form_tag profile_two_factor_auth_path, method: :post do |f| + - if @error + .alert.alert-danger + = @error + .form-group + = label_tag :pin_code, nil, class: "label-light" + = text_field_tag :pin_code, nil, class: "form-control", required: true + .prepend-top-default + = submit_tag 'Register with two-factor app', class: 'btn btn-success' -%hr + %hr -.row.prepend-top-default - - .col-lg-4 - %h4.prepend-top-0 - Register Universal Two-Factor (U2F) Device - %p - Use a hardware device to add the second factor of authentication. - %p - As U2F devices are only supported by a few browsers, we require that you set up a - two-factor authentication app before a U2F device. That way you'll always be able to - log in - even when you're using an unsupported browser. - .col-lg-8 - - if @u2f_registration.errors.present? - = form_errors(@u2f_registration) - = render "u2f/register" + .row.prepend-top-default + .col-lg-4 + %h4.prepend-top-0 + Register Universal Two-Factor (U2F) Device + %p + Use a hardware device to add the second factor of authentication. + %p + As U2F devices are only supported by a few browsers, we require that you set up a + two-factor authentication app before a U2F device. That way you'll always be able to + log in - even when you're using an unsupported browser. + .col-lg-8 + - if @u2f_registration.errors.present? + = form_errors(@u2f_registration) + = render "u2f/register" - %hr + %hr - %h5 U2F Devices (#{@u2f_registrations.length}) + %h5 U2F Devices (#{@u2f_registrations.length}) - - if @u2f_registrations.present? - .table-responsive - %table.table.table-bordered.u2f-registrations - %colgroup - %col{ width: "50%" } - %col{ width: "30%" } - %col{ width: "20%" } - %thead - %tr - %th Name - %th Registered On - %th - %tbody - - @u2f_registrations.each do |registration| + - if @u2f_registrations.present? + .table-responsive + %table.table.table-bordered.u2f-registrations + %colgroup + %col{ width: "50%" } + %col{ width: "30%" } + %col{ width: "20%" } + %thead %tr - %td= registration.name.presence || "" - %td= registration.created_at.to_date.to_s(:medium) - %td= link_to "Delete", profile_u2f_registration_path(registration), method: :delete, class: "btn btn-danger pull-right", data: { confirm: "Are you sure you want to delete this device? This action cannot be undone." } - - - else - .settings-message.text-center - You don't have any U2F devices registered yet. - + %th Name + %th Registered On + %th + %tbody + - @u2f_registrations.each do |registration| + %tr + %td= registration.name.presence || "" + %td= registration.created_at.to_date.to_s(:medium) + %td= link_to "Delete", profile_u2f_registration_path(registration), method: :delete, class: "btn btn-danger pull-right", data: { confirm: "Are you sure you want to delete this device? This action cannot be undone." } -- if two_factor_skippable? - :javascript - var button = "Configure it later"; - $(".flash-alert").append(button); + - else + .settings-message.text-center + You don't have any U2F devices registered yet. diff --git a/config/webpack.config.js b/config/webpack.config.js index 9c20fe4dff9e..e9986dabd4db 100644 --- a/config/webpack.config.js +++ b/config/webpack.config.js @@ -76,6 +76,7 @@ var config = { raven: './raven/index.js', vue_merge_request_widget: './vue_merge_request_widget/index.js', test: './test.js', + two_factor_auth: './two_factor_auth.js', performance_bar: './performance_bar.js', webpack_runtime: './webpack.js', }, -- GitLab From e95f77419c8c73ed03b4a653e0556dd0ac895db5 Mon Sep 17 00:00:00 2001 From: Tim Zallmann Date: Wed, 19 Jul 2017 12:33:19 +0200 Subject: [PATCH 06/26] Moved Inline JS from u2f register --- app/assets/javascripts/two_factor_auth.js | 4 ++++ app/views/u2f/_register.html.haml | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/two_factor_auth.js b/app/assets/javascripts/two_factor_auth.js index 852b32c28036..d3c23d0276ba 100644 --- a/app/assets/javascripts/two_factor_auth.js +++ b/app/assets/javascripts/two_factor_auth.js @@ -1,3 +1,4 @@ +/* global U2FRegister */ document.addEventListener('DOMContentLoaded', () => { const skippable = document.querySelector('.js-two-factor-auth').dataset.two_factor_skippable === 'true'; if (skippable) { @@ -5,4 +6,7 @@ document.addEventListener('DOMContentLoaded', () => { const flashAlert = document.querySelector('.flash-alert'); if (flashAlert) flashAlert.insertAdjacentHTML('beforeend', button); } + + const u2fRegister = new U2FRegister($('#js-register-u2f'), gon.u2f); + u2fRegister.start(); }); diff --git a/app/views/u2f/_register.html.haml b/app/views/u2f/_register.html.haml index 00788e77b6b7..093b2d828135 100644 --- a/app/views/u2f/_register.html.haml +++ b/app/views/u2f/_register.html.haml @@ -37,7 +37,3 @@ .col-md-3 = hidden_field_tag 'u2f_registration[device_response]', nil, class: 'form-control', required: true, id: "js-device-response" = submit_tag "Register U2F device", class: "btn btn-success" - -:javascript - var u2fRegister = new U2FRegister($("#js-register-u2f"), gon.u2f); - u2fRegister.start(); -- GitLab From c10ed8f7ca0a63868a51f33311891dbaead530eb Mon Sep 17 00:00:00 2001 From: Tim Zallmann Date: Wed, 19 Jul 2017 13:08:42 +0200 Subject: [PATCH 07/26] Moved inline Script from project activities page --- app/assets/javascripts/dispatcher.js | 1 + app/views/projects/_activity.html.haml | 6 ------ 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/app/assets/javascripts/dispatcher.js b/app/assets/javascripts/dispatcher.js index d5923266c60b..42aa2bdb0a18 100644 --- a/app/assets/javascripts/dispatcher.js +++ b/app/assets/javascripts/dispatcher.js @@ -316,6 +316,7 @@ import GpgBadges from './gpg_badges'; GpgBadges.fetch(); break; case 'projects:activity': + new gl.Activities(); shortcut_handler = new ShortcutsNavigation(); break; case 'projects:show': diff --git a/app/views/projects/_activity.html.haml b/app/views/projects/_activity.html.haml index ecc966ed4534..ad63f5e73aeb 100644 --- a/app/views/projects/_activity.html.haml +++ b/app/views/projects/_activity.html.haml @@ -8,9 +8,3 @@ .content_list.project-activity{ :"data-href" => activity_project_path(@project) } = spinner - -:javascript - var activity = new gl.Activities(); - $(document).on('page:restore', function (event) { - activity.reloadActivities() - }) -- GitLab From 0a0e9566126d2585f5d03cf9473e3fd86a3f9904 Mon Sep 17 00:00:00 2001 From: Tim Zallmann Date: Wed, 19 Jul 2017 13:25:49 +0200 Subject: [PATCH 08/26] Moved functionality of blob modals (new directory + delete) to appropriate places --- app/assets/javascripts/blob_edit/blob_bundle.js | 5 +++++ app/assets/javascripts/dispatcher.js | 2 ++ app/views/projects/blob/_new_dir.html.haml | 3 --- app/views/projects/blob/_remove.html.haml | 3 --- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/blob_edit/blob_bundle.js b/app/assets/javascripts/blob_edit/blob_bundle.js index 1c64ccf536f7..b5500ac116f7 100644 --- a/app/assets/javascripts/blob_edit/blob_bundle.js +++ b/app/assets/javascripts/blob_edit/blob_bundle.js @@ -8,6 +8,7 @@ import BlobFileDropzone from '../blob/blob_file_dropzone'; $(() => { const editBlobForm = $('.js-edit-blob-form'); const uploadBlobForm = $('.js-upload-blob-form'); + const deleteBlobForm = $('.js-delete-blob-form'); if (editBlobForm.length) { const urlRoot = editBlobForm.data('relative-url-root'); @@ -30,4 +31,8 @@ $(() => { '.btn-upload-file', ); } + + if (deleteBlobForm.length) { + new NewCommitForm(deleteBlobForm); + } }); diff --git a/app/assets/javascripts/dispatcher.js b/app/assets/javascripts/dispatcher.js index 42aa2bdb0a18..cce94abfeb48 100644 --- a/app/assets/javascripts/dispatcher.js +++ b/app/assets/javascripts/dispatcher.js @@ -19,6 +19,7 @@ /* global Search */ /* global Admin */ /* global NamespaceSelects */ +/* global NewCommitForm */ /* global Project */ /* global ProjectAvatar */ /* global MergeRequest */ @@ -388,6 +389,7 @@ import GpgBadges from './gpg_badges'; shortcut_handler = new ShortcutsNavigation(); new TreeView(); new BlobViewer(); + new NewCommitForm($('.js-create-dir-form')); $('#tree-slider').waitForImages(function() { gl.utils.ajaxGet(document.querySelector('.js-tree-content').dataset.logsPath); }); diff --git a/app/views/projects/blob/_new_dir.html.haml b/app/views/projects/blob/_new_dir.html.haml index b2959ef6d31f..03ab1bb59e45 100644 --- a/app/views/projects/blob/_new_dir.html.haml +++ b/app/views/projects/blob/_new_dir.html.haml @@ -20,6 +20,3 @@ - unless can?(current_user, :push_code, @project) .inline.prepend-left-10 = commit_in_fork_help - -:javascript - new NewCommitForm($('.js-create-dir-form')) diff --git a/app/views/projects/blob/_remove.html.haml b/app/views/projects/blob/_remove.html.haml index 6a4a657fa8ca..750bdef3308c 100644 --- a/app/views/projects/blob/_remove.html.haml +++ b/app/views/projects/blob/_remove.html.haml @@ -13,6 +13,3 @@ .col-sm-offset-2.col-sm-10 = button_tag 'Delete file', class: 'btn btn-remove btn-remove-file' = link_to "Cancel", '#', class: "btn btn-cancel", "data-dismiss" => "modal" - -:javascript - new NewCommitForm($('.js-delete-blob-form')) -- GitLab From 8129acb77bd61ccb1769c2bda38c3f662cf9ba87 Mon Sep 17 00:00:00 2001 From: Tim Zallmann Date: Wed, 19 Jul 2017 13:44:45 +0200 Subject: [PATCH 09/26] Moved New Branch Inline JS to dispatcher / left array init --- app/assets/javascripts/dispatcher.js | 4 ++++ app/views/projects/branches/new.html.haml | 7 +++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/dispatcher.js b/app/assets/javascripts/dispatcher.js index cce94abfeb48..8c02ce36022b 100644 --- a/app/assets/javascripts/dispatcher.js +++ b/app/assets/javascripts/dispatcher.js @@ -20,6 +20,7 @@ /* global Admin */ /* global NamespaceSelects */ /* global NewCommitForm */ +/* global NewBranchForm */ /* global Project */ /* global ProjectAvatar */ /* global MergeRequest */ @@ -219,6 +220,9 @@ import GpgBadges from './gpg_badges'; case 'projects:compare:show': new gl.Diff(); break; + case 'projects:branches:new': + new NewBranchForm($('.js-create-branch-form'), window.gl.availableRefs); + break; case 'projects:branches:index': gl.AjaxLoadingSpinner.init(); new DeleteModal(); diff --git a/app/views/projects/branches/new.html.haml b/app/views/projects/branches/new.html.haml index 03eefcc2b4de..16d7727d2b7a 100644 --- a/app/views/projects/branches/new.html.haml +++ b/app/views/projects/branches/new.html.haml @@ -28,8 +28,7 @@ .form-actions = button_tag 'Create branch', class: 'btn btn-create', tabindex: 3 = link_to 'Cancel', project_branches_path(@project), class: 'btn btn-cancel' - +-# haml-lint:disable InlineJavaScript :javascript - var availableRefs = #{@project.repository.ref_names.to_json}; - - new NewBranchForm($('.js-create-branch-form'), availableRefs) + window.gl = window.gl || { }; + window.gl.availableRefs = #{@project.repository.ref_names.to_json}; -- GitLab From 0e0a4b749a807a0b932a89165923b99819be2839 Mon Sep 17 00:00:00 2001 From: Tim Zallmann Date: Wed, 19 Jul 2017 20:02:58 +0200 Subject: [PATCH 10/26] Moved Commit Box Loading call to own file from inline script --- app/assets/javascripts/commit/commit_box.js | 4 ++++ app/views/projects/commit/_commit_box.html.haml | 8 ++++---- config/webpack.config.js | 1 + 3 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 app/assets/javascripts/commit/commit_box.js diff --git a/app/assets/javascripts/commit/commit_box.js b/app/assets/javascripts/commit/commit_box.js new file mode 100644 index 000000000000..20f29df4d281 --- /dev/null +++ b/app/assets/javascripts/commit/commit_box.js @@ -0,0 +1,4 @@ +/* global U2FRegister */ +document.addEventListener('DOMContentLoaded', () => { + $('.commit-info.branches').load(document.querySelector('.js-commit-box').dataset.commit_path); +}); diff --git a/app/views/projects/commit/_commit_box.html.haml b/app/views/projects/commit/_commit_box.html.haml index 419fbe99af83..0d8bce5548fd 100644 --- a/app/views/projects/commit/_commit_box.html.haml +++ b/app/views/projects/commit/_commit_box.html.haml @@ -1,4 +1,7 @@ -.page-content-header +- content_for :page_specific_javascripts do + = webpack_bundle_tag('commit_box') + +.page-content-header.js-commit-box{ 'data-commit_path' => branches_project_commit_path(@project, @commit.id) } .header-main-content = render partial: 'signature', object: @commit.signature %strong @@ -79,6 +82,3 @@ = render 'shared/mini_pipeline_graph', pipeline: last_pipeline, klass: 'js-commit-pipeline-graph' in = time_interval_in_words last_pipeline.duration - -:javascript - $(".commit-info.branches").load("#{branches_project_commit_path(@project, @commit.id)}"); diff --git a/config/webpack.config.js b/config/webpack.config.js index e9986dabd4db..84d31553efc0 100644 --- a/config/webpack.config.js +++ b/config/webpack.config.js @@ -33,6 +33,7 @@ var config = { common_d3: ['d3'], cycle_analytics: './cycle_analytics/cycle_analytics_bundle.js', commit_pipelines: './commit/pipelines/pipelines_bundle.js', + commit_box: './commit/commit_box.js', deploy_keys: './deploy_keys/index.js', diff_notes: './diff_notes/diff_notes_bundle.js', environments: './environments/environments_bundle.js', -- GitLab From 635cdc1f4b13067662fb0b98535498bfb88dbd3f Mon Sep 17 00:00:00 2001 From: Tim Zallmann Date: Wed, 19 Jul 2017 20:16:05 +0200 Subject: [PATCH 11/26] Moved the Commits List inline JS to external File --- app/assets/javascripts/dispatcher.js | 4 ++ app/views/projects/commits/show.html.haml | 52 +++++++++++------------ 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/app/assets/javascripts/dispatcher.js b/app/assets/javascripts/dispatcher.js index 8c02ce36022b..f8388d72a445 100644 --- a/app/assets/javascripts/dispatcher.js +++ b/app/assets/javascripts/dispatcher.js @@ -8,6 +8,7 @@ /* global LabelsSelect */ /* global MilestoneSelect */ /* global Commit */ +/* global CommitsList */ /* global NewBranchForm */ /* global NotificationsForm */ /* global NotificationsDropdown */ @@ -324,6 +325,9 @@ import GpgBadges from './gpg_badges'; new gl.Activities(); shortcut_handler = new ShortcutsNavigation(); break; + case 'projects:commits:show': + CommitsList.init(document.querySelector('.js-project-commits-show').dataset.commits_limit); + break; case 'projects:show': shortcut_handler = new ShortcutsNavigation(); new NotificationsForm(); diff --git a/app/views/projects/commits/show.html.haml b/app/views/projects/commits/show.html.haml index bd2d900997e6..c7fa147054dc 100644 --- a/app/views/projects/commits/show.html.haml +++ b/app/views/projects/commits/show.html.haml @@ -11,34 +11,32 @@ = content_for :sub_nav do = render "head" -%div{ class: container_class } - .tree-holder - .nav-block - .tree-ref-container - .tree-ref-holder - = render 'shared/ref_switcher', destination: 'commits' +.js-project-commits-show{ 'data-commits_limit' => @limit } + %div{ class: container_class } + .tree-holder + .nav-block + .tree-ref-container + .tree-ref-holder + = render 'shared/ref_switcher', destination: 'commits' + + %ul.breadcrumb.repo-breadcrumb + = commits_breadcrumbs + .tree-controls.hidden-xs.hidden-sm + - if @merge_request.present? + .control + = link_to _("View open merge request"), project_merge_request_path(@project, @merge_request), class: 'btn' + - elsif create_mr_button?(@repository.root_ref, @ref) + .control + = link_to _("Create merge request"), create_mr_path(@repository.root_ref, @ref), class: 'btn btn-success' - %ul.breadcrumb.repo-breadcrumb - = commits_breadcrumbs - .tree-controls.hidden-xs.hidden-sm - - if @merge_request.present? .control - = link_to _("View open merge request"), project_merge_request_path(@project, @merge_request), class: 'btn' - - elsif create_mr_button?(@repository.root_ref, @ref) + = form_tag(project_commits_path(@project, @id), method: :get, class: 'commits-search-form', data: { 'signatures-path' => namespace_project_signatures_path }) do + = search_field_tag :search, params[:search], { placeholder: _('Filter by commit message'), id: 'commits-search', class: 'form-control search-text-input input-short', spellcheck: false } .control - = link_to _("Create merge request"), create_mr_path(@repository.root_ref, @ref), class: 'btn btn-success' + = link_to project_commits_path(@project, @ref, rss_url_options), title: _("Commits feed"), class: 'btn' do + = icon("rss") - .control - = form_tag(project_commits_path(@project, @id), method: :get, class: 'commits-search-form', data: { 'signatures-path' => namespace_project_signatures_path }) do - = search_field_tag :search, params[:search], { placeholder: _('Filter by commit message'), id: 'commits-search', class: 'form-control search-text-input input-short', spellcheck: false } - .control - = link_to project_commits_path(@project, @ref, rss_url_options), title: _("Commits feed"), class: 'btn' do - = icon("rss") - - %div{ id: dom_id(@project) } - %ol#commits-list.list-unstyled.content_list - = render 'commits', project: @project, ref: @ref - = spinner - -:javascript - CommitsList.init(#{@limit}); + %div{ id: dom_id(@project) } + %ol#commits-list.list-unstyled.content_list + = render 'commits', project: @project, ref: @ref + = spinner -- GitLab From 32e0a95e0e8f283ba11087d136818c9adf3cf18b Mon Sep 17 00:00:00 2001 From: Tim Zallmann Date: Fri, 21 Jul 2017 15:59:11 +0200 Subject: [PATCH 12/26] Find File moved to dispatcher --- app/assets/javascripts/dispatcher.js | 10 +++++++++- app/views/projects/find_file/show.html.haml | 10 +--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/assets/javascripts/dispatcher.js b/app/assets/javascripts/dispatcher.js index f8388d72a445..b5b58f6297a5 100644 --- a/app/assets/javascripts/dispatcher.js +++ b/app/assets/javascripts/dispatcher.js @@ -27,10 +27,12 @@ /* global MergeRequest */ /* global Compare */ /* global CompareAutocomplete */ +/* global ProjectFindFile */ /* global ProjectNew */ /* global ProjectShow */ /* global Labels */ /* global Shortcuts */ +/* global ShortcutsFindFile */ /* global Sidebar */ /* global ShortcutsWiki */ @@ -198,7 +200,6 @@ import GpgBadges from './gpg_badges'; break; case 'explore:groups:index': new GroupsList(); - const landingElement = document.querySelector('.js-explore-groups-landing'); if (!landingElement) break; const exploreGroupsLanding = new Landing( @@ -403,6 +404,13 @@ import GpgBadges from './gpg_badges'; }); break; case 'projects:find_file:show': + const findElement = document.querySelector('.js-file-finder'); + const projectFindFile = new ProjectFindFile($(".file-finder-holder"), { + url: findElement.dataset.file_find_url, + treeUrl: findElement.dataset.find_tree_url, + blobUrlTemplate: findElement.dataset.blob_url_template, + }); + new ShortcutsFindFile(projectFindFile); shortcut_handler = true; break; case 'projects:blob:show': diff --git a/app/views/projects/find_file/show.html.haml b/app/views/projects/find_file/show.html.haml index e3bf48ee47f7..ccfcf19d3b60 100644 --- a/app/views/projects/find_file/show.html.haml +++ b/app/views/projects/find_file/show.html.haml @@ -1,7 +1,7 @@ - page_title "Find File", @ref = render "projects/commits/head" -.file-finder-holder.tree-holder.clearfix +.file-finder-holder.tree-holder.clearfix.js-file-finder{'data-file_find_url': "#{escape_javascript(project_files_path(@project, @ref, @options.merge(format: :json)))}", 'data-find_tree_url': escape_javascript(project_tree_path(@project, @ref)), 'data-blob_url_template': escape_javascript(project_blob_path(@project, @id || @commit.id))} .nav-block .tree-ref-holder = render 'shared/ref_switcher', destination: 'find_file', path: @path @@ -17,11 +17,3 @@ %table.table.files-slider{ class: "table_#{@hex_path} tree-table table-striped" } %tbody = spinner nil, true - -:javascript - var projectFindFile = new ProjectFindFile($(".file-finder-holder"), { - url: "#{escape_javascript(project_files_path(@project, @ref, @options.merge(format: :json)))}", - treeUrl: "#{escape_javascript(project_tree_path(@project, @ref))}", - blobUrlTemplate: "#{escape_javascript(project_blob_path(@project, @id || @commit.id))}" - }); - new ShortcutsFindFile(projectFindFile); -- GitLab From 9a6021a6dc5186659f3f764cae130548e297e76c Mon Sep 17 00:00:00 2001 From: Tim Zallmann Date: Fri, 21 Jul 2017 16:34:16 +0200 Subject: [PATCH 13/26] Moving Graphs and charts to External FIles --- .../javascripts/graphs/graphs_bundle.js | 2 -- .../javascripts/graphs/graphs_charts.js | 0 app/assets/javascripts/graphs/graphs_show.js | 21 ++++++++++++++ app/views/projects/graphs/charts.html.haml | 5 ++-- app/views/projects/graphs/show.html.haml | 28 +++---------------- config/webpack.config.js | 2 ++ 6 files changed, 30 insertions(+), 28 deletions(-) create mode 100644 app/assets/javascripts/graphs/graphs_charts.js create mode 100644 app/assets/javascripts/graphs/graphs_show.js diff --git a/app/assets/javascripts/graphs/graphs_bundle.js b/app/assets/javascripts/graphs/graphs_bundle.js index a433c7ba8f0c..534bc535bb64 100644 --- a/app/assets/javascripts/graphs/graphs_bundle.js +++ b/app/assets/javascripts/graphs/graphs_bundle.js @@ -1,6 +1,4 @@ import Chart from 'vendor/Chart'; -import ContributorsStatGraph from './stat_graph_contributors'; // export to global scope window.Chart = Chart; -window.ContributorsStatGraph = ContributorsStatGraph; diff --git a/app/assets/javascripts/graphs/graphs_charts.js b/app/assets/javascripts/graphs/graphs_charts.js new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/app/assets/javascripts/graphs/graphs_show.js b/app/assets/javascripts/graphs/graphs_show.js new file mode 100644 index 000000000000..109cd5bddaaf --- /dev/null +++ b/app/assets/javascripts/graphs/graphs_show.js @@ -0,0 +1,21 @@ +import ContributorsStatGraph from './stat_graph_contributors'; + +document.addEventListener('DOMContentLoaded', () => { + $.ajax({ + type: 'GET', + url: document.querySelector('.js-graphs-show').dataset.project_graph_path, + dataType: 'json', + success(data) { + const graph = new ContributorsStatGraph(); + graph.init(data); + + $('#brush_change').change(() => { + graph.change_date_header(); + graph.redraw_authors(); + }); + + $('.stat-graph').fadeIn(); + $('.loading-graph').hide(); + }, + }); +}); diff --git a/app/views/projects/graphs/charts.html.haml b/app/views/projects/graphs/charts.html.haml index 249b9d82ad97..2d730e346db0 100644 --- a/app/views/projects/graphs/charts.html.haml +++ b/app/views/projects/graphs/charts.html.haml @@ -3,8 +3,9 @@ - if show_new_nav? - add_to_breadcrumbs("Repository", project_tree_path(@project)) - content_for :page_specific_javascripts do - = page_specific_javascript_bundle_tag('common_d3') - = page_specific_javascript_bundle_tag('graphs') + = webpack_bundle_tag('common_d3') + = webpack_bundle_tag('graphs') + = webpack_bundle_tag('graphs_charts') = render "projects/commits/head" .repo-charts{ class: container_class } diff --git a/app/views/projects/graphs/show.html.haml b/app/views/projects/graphs/show.html.haml index 4256a8c4d7e6..63adc03a3dfe 100644 --- a/app/views/projects/graphs/show.html.haml +++ b/app/views/projects/graphs/show.html.haml @@ -1,15 +1,16 @@ - @no_container = true - page_title "Contributors" - content_for :page_specific_javascripts do - = page_specific_javascript_bundle_tag('common_d3') - = page_specific_javascript_bundle_tag('graphs') + = webpack_bundle_tag('common_d3') + = webpack_bundle_tag('graphs') + = webpack_bundle_tag('graphs_show') - if show_new_nav? - add_to_breadcrumbs("Repository", project_tree_path(@project)) = render 'projects/commits/head' -%div{ class: container_class } +%div.js-graphs-show{ class: container_class, 'data-project_graph_path': "#{project_graph_path(@project, current_ref, format: :json)}" } .sub-header-block .tree-ref-holder = render 'shared/ref_switcher', destination: 'graphs' @@ -33,24 +34,3 @@ #contributors-master #contributors.clearfix %ol.contributors-list.clearfix - - - -:javascript - $.ajax({ - type: "GET", - url: "#{project_graph_path(@project, current_ref, format: :json)}", - dataType: "json", - success: function (data) { - var graph = new ContributorsStatGraph(); - graph.init(data); - - $("#brush_change").change(function(){ - graph.change_date_header(); - graph.redraw_authors(); - }); - - $(".stat-graph").fadeIn(); - $(".loading-graph").hide(); - } - }); diff --git a/config/webpack.config.js b/config/webpack.config.js index 84d31553efc0..78693b467c86 100644 --- a/config/webpack.config.js +++ b/config/webpack.config.js @@ -40,6 +40,8 @@ var config = { environments_folder: './environments/folder/environments_folder_bundle.js', filtered_search: './filtered_search/filtered_search_bundle.js', graphs: './graphs/graphs_bundle.js', + graphs_charts: './graphs/graphs_charts.js', + graphs_show: './graphs/graphs_show.js', group: './group.js', groups: './groups/index.js', groups_list: './groups_list.js', -- GitLab From 35d21badaa03e383a5fdece41504148961b2b4b0 Mon Sep 17 00:00:00 2001 From: Tim Zallmann Date: Mon, 24 Jul 2017 09:32:16 +0200 Subject: [PATCH 14/26] Moved Inline JS from projects import to dispatcher --- app/assets/javascripts/dispatcher.js | 4 ++++ app/views/projects/imports/show.html.haml | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/dispatcher.js b/app/assets/javascripts/dispatcher.js index b5b58f6297a5..0e0c44b3e0e4 100644 --- a/app/assets/javascripts/dispatcher.js +++ b/app/assets/javascripts/dispatcher.js @@ -30,6 +30,7 @@ /* global ProjectFindFile */ /* global ProjectNew */ /* global ProjectShow */ +/* global ProjectImport */ /* global Labels */ /* global Shortcuts */ /* global ShortcutsFindFile */ @@ -342,6 +343,9 @@ import GpgBadges from './gpg_badges'; case 'projects:edit': setupProjectEdit(); break; + case 'projects:imports:show': + new ProjectImport(); + break; case 'projects:pipelines:new': new NewBranchForm($('.js-new-pipeline-form')); break; diff --git a/app/views/projects/imports/show.html.haml b/app/views/projects/imports/show.html.haml index c52b38606369..8c490773a569 100644 --- a/app/views/projects/imports/show.html.haml +++ b/app/views/projects/imports/show.html.haml @@ -10,5 +10,3 @@ - if @project.external_import? %p.monospace git clone --bare #{@project.safe_import_url} %p Please wait while we import the repository for you. Refresh at will. - :javascript - new ProjectImport(); -- GitLab From a686dcdd0c6f17d4c0f3f44586186a0107b167c9 Mon Sep 17 00:00:00 2001 From: Tim Zallmann Date: Mon, 24 Jul 2017 10:20:11 +0200 Subject: [PATCH 15/26] Moved Charts to external JS File --- .../javascripts/graphs/graphs_charts.js | 61 +++++++++++++++++ app/views/projects/graphs/charts.html.haml | 67 +++++-------------- 2 files changed, 77 insertions(+), 51 deletions(-) diff --git a/app/assets/javascripts/graphs/graphs_charts.js b/app/assets/javascripts/graphs/graphs_charts.js index e69de29bb2d1..1fee85ca31ec 100644 --- a/app/assets/javascripts/graphs/graphs_charts.js +++ b/app/assets/javascripts/graphs/graphs_charts.js @@ -0,0 +1,61 @@ +import Chart from 'vendor/Chart'; + +document.addEventListener('DOMContentLoaded', () => { + const responsiveChart = (selector, data) => { + const options = { + scaleOverlay: true, + responsive: true, + pointHitDetectionRadius: 2, + maintainAspectRatio: false, + }; + // get selector by context + const ctx = selector.get(0).getContext('2d'); + // pointing parent container to make chart.js inherit its width + const container = $(selector).parent(); + const generateChart = () => { + selector.attr('width', $(container).width()); + if (window.innerWidth < 768) { + // Scale fonts if window width lower than 768px (iPad portrait) + options.scaleFontSize = 8; + } + return new Chart(ctx).Bar(data, options); + }; + // enabling auto-resizing + $(window).resize(generateChart); + return generateChart(); + }; + + const chartData = (keys, values) => { + const data = { + labels: keys, + datasets: [{ + fillColor: 'rgba(220,220,220,0.5)', + strokeColor: 'rgba(220,220,220,1)', + barStrokeWidth: 1, + barValueSpacing: 1, + barDatasetSpacing: 1, + data: values, + }], + }; + return data; + }; + + const hourData = chartData(gl.projectChartData.hour.keys, gl.projectChartData.hour.values); + responsiveChart($('#hour-chart'), hourData); + + const dayData = chartData(gl.projectChartData.weekDays.keys, gl.projectChartData.weekDays.values); + responsiveChart($('#weekday-chart'), dayData); + + const monthData = chartData(gl.projectChartData.month.keys, gl.projectChartData.month.values); + responsiveChart($('#month-chart'), monthData); + + const data = gl.projectChartData.languages; + const ctx = $('#languages-chart').get(0).getContext('2d'); + const options = { + scaleOverlay: true, + responsive: true, + maintainAspectRatio: false, + }; + + new Chart(ctx).Pie(data, options); +}); diff --git a/app/views/projects/graphs/charts.html.haml b/app/views/projects/graphs/charts.html.haml index 2d730e346db0..97d4ddeab180 100644 --- a/app/views/projects/graphs/charts.html.haml +++ b/app/views/projects/graphs/charts.html.haml @@ -75,56 +75,21 @@ %p.slead Commits per day hour (UTC) %canvas#hour-chart - +-# haml-lint:disable InlineJavaScript :javascript - var responsiveChart = function (selector, data) { - var options = { "scaleOverlay": true, responsive: true, pointHitDetectionRadius: 2, maintainAspectRatio: false }; - // get selector by context - var ctx = selector.get(0).getContext("2d"); - // pointing parent container to make chart.js inherit its width - var container = $(selector).parent(); - var generateChart = function() { - selector.attr('width', $(container).width()); - if (window.innerWidth < 768) { - // Scale fonts if window width lower than 768px (iPad portrait) - options.scaleFontSize = 8 - } - return new Chart(ctx).Bar(data, options); - }; - // enabling auto-resizing - $(window).resize(generateChart); - return generateChart(); - }; - - var chartData = function (keys, values) { - var data = { - labels : keys, - datasets : [{ - fillColor : "rgba(220,220,220,0.5)", - strokeColor : "rgba(220,220,220,1)", - barStrokeWidth: 1, - barValueSpacing: 1, - barDatasetSpacing: 1, - data : values - }] - }; - return data; + window.gl = window.gl || { }; + window.gl.projectChartData = { + hour: { + keys: #{@commits_per_time.keys.to_json}, + values: #{@commits_per_time.values.to_json} + }, + weekDays: { + keys: #{@commits_per_week_days.keys.to_json}, + values: #{@commits_per_week_days.values.to_json} + }, + month: { + keys: #{@commits_per_month.keys.to_json}, + values: #{@commits_per_month.values.to_json} + }, + languages: #{@languages.to_json} }; - - var hourData = chartData(#{@commits_per_time.keys.to_json}, #{@commits_per_time.values.to_json}); - responsiveChart($('#hour-chart'), hourData); - - var dayData = chartData(#{@commits_per_week_days.keys.to_json}, #{@commits_per_week_days.values.to_json}); - responsiveChart($('#weekday-chart'), dayData); - - var monthData = chartData(#{@commits_per_month.keys.to_json}, #{@commits_per_month.values.to_json}); - responsiveChart($('#month-chart'), monthData); - - var data = #{@languages.to_json}; - var ctx = $("#languages-chart").get(0).getContext("2d"); - var options = { - scaleOverlay: true, - responsive: true, - maintainAspectRatio: false - } - var myPieChart = new Chart(ctx).Pie(data, options); -- GitLab From 5e43c506713edb5214829a27d9e17bae7f034bea Mon Sep 17 00:00:00 2001 From: Tim Zallmann Date: Mon, 24 Jul 2017 10:34:51 +0200 Subject: [PATCH 16/26] Set Inline Scripts with URL's to Ignore Fixed Static Testing --- app/views/layouts/_init_auto_complete.html.haml | 1 + app/views/layouts/project.html.haml | 1 + app/views/layouts/snippets.html.haml | 1 + app/views/projects/branches/new.html.haml | 2 +- app/views/projects/find_file/show.html.haml | 2 +- app/views/projects/graphs/show.html.haml | 2 +- 6 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/views/layouts/_init_auto_complete.html.haml b/app/views/layouts/_init_auto_complete.html.haml index 4bb0dfc73fdc..9704c9ec624c 100644 --- a/app/views/layouts/_init_auto_complete.html.haml +++ b/app/views/layouts/_init_auto_complete.html.haml @@ -2,6 +2,7 @@ - noteable_type = @noteable.class if @noteable.present? - if project + -# haml-lint:disable InlineJavaScript :javascript gl.GfmAutoComplete = gl.GfmAutoComplete || {}; gl.GfmAutoComplete.dataSources = { diff --git a/app/views/layouts/project.html.haml b/app/views/layouts/project.html.haml index 99adb83cd1f1..54d56e9b8737 100644 --- a/app/views/layouts/project.html.haml +++ b/app/views/layouts/project.html.haml @@ -10,6 +10,7 @@ - content_for :project_javascripts do - project = @target_project || @project - if current_user + -# haml-lint:disable InlineJavaScript :javascript window.uploads_path = "#{project_uploads_path(project)}"; diff --git a/app/views/layouts/snippets.html.haml b/app/views/layouts/snippets.html.haml index 57971205e0e9..849075a0ba51 100644 --- a/app/views/layouts/snippets.html.haml +++ b/app/views/layouts/snippets.html.haml @@ -2,6 +2,7 @@ - content_for :page_specific_javascripts do - if @snippet && current_user + -# haml-lint:disable InlineJavaScript :javascript window.uploads_path = "#{upload_path('personal_snippet', id: @snippet.id)}"; diff --git a/app/views/projects/branches/new.html.haml b/app/views/projects/branches/new.html.haml index 16d7727d2b7a..9d77ca4db7b3 100644 --- a/app/views/projects/branches/new.html.haml +++ b/app/views/projects/branches/new.html.haml @@ -28,7 +28,7 @@ .form-actions = button_tag 'Create branch', class: 'btn btn-create', tabindex: 3 = link_to 'Cancel', project_branches_path(@project), class: 'btn btn-cancel' --# haml-lint:disable InlineJavaScript +-# haml-lint:disable InlineJavaScript :javascript window.gl = window.gl || { }; window.gl.availableRefs = #{@project.repository.ref_names.to_json}; diff --git a/app/views/projects/find_file/show.html.haml b/app/views/projects/find_file/show.html.haml index ccfcf19d3b60..de9d49cfb6ad 100644 --- a/app/views/projects/find_file/show.html.haml +++ b/app/views/projects/find_file/show.html.haml @@ -1,7 +1,7 @@ - page_title "Find File", @ref = render "projects/commits/head" -.file-finder-holder.tree-holder.clearfix.js-file-finder{'data-file_find_url': "#{escape_javascript(project_files_path(@project, @ref, @options.merge(format: :json)))}", 'data-find_tree_url': escape_javascript(project_tree_path(@project, @ref)), 'data-blob_url_template': escape_javascript(project_blob_path(@project, @id || @commit.id))} +.file-finder-holder.tree-holder.clearfix.js-file-finder{'data-file_find_url': "#{ escape_javascript(project_files_path(@project, @ref, @options.merge(format: :json))) }", 'data-find_tree_url': escape_javascript(project_tree_path(@project, @ref)), 'data-blob_url_template': escape_javascript(project_blob_path(@project, @id || @commit.id))} .nav-block .tree-ref-holder = render 'shared/ref_switcher', destination: 'find_file', path: @path diff --git a/app/views/projects/graphs/show.html.haml b/app/views/projects/graphs/show.html.haml index 63adc03a3dfe..296bf7048e3a 100644 --- a/app/views/projects/graphs/show.html.haml +++ b/app/views/projects/graphs/show.html.haml @@ -10,7 +10,7 @@ = render 'projects/commits/head' -%div.js-graphs-show{ class: container_class, 'data-project_graph_path': "#{project_graph_path(@project, current_ref, format: :json)}" } +.js-graphs-show{ class: container_class, 'data-project_graph_path': "#{ project_graph_path(@project, current_ref, format: :json) }" } .sub-header-block .tree-ref-holder = render 'shared/ref_switcher', destination: 'graphs' -- GitLab From 2e999042389030e7ecc6a9f71dd108968780403e Mon Sep 17 00:00:00 2001 From: Tim Zallmann Date: Mon, 24 Jul 2017 14:05:49 +0200 Subject: [PATCH 17/26] Fixed 2FA , Dispatching for Commits Show and Static Analysis --- app/assets/javascripts/dispatcher.js | 4 +++- app/assets/javascripts/two_factor_auth.js | 7 ++++--- app/views/profiles/two_factor_auths/show.html.haml | 2 +- app/views/projects/find_file/show.html.haml | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/dispatcher.js b/app/assets/javascripts/dispatcher.js index 0e0c44b3e0e4..1849b7e88f59 100644 --- a/app/assets/javascripts/dispatcher.js +++ b/app/assets/javascripts/dispatcher.js @@ -223,7 +223,7 @@ import GpgBadges from './gpg_badges'; case 'projects:compare:show': new gl.Diff(); break; - case 'projects:branches:new': + case 'projects:branches:create': new NewBranchForm($('.js-create-branch-form'), window.gl.availableRefs); break; case 'projects:branches:index': @@ -329,6 +329,8 @@ import GpgBadges from './gpg_badges'; break; case 'projects:commits:show': CommitsList.init(document.querySelector('.js-project-commits-show').dataset.commits_limit); + new gl.Activities(); + shortcut_handler = new ShortcutsNavigation(); break; case 'projects:show': shortcut_handler = new ShortcutsNavigation(); diff --git a/app/assets/javascripts/two_factor_auth.js b/app/assets/javascripts/two_factor_auth.js index d3c23d0276ba..b9814f18193d 100644 --- a/app/assets/javascripts/two_factor_auth.js +++ b/app/assets/javascripts/two_factor_auth.js @@ -1,9 +1,10 @@ /* global U2FRegister */ document.addEventListener('DOMContentLoaded', () => { - const skippable = document.querySelector('.js-two-factor-auth').dataset.two_factor_skippable === 'true'; + const twoFactorNode = document.querySelector('.js-two-factor-auth'); + const skippable = twoFactorNode.dataset.two_factor_skippable === 'true'; if (skippable) { - const button = "Configure it later"; - const flashAlert = document.querySelector('.flash-alert'); + const button = `Configure it later`; + const flashAlert = document.querySelector('.flash-alert .container-fluid'); if (flashAlert) flashAlert.insertAdjacentHTML('beforeend', button); } diff --git a/app/views/profiles/two_factor_auths/show.html.haml b/app/views/profiles/two_factor_auths/show.html.haml index 783bc4d2a306..607b89d2a234 100644 --- a/app/views/profiles/two_factor_auths/show.html.haml +++ b/app/views/profiles/two_factor_auths/show.html.haml @@ -12,7 +12,7 @@ - if inject_u2f_api? = page_specific_javascript_bundle_tag('u2f') -.js-two-factor-auth{ 'data-two_factor_skippable' => two_factor_skippable? } +.js-two-factor-auth{ 'data-two_factor_skippable' => "#{two_factor_skippable?}", 'data-two_factor_skip_url' => skip_profile_two_factor_auth_path } .row.prepend-top-default .col-lg-4 %h4.prepend-top-0 diff --git a/app/views/projects/find_file/show.html.haml b/app/views/projects/find_file/show.html.haml index de9d49cfb6ad..3e496c0e4bf9 100644 --- a/app/views/projects/find_file/show.html.haml +++ b/app/views/projects/find_file/show.html.haml @@ -1,7 +1,7 @@ - page_title "Find File", @ref = render "projects/commits/head" -.file-finder-holder.tree-holder.clearfix.js-file-finder{'data-file_find_url': "#{ escape_javascript(project_files_path(@project, @ref, @options.merge(format: :json))) }", 'data-find_tree_url': escape_javascript(project_tree_path(@project, @ref)), 'data-blob_url_template': escape_javascript(project_blob_path(@project, @id || @commit.id))} +.file-finder-holder.tree-holder.clearfix.js-file-finder{ 'data-file_find_url': "#{escape_javascript(project_files_path(@project, @ref, @options.merge(format: :json)))}", 'data-find_tree_url': escape_javascript(project_tree_path(@project, @ref)), 'data-blob_url_template': escape_javascript(project_blob_path(@project, @id || @commit.id)) } .nav-block .tree-ref-holder = render 'shared/ref_switcher', destination: 'find_file', path: @path -- GitLab From 055f7f863a7891db258066dde60a4f262a0a4cee Mon Sep 17 00:00:00 2001 From: Tim Zallmann Date: Mon, 24 Jul 2017 18:28:24 +0200 Subject: [PATCH 18/26] Fix for Dropdown Tests on new Branch Creation --- app/assets/javascripts/dispatcher.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/javascripts/dispatcher.js b/app/assets/javascripts/dispatcher.js index 1849b7e88f59..3156fb7f86b9 100644 --- a/app/assets/javascripts/dispatcher.js +++ b/app/assets/javascripts/dispatcher.js @@ -223,6 +223,7 @@ import GpgBadges from './gpg_badges'; case 'projects:compare:show': new gl.Diff(); break; + case 'projects:branches:new': case 'projects:branches:create': new NewBranchForm($('.js-create-branch-form'), window.gl.availableRefs); break; -- GitLab From 869d46c599c8508ab09044a949ed276f0bb3ccd5 Mon Sep 17 00:00:00 2001 From: Tim Zallmann Date: Tue, 25 Jul 2017 14:35:35 +0200 Subject: [PATCH 19/26] Changes based on Feedback on MR --- app/assets/javascripts/commit/commit_box.js | 2 +- app/assets/javascripts/dispatcher.js | 10 +++---- .../javascripts/graphs/graphs_charts.js | 10 ++++--- app/assets/javascripts/graphs/graphs_show.js | 2 +- app/assets/javascripts/two_factor_auth.js | 2 +- .../profiles/two_factor_auths/show.html.haml | 2 +- app/views/projects/branches/new.html.haml | 5 +--- .../projects/commit/_commit_box.html.haml | 2 +- app/views/projects/commits/show.html.haml | 2 +- app/views/projects/find_file/show.html.haml | 2 +- app/views/projects/graphs/charts.html.haml | 26 ++++++------------- app/views/projects/graphs/show.html.haml | 2 +- 12 files changed, 28 insertions(+), 39 deletions(-) diff --git a/app/assets/javascripts/commit/commit_box.js b/app/assets/javascripts/commit/commit_box.js index 20f29df4d281..99a879f4380c 100644 --- a/app/assets/javascripts/commit/commit_box.js +++ b/app/assets/javascripts/commit/commit_box.js @@ -1,4 +1,4 @@ /* global U2FRegister */ document.addEventListener('DOMContentLoaded', () => { - $('.commit-info.branches').load(document.querySelector('.js-commit-box').dataset.commit_path); + $('.commit-info.branches').load(document.querySelector('.js-commit-box').dataset.commitPath); }); diff --git a/app/assets/javascripts/dispatcher.js b/app/assets/javascripts/dispatcher.js index 3156fb7f86b9..17d7f550d92e 100644 --- a/app/assets/javascripts/dispatcher.js +++ b/app/assets/javascripts/dispatcher.js @@ -225,7 +225,7 @@ import GpgBadges from './gpg_badges'; break; case 'projects:branches:new': case 'projects:branches:create': - new NewBranchForm($('.js-create-branch-form'), window.gl.availableRefs); + new NewBranchForm($('.js-create-branch-form'), JSON.parse(document.getElementById('availableRefs').innerHTML)); break; case 'projects:branches:index': gl.AjaxLoadingSpinner.init(); @@ -329,7 +329,7 @@ import GpgBadges from './gpg_badges'; shortcut_handler = new ShortcutsNavigation(); break; case 'projects:commits:show': - CommitsList.init(document.querySelector('.js-project-commits-show').dataset.commits_limit); + CommitsList.init(document.querySelector('.js-project-commits-show').dataset.commitsLimit); new gl.Activities(); shortcut_handler = new ShortcutsNavigation(); break; @@ -413,9 +413,9 @@ import GpgBadges from './gpg_badges'; case 'projects:find_file:show': const findElement = document.querySelector('.js-file-finder'); const projectFindFile = new ProjectFindFile($(".file-finder-holder"), { - url: findElement.dataset.file_find_url, - treeUrl: findElement.dataset.find_tree_url, - blobUrlTemplate: findElement.dataset.blob_url_template, + url: findElement.dataset.fileFindUrl, + treeUrl: findElement.dataset.findTreeUrl, + blobUrlTemplate: findElement.dataset.blobUrlTemplate, }); new ShortcutsFindFile(projectFindFile); shortcut_handler = true; diff --git a/app/assets/javascripts/graphs/graphs_charts.js b/app/assets/javascripts/graphs/graphs_charts.js index 1fee85ca31ec..279ffef770f2 100644 --- a/app/assets/javascripts/graphs/graphs_charts.js +++ b/app/assets/javascripts/graphs/graphs_charts.js @@ -1,6 +1,8 @@ import Chart from 'vendor/Chart'; document.addEventListener('DOMContentLoaded', () => { + const projectChartData = JSON.parse(document.getElementById('projectChartData').innerHTML); + const responsiveChart = (selector, data) => { const options = { scaleOverlay: true, @@ -40,16 +42,16 @@ document.addEventListener('DOMContentLoaded', () => { return data; }; - const hourData = chartData(gl.projectChartData.hour.keys, gl.projectChartData.hour.values); + const hourData = chartData(projectChartData.hour.keys, projectChartData.hour.values); responsiveChart($('#hour-chart'), hourData); - const dayData = chartData(gl.projectChartData.weekDays.keys, gl.projectChartData.weekDays.values); + const dayData = chartData(projectChartData.weekDays.keys, projectChartData.weekDays.values); responsiveChart($('#weekday-chart'), dayData); - const monthData = chartData(gl.projectChartData.month.keys, gl.projectChartData.month.values); + const monthData = chartData(projectChartData.month.keys, projectChartData.month.values); responsiveChart($('#month-chart'), monthData); - const data = gl.projectChartData.languages; + const data = projectChartData.languages; const ctx = $('#languages-chart').get(0).getContext('2d'); const options = { scaleOverlay: true, diff --git a/app/assets/javascripts/graphs/graphs_show.js b/app/assets/javascripts/graphs/graphs_show.js index 109cd5bddaaf..36bad6db3e1d 100644 --- a/app/assets/javascripts/graphs/graphs_show.js +++ b/app/assets/javascripts/graphs/graphs_show.js @@ -3,7 +3,7 @@ import ContributorsStatGraph from './stat_graph_contributors'; document.addEventListener('DOMContentLoaded', () => { $.ajax({ type: 'GET', - url: document.querySelector('.js-graphs-show').dataset.project_graph_path, + url: document.querySelector('.js-graphs-show').dataset.projectGraphPath, dataType: 'json', success(data) { const graph = new ContributorsStatGraph(); diff --git a/app/assets/javascripts/two_factor_auth.js b/app/assets/javascripts/two_factor_auth.js index b9814f18193d..d26f61562a59 100644 --- a/app/assets/javascripts/two_factor_auth.js +++ b/app/assets/javascripts/two_factor_auth.js @@ -1,7 +1,7 @@ /* global U2FRegister */ document.addEventListener('DOMContentLoaded', () => { const twoFactorNode = document.querySelector('.js-two-factor-auth'); - const skippable = twoFactorNode.dataset.two_factor_skippable === 'true'; + const skippable = twoFactorNode.dataset.twoFactorSkippable === 'true'; if (skippable) { const button = `Configure it later`; const flashAlert = document.querySelector('.flash-alert .container-fluid'); diff --git a/app/views/profiles/two_factor_auths/show.html.haml b/app/views/profiles/two_factor_auths/show.html.haml index 607b89d2a234..ff434b5dbad9 100644 --- a/app/views/profiles/two_factor_auths/show.html.haml +++ b/app/views/profiles/two_factor_auths/show.html.haml @@ -12,7 +12,7 @@ - if inject_u2f_api? = page_specific_javascript_bundle_tag('u2f') -.js-two-factor-auth{ 'data-two_factor_skippable' => "#{two_factor_skippable?}", 'data-two_factor_skip_url' => skip_profile_two_factor_auth_path } +.js-two-factor-auth{ 'data-two-factor-skippable' => "#{two_factor_skippable?}", 'data-two_factor_skip_url' => skip_profile_two_factor_auth_path } .row.prepend-top-default .col-lg-4 %h4.prepend-top-0 diff --git a/app/views/projects/branches/new.html.haml b/app/views/projects/branches/new.html.haml index 9d77ca4db7b3..2baaaf6ac5bd 100644 --- a/app/views/projects/branches/new.html.haml +++ b/app/views/projects/branches/new.html.haml @@ -28,7 +28,4 @@ .form-actions = button_tag 'Create branch', class: 'btn btn-create', tabindex: 3 = link_to 'Cancel', project_branches_path(@project), class: 'btn btn-cancel' --# haml-lint:disable InlineJavaScript -:javascript - window.gl = window.gl || { }; - window.gl.availableRefs = #{@project.repository.ref_names.to_json}; +%script#availableRefs{ type: "application/json" }= @project.repository.ref_names.to_json.html_safe diff --git a/app/views/projects/commit/_commit_box.html.haml b/app/views/projects/commit/_commit_box.html.haml index 0d8bce5548fd..af7cfd18280b 100644 --- a/app/views/projects/commit/_commit_box.html.haml +++ b/app/views/projects/commit/_commit_box.html.haml @@ -1,7 +1,7 @@ - content_for :page_specific_javascripts do = webpack_bundle_tag('commit_box') -.page-content-header.js-commit-box{ 'data-commit_path' => branches_project_commit_path(@project, @commit.id) } +.page-content-header.js-commit-box{ 'data-commit-path' => branches_project_commit_path(@project, @commit.id) } .header-main-content = render partial: 'signature', object: @commit.signature %strong diff --git a/app/views/projects/commits/show.html.haml b/app/views/projects/commits/show.html.haml index c7fa147054dc..7ae560861776 100644 --- a/app/views/projects/commits/show.html.haml +++ b/app/views/projects/commits/show.html.haml @@ -11,7 +11,7 @@ = content_for :sub_nav do = render "head" -.js-project-commits-show{ 'data-commits_limit' => @limit } +.js-project-commits-show{ 'data-commits-limit' => @limit } %div{ class: container_class } .tree-holder .nav-block diff --git a/app/views/projects/find_file/show.html.haml b/app/views/projects/find_file/show.html.haml index 3e496c0e4bf9..021575160ea2 100644 --- a/app/views/projects/find_file/show.html.haml +++ b/app/views/projects/find_file/show.html.haml @@ -1,7 +1,7 @@ - page_title "Find File", @ref = render "projects/commits/head" -.file-finder-holder.tree-holder.clearfix.js-file-finder{ 'data-file_find_url': "#{escape_javascript(project_files_path(@project, @ref, @options.merge(format: :json)))}", 'data-find_tree_url': escape_javascript(project_tree_path(@project, @ref)), 'data-blob_url_template': escape_javascript(project_blob_path(@project, @id || @commit.id)) } +.file-finder-holder.tree-holder.clearfix.js-file-finder{ 'data-file-find-url': "#{escape_javascript(project_files_path(@project, @ref, @options.merge(format: :json)))}", 'data-find-tree-url': escape_javascript(project_tree_path(@project, @ref)), 'data-blob-url-template': escape_javascript(project_blob_path(@project, @id || @commit.id)) } .nav-block .tree-ref-holder = render 'shared/ref_switcher', destination: 'find_file', path: @path diff --git a/app/views/projects/graphs/charts.html.haml b/app/views/projects/graphs/charts.html.haml index 97d4ddeab180..228c8c84792c 100644 --- a/app/views/projects/graphs/charts.html.haml +++ b/app/views/projects/graphs/charts.html.haml @@ -75,21 +75,11 @@ %p.slead Commits per day hour (UTC) %canvas#hour-chart --# haml-lint:disable InlineJavaScript -:javascript - window.gl = window.gl || { }; - window.gl.projectChartData = { - hour: { - keys: #{@commits_per_time.keys.to_json}, - values: #{@commits_per_time.values.to_json} - }, - weekDays: { - keys: #{@commits_per_week_days.keys.to_json}, - values: #{@commits_per_week_days.values.to_json} - }, - month: { - keys: #{@commits_per_month.keys.to_json}, - values: #{@commits_per_month.values.to_json} - }, - languages: #{@languages.to_json} - }; + +%script#projectChartData{ type: "application/json" } + - projectChartData = {}; + - projectChartData['hour'] = { 'keys' => @commits_per_time.keys, 'values' => @commits_per_time.values } + - projectChartData['weekDays'] = { 'keys' => @commits_per_week_days.keys, 'values' => @commits_per_week_days.values } + - projectChartData['month'] = { 'keys' => @commits_per_month.keys, 'values' => @commits_per_month.values } + - projectChartData['languages'] = @languages + = projectChartData.to_json.html_safe diff --git a/app/views/projects/graphs/show.html.haml b/app/views/projects/graphs/show.html.haml index 296bf7048e3a..1715a41049b0 100644 --- a/app/views/projects/graphs/show.html.haml +++ b/app/views/projects/graphs/show.html.haml @@ -10,7 +10,7 @@ = render 'projects/commits/head' -.js-graphs-show{ class: container_class, 'data-project_graph_path': "#{ project_graph_path(@project, current_ref, format: :json) }" } +.js-graphs-show{ class: container_class, 'data-project-graph-path': "#{ project_graph_path(@project, current_ref, format: :json) }" } .sub-header-block .tree-ref-holder = render 'shared/ref_switcher', destination: 'graphs' -- GitLab From 81a991f0d5592004e42d1f3b6c9355882a86b043 Mon Sep 17 00:00:00 2001 From: Tim Zallmann Date: Tue, 25 Jul 2017 16:28:29 +0200 Subject: [PATCH 20/26] Refactored the select in personal access tokens --- app/assets/javascripts/profile/personal_access_tokens.js | 8 -------- app/views/profiles/personal_access_tokens/index.html.haml | 4 +--- 2 files changed, 1 insertion(+), 11 deletions(-) delete mode 100644 app/assets/javascripts/profile/personal_access_tokens.js diff --git a/app/assets/javascripts/profile/personal_access_tokens.js b/app/assets/javascripts/profile/personal_access_tokens.js deleted file mode 100644 index 0a6d601d3534..000000000000 --- a/app/assets/javascripts/profile/personal_access_tokens.js +++ /dev/null @@ -1,8 +0,0 @@ -document.addEventListener('DOMContentLoaded', () => { - const createdTokenInput = document.getElementById('created-personal-access-token'); - if (createdTokenInput) { - createdTokenInput.addEventListener('click', () => { - createdTokenInput.select(); - }); - } -}); diff --git a/app/views/profiles/personal_access_tokens/index.html.haml b/app/views/profiles/personal_access_tokens/index.html.haml index fcf53ab87edd..2216708d354a 100644 --- a/app/views/profiles/personal_access_tokens/index.html.haml +++ b/app/views/profiles/personal_access_tokens/index.html.haml @@ -1,7 +1,5 @@ - page_title "Personal Access Tokens" - @content_class = "limit-container-width" unless fluid_layout -- content_for :page_specific_javascripts do - = webpack_bundle_tag('personal_access_tokens') = render 'profiles/head' @@ -22,7 +20,7 @@ %h5.prepend-top-0 Your New Personal Access Token .form-group - = text_field_tag 'created-personal-access-token', flash[:personal_access_token], readonly: true, class: "form-control", 'aria-describedby' => "created-personal-access-token-help-block" + = text_field_tag 'created-personal-access-token', flash[:personal_access_token], readonly: true, class: "form-control js-select-on-focus", 'aria-describedby' => "created-personal-access-token-help-block" = clipboard_button(text: flash[:personal_access_token], title: "Copy personal access token to clipboard", placement: "left") %span#created-personal-access-token-help-block.help-block.text-danger Make sure you save it - you won't be able to access it again. -- GitLab From c5012e29e9ed48f0c6811f8e09df59e63fa5e749 Mon Sep 17 00:00:00 2001 From: Tim Zallmann Date: Wed, 26 Jul 2017 10:18:14 +0200 Subject: [PATCH 21/26] Removed personal_access_tokens.js from webpack config --- config/webpack.config.js | 1 - 1 file changed, 1 deletion(-) diff --git a/config/webpack.config.js b/config/webpack.config.js index 78693b467c86..ef9422323bd9 100644 --- a/config/webpack.config.js +++ b/config/webpack.config.js @@ -56,7 +56,6 @@ var config = { network: './network/network_bundle.js', notebook_viewer: './blob/notebook_viewer.js', pdf_viewer: './blob/pdf_viewer.js', - personal_access_tokens:'./profile/personal_access_tokens.js', pipelines: './pipelines/pipelines_bundle.js', pipelines_charts: './pipelines/pipelines_charts.js', pipelines_details: './pipelines/pipeline_details_bundle.js', -- GitLab From 7432f17f429810075f880d81e862dabc393d5b96 Mon Sep 17 00:00:00 2001 From: Tim Zallmann Date: Thu, 27 Jul 2017 10:25:41 +0200 Subject: [PATCH 22/26] Commit_box removed as it is only one line, 2Factor changed --- app/assets/javascripts/commit/commit_box.js | 4 ---- app/assets/javascripts/dispatcher.js | 2 ++ app/views/profiles/two_factor_auths/show.html.haml | 3 ++- app/views/projects/commit/_commit_box.html.haml | 3 --- app/views/projects/graphs/show.html.haml | 2 +- config/webpack.config.js | 1 - 6 files changed, 5 insertions(+), 10 deletions(-) delete mode 100644 app/assets/javascripts/commit/commit_box.js diff --git a/app/assets/javascripts/commit/commit_box.js b/app/assets/javascripts/commit/commit_box.js deleted file mode 100644 index 99a879f4380c..000000000000 --- a/app/assets/javascripts/commit/commit_box.js +++ /dev/null @@ -1,4 +0,0 @@ -/* global U2FRegister */ -document.addEventListener('DOMContentLoaded', () => { - $('.commit-info.branches').load(document.querySelector('.js-commit-box').dataset.commitPath); -}); diff --git a/app/assets/javascripts/dispatcher.js b/app/assets/javascripts/dispatcher.js index 17d7f550d92e..a7ab166848d8 100644 --- a/app/assets/javascripts/dispatcher.js +++ b/app/assets/javascripts/dispatcher.js @@ -314,11 +314,13 @@ import GpgBadges from './gpg_badges'; container: '.js-commit-pipeline-graph', }).bindEvents(); initNotes(); + $('.commit-info.branches').load(document.querySelector('.js-commit-box').dataset.commitPath); break; case 'projects:commit:pipelines': new MiniPipelineGraph({ container: '.js-commit-pipeline-graph', }).bindEvents(); + $('.commit-info.branches').load(document.querySelector('.js-commit-box').dataset.commitPath); break; case 'projects:commits:show': shortcut_handler = new ShortcutsNavigation(); diff --git a/app/views/profiles/two_factor_auths/show.html.haml b/app/views/profiles/two_factor_auths/show.html.haml index ff434b5dbad9..c48907f64578 100644 --- a/app/views/profiles/two_factor_auths/show.html.haml +++ b/app/views/profiles/two_factor_auths/show.html.haml @@ -8,9 +8,10 @@ = render 'profiles/head' - content_for :page_specific_javascripts do - = page_specific_javascript_bundle_tag('two_factor_auth') - if inject_u2f_api? = page_specific_javascript_bundle_tag('u2f') + = page_specific_javascript_bundle_tag('two_factor_auth') + .js-two-factor-auth{ 'data-two-factor-skippable' => "#{two_factor_skippable?}", 'data-two_factor_skip_url' => skip_profile_two_factor_auth_path } .row.prepend-top-default diff --git a/app/views/projects/commit/_commit_box.html.haml b/app/views/projects/commit/_commit_box.html.haml index af7cfd18280b..09bcd187e59d 100644 --- a/app/views/projects/commit/_commit_box.html.haml +++ b/app/views/projects/commit/_commit_box.html.haml @@ -1,6 +1,3 @@ -- content_for :page_specific_javascripts do - = webpack_bundle_tag('commit_box') - .page-content-header.js-commit-box{ 'data-commit-path' => branches_project_commit_path(@project, @commit.id) } .header-main-content = render partial: 'signature', object: @commit.signature diff --git a/app/views/projects/graphs/show.html.haml b/app/views/projects/graphs/show.html.haml index 1715a41049b0..f41a0d8293bd 100644 --- a/app/views/projects/graphs/show.html.haml +++ b/app/views/projects/graphs/show.html.haml @@ -10,7 +10,7 @@ = render 'projects/commits/head' -.js-graphs-show{ class: container_class, 'data-project-graph-path': "#{ project_graph_path(@project, current_ref, format: :json) }" } +.js-graphs-show{ class: container_class, 'data-project-graph-path': project_graph_path(@project, current_ref, format: :json) } .sub-header-block .tree-ref-holder = render 'shared/ref_switcher', destination: 'graphs' diff --git a/config/webpack.config.js b/config/webpack.config.js index ef9422323bd9..8b0c64f92891 100644 --- a/config/webpack.config.js +++ b/config/webpack.config.js @@ -33,7 +33,6 @@ var config = { common_d3: ['d3'], cycle_analytics: './cycle_analytics/cycle_analytics_bundle.js', commit_pipelines: './commit/pipelines/pipelines_bundle.js', - commit_box: './commit/commit_box.js', deploy_keys: './deploy_keys/index.js', diff_notes: './diff_notes/diff_notes_bundle.js', environments: './environments/environments_bundle.js', -- GitLab From 832884469478703736dfaf393f22f9bac33cf959 Mon Sep 17 00:00:00 2001 From: Tim Zallmann Date: Thu, 27 Jul 2017 11:26:56 +0200 Subject: [PATCH 23/26] Removed Trailin Whitespaces --- app/views/profiles/two_factor_auths/show.html.haml | 1 - 1 file changed, 1 deletion(-) diff --git a/app/views/profiles/two_factor_auths/show.html.haml b/app/views/profiles/two_factor_auths/show.html.haml index c48907f64578..33e062c1c9c1 100644 --- a/app/views/profiles/two_factor_auths/show.html.haml +++ b/app/views/profiles/two_factor_auths/show.html.haml @@ -11,7 +11,6 @@ - if inject_u2f_api? = page_specific_javascript_bundle_tag('u2f') = page_specific_javascript_bundle_tag('two_factor_auth') - .js-two-factor-auth{ 'data-two-factor-skippable' => "#{two_factor_skippable?}", 'data-two_factor_skip_url' => skip_profile_two_factor_auth_path } .row.prepend-top-default -- GitLab From 7898a0fba98a82026394d445fc138ab75c19199b Mon Sep 17 00:00:00 2001 From: Tim Zallmann Date: Mon, 31 Jul 2017 08:00:53 +0200 Subject: [PATCH 24/26] Fix for projects:commits:show init --- app/assets/javascripts/dispatcher.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/assets/javascripts/dispatcher.js b/app/assets/javascripts/dispatcher.js index a7ab166848d8..a2664c0301e5 100644 --- a/app/assets/javascripts/dispatcher.js +++ b/app/assets/javascripts/dispatcher.js @@ -322,10 +322,6 @@ import GpgBadges from './gpg_badges'; }).bindEvents(); $('.commit-info.branches').load(document.querySelector('.js-commit-box').dataset.commitPath); break; - case 'projects:commits:show': - shortcut_handler = new ShortcutsNavigation(); - GpgBadges.fetch(); - break; case 'projects:activity': new gl.Activities(); shortcut_handler = new ShortcutsNavigation(); @@ -334,6 +330,7 @@ import GpgBadges from './gpg_badges'; CommitsList.init(document.querySelector('.js-project-commits-show').dataset.commitsLimit); new gl.Activities(); shortcut_handler = new ShortcutsNavigation(); + GpgBadges.fetch(); break; case 'projects:show': shortcut_handler = new ShortcutsNavigation(); -- GitLab From 73489f0926e362ba45ccd801e538c6d929ddb197 Mon Sep 17 00:00:00 2001 From: Tim Zallmann Date: Mon, 31 Jul 2017 14:49:01 +0200 Subject: [PATCH 25/26] Focuses the GPG popover badge test to the first Verified as it could be ambigious --- spec/features/commits_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/features/commits_spec.rb b/spec/features/commits_spec.rb index 15ec6f20763e..56cbb19dabfb 100644 --- a/spec/features/commits_spec.rb +++ b/spec/features/commits_spec.rb @@ -282,7 +282,7 @@ end # verified and the gpg user has a gitlab profile - click_on 'Verified' + click_on 'Verified', match: :first within '.popover' do expect(page).to have_content 'This commit was signed with a verified signature.' expect(page).to have_content 'Nannie Bernhard' -- GitLab From 1f743a2b1e9b344ea66e3a5ba55db6bba110445f Mon Sep 17 00:00:00 2001 From: Tim Zallmann Date: Mon, 31 Jul 2017 16:14:36 +0200 Subject: [PATCH 26/26] Another ambigous click resolved --- spec/features/commits_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/features/commits_spec.rb b/spec/features/commits_spec.rb index 56cbb19dabfb..0c9fcc60d301 100644 --- a/spec/features/commits_spec.rb +++ b/spec/features/commits_spec.rb @@ -295,7 +295,7 @@ visit project_commits_path(project, :'signed-commits') - click_on 'Verified' + click_on 'Verified', match: :first within '.popover' do expect(page).to have_content 'This commit was signed with a verified signature.' expect(page).to have_content 'Nannie Bernhard' -- GitLab