From ebcd5711c5ff937bf925002bf9a5b636b037684e Mon Sep 17 00:00:00 2001 From: Takuya Noguchi Date: Thu, 26 Apr 2018 00:58:56 +0900 Subject: [PATCH] Replace time_ago_in_words with JS-based one --- app/views/admin/projects/show.html.haml | 2 +- app/views/admin/runners/_runner.html.haml | 2 +- app/views/admin/runners/show.html.haml | 2 +- app/views/admin/services/index.html.haml | 3 +-- app/views/devise/mailer/unlock_instructions.html.haml | 2 +- app/views/devise/mailer/unlock_instructions.text.erb | 2 +- app/views/projects/jobs/_sidebar.html.haml | 2 +- app/views/projects/registry/repositories/_tag.html.haml | 2 +- app/views/projects/runners/show.html.haml | 2 +- app/views/projects/services/_index.html.haml | 3 +-- app/views/projects/triggers/_trigger.html.haml | 2 +- app/views/sherlock/transactions/_general.html.haml | 3 +-- app/views/sherlock/transactions/index.html.haml | 3 +-- .../45761-replace-actionview-time_ago_in_words.yml | 5 +++++ spec/features/admin/admin_uses_repository_checks_spec.rb | 2 +- 15 files changed, 19 insertions(+), 18 deletions(-) create mode 100644 changelogs/unreleased/45761-replace-actionview-time_ago_in_words.yml diff --git a/app/views/admin/projects/show.html.haml b/app/views/admin/projects/show.html.haml index aeba9788fda..75ca5106fd5 100644 --- a/app/views/admin/projects/show.html.haml +++ b/app/views/admin/projects/show.html.haml @@ -13,7 +13,7 @@ .panel .panel-heading.alert.alert-danger Last repository check - = "(#{time_ago_in_words(@project.last_repository_check_at)} ago)" + = "(#{time_ago_with_tooltip(@project.last_repository_check_at)})" failed. See = link_to 'repocheck.log', admin_logs_path for error messages. diff --git a/app/views/admin/runners/_runner.html.haml b/app/views/admin/runners/_runner.html.haml index e1cee584929..f90b8b8c0a4 100644 --- a/app/views/admin/runners/_runner.html.haml +++ b/app/views/admin/runners/_runner.html.haml @@ -31,7 +31,7 @@ = tag %td - if runner.contacted_at - #{time_ago_in_words(runner.contacted_at)} ago + = time_ago_with_tooltip runner.contacted_at - else Never %td.admin-runner-btn-group-cell diff --git a/app/views/admin/runners/show.html.haml b/app/views/admin/runners/show.html.haml index 37269862de6..d04cf48b05c 100644 --- a/app/views/admin/runners/show.html.haml +++ b/app/views/admin/runners/show.html.haml @@ -108,4 +108,4 @@ %td.timestamp - if build.finished_at - %span #{time_ago_in_words build.finished_at} ago + %span= time_ago_with_tooltip build.finished_at diff --git a/app/views/admin/services/index.html.haml b/app/views/admin/services/index.html.haml index 50132572096..89872c1b91a 100644 --- a/app/views/admin/services/index.html.haml +++ b/app/views/admin/services/index.html.haml @@ -20,5 +20,4 @@ %td = service.description %td.light - = time_ago_in_words service.updated_at - ago + = time_ago_with_tooltip service.updated_at diff --git a/app/views/devise/mailer/unlock_instructions.html.haml b/app/views/devise/mailer/unlock_instructions.html.haml index 79e3a35cc9a..8ddfd3ea74a 100644 --- a/app/views/devise/mailer/unlock_instructions.html.haml +++ b/app/views/devise/mailer/unlock_instructions.html.haml @@ -2,7 +2,7 @@ = email_default_heading("Hello, #{@resource.name}!") %p Your GitLab account has been locked due to an excessive amount of unsuccessful - sign in attempts. Your account will automatically unlock in #{time_ago_in_words(Devise.unlock_in.from_now)} + sign in attempts. Your account will automatically unlock in #{distance_of_time_in_words(Devise.unlock_in)} or you may click the link below to unlock now. #cta = link_to('Unlock account', unlock_url(@resource, unlock_token: @token)) diff --git a/app/views/devise/mailer/unlock_instructions.text.erb b/app/views/devise/mailer/unlock_instructions.text.erb index 3aea3e20145..8d4abbf3500 100644 --- a/app/views/devise/mailer/unlock_instructions.text.erb +++ b/app/views/devise/mailer/unlock_instructions.text.erb @@ -1,7 +1,7 @@ Hello, <%= @resource.name %>! Your GitLab account has been locked due to an excessive amount of unsuccessful -sign in attempts. Your account will automatically unlock in <%= time_ago_in_words(Devise.unlock_in.from_now) %> +sign in attempts. Your account will automatically unlock in <%= distance_of_time_in_words(Devise.unlock_in) %> or you may click the link below to unlock now. <%= unlock_url(@resource, unlock_token: @token) %> diff --git a/app/views/projects/jobs/_sidebar.html.haml b/app/views/projects/jobs/_sidebar.html.haml index 7f0bef5ede0..826404c2008 100644 --- a/app/views/projects/jobs/_sidebar.html.haml +++ b/app/views/projects/jobs/_sidebar.html.haml @@ -15,7 +15,7 @@ - elsif @build.has_expiring_artifacts? %p.build-detail-row The artifacts will be removed in - %span= time_ago_in_words @build.artifacts_expire_at + %span= time_ago_with_tooltip @build.artifacts_expire_at - if @build.artifacts? .btn-group.btn-group-justified{ role: :group } diff --git a/app/views/projects/registry/repositories/_tag.html.haml b/app/views/projects/registry/repositories/_tag.html.haml index 0b082a2137f..0223372bff8 100644 --- a/app/views/projects/registry/repositories/_tag.html.haml +++ b/app/views/projects/registry/repositories/_tag.html.haml @@ -18,7 +18,7 @@ \- %td - if tag.created_at - = time_ago_in_words(tag.created_at) + = time_ago_with_tooltip tag.created_at - else .light \- diff --git a/app/views/projects/runners/show.html.haml b/app/views/projects/runners/show.html.haml index f33e7e25b68..322152cfaca 100644 --- a/app/views/projects/runners/show.html.haml +++ b/app/views/projects/runners/show.html.haml @@ -62,6 +62,6 @@ %td Last contact %td - if @runner.contacted_at - #{time_ago_in_words(@runner.contacted_at)} ago + = time_ago_with_tooltip @runner.contacted_at - else Never diff --git a/app/views/projects/services/_index.html.haml b/app/views/projects/services/_index.html.haml index 915c6b22162..dac7d4d1bbb 100644 --- a/app/views/projects/services/_index.html.haml +++ b/app/views/projects/services/_index.html.haml @@ -27,5 +27,4 @@ = service.description %td.light - if service.updated_at.present? - = time_ago_in_words service.updated_at - ago + = time_ago_with_tooltip service.updated_at diff --git a/app/views/projects/triggers/_trigger.html.haml b/app/views/projects/triggers/_trigger.html.haml index 6249c32b7cc..9201680f119 100644 --- a/app/views/projects/triggers/_trigger.html.haml +++ b/app/views/projects/triggers/_trigger.html.haml @@ -25,7 +25,7 @@ %td - if trigger.last_used - #{time_ago_in_words(trigger.last_used)} ago + = time_ago_with_tooltip trigger.last_used - else Never diff --git a/app/views/sherlock/transactions/_general.html.haml b/app/views/sherlock/transactions/_general.html.haml index 8533b130da6..a37fb5d449a 100644 --- a/app/views/sherlock/transactions/_general.html.haml +++ b/app/views/sherlock/transactions/_general.html.haml @@ -35,5 +35,4 @@ %span.light #{t('sherlock.finished_at')}: %strong - = time_ago_in_words(@transaction.finished_at) - = t('sherlock.ago') + = time_ago_with_tooltip @transaction.finished_at diff --git a/app/views/sherlock/transactions/index.html.haml b/app/views/sherlock/transactions/index.html.haml index bc05659dfa8..6ed7e9e21a6 100644 --- a/app/views/sherlock/transactions/index.html.haml +++ b/app/views/sherlock/transactions/index.html.haml @@ -35,8 +35,7 @@ = t('sherlock.seconds') %td= trans.queries.length %td - = time_ago_in_words(trans.finished_at) - = t('sherlock.ago') + = time_ago_with_tooltip trans.finished_at %td = link_to(sherlock_transaction_path(trans), class: 'btn btn-xs') do = t('sherlock.view') diff --git a/changelogs/unreleased/45761-replace-actionview-time_ago_in_words.yml b/changelogs/unreleased/45761-replace-actionview-time_ago_in_words.yml new file mode 100644 index 00000000000..adf4db90407 --- /dev/null +++ b/changelogs/unreleased/45761-replace-actionview-time_ago_in_words.yml @@ -0,0 +1,5 @@ +--- +title: Replace time_ago_in_words with JS-based one +merge_request: 18607 +author: Takuya Noguchi +type: performance diff --git a/spec/features/admin/admin_uses_repository_checks_spec.rb b/spec/features/admin/admin_uses_repository_checks_spec.rb index f1ac73ff819..90cf5a53787 100644 --- a/spec/features/admin/admin_uses_repository_checks_spec.rb +++ b/spec/features/admin/admin_uses_repository_checks_spec.rb @@ -19,7 +19,7 @@ feature 'Admin uses repository checks' do expect(page).to have_content('Repository check was triggered') end - scenario 'to see a single failed repository check' do + scenario 'to see a single failed repository check', :js do project = create(:project) project.update_columns( last_repository_check_failed: true,