Skip to content
Snippets Groups Projects
Commit f1d3ea63 authored by Bob Van Landuyt's avatar Bob Van Landuyt
Browse files

Show the status of a user in interactions

The status is shown for
- The author of a commit when viewing a commit
- Notes on a commit (regular/diff)
- The user that triggered a pipeline when viewing a pipeline
- The author of a merge request when viewing a merge request
- The author of notes on a merge request (regular/diff)
- The author of an issue when viewing an issue
- The author of notes on an issue
- The author of a snippet when viewing a snippet
- The author of notes on a snippet
- A user's profile page
- The list of members of a group/user
parent b4c4b48a
No related branches found
No related tags found
1 merge request!10495Merge Requests - Assignee
Showing
with 220 additions and 2 deletions
# frozen_string_literal: true
module UserStatusTooltip
extend ActiveSupport::Concern
include ActionView::Helpers::TagHelper
include ActionView::Context
include EmojiHelper
include UsersHelper
included do
expose :user_status_if_loaded, as: :status_tooltip_html
def user_status_if_loaded
return nil unless object.association(:status).loaded?
user_status(object)
end
end
end
Loading
Loading
@@ -2,6 +2,7 @@
 
class UserEntity < API::Entities::UserBasic
include RequestAwareEntity
include UserStatusTooltip
 
expose :path do |user|
user_path(user)
Loading
Loading
Loading
Loading
@@ -24,6 +24,7 @@ module Users
private
 
def set_status
params[:emoji] = UserStatus::DEFAULT_EMOJI if params[:emoji].blank?
user_status.update(params)
end
 
Loading
Loading
Loading
Loading
@@ -13,6 +13,7 @@
= author_avatar(@commit, size: 24, has_tooltip: false)
%strong
= commit_author_link(@commit, avatar: true, size: 24)
= user_status(@commit.author)
- if @commit.different_committer?
%span.light= _('Committed by')
%strong
Loading
Loading
Loading
Loading
@@ -11,6 +11,7 @@
= image_tag avatar_icon_for_user(user, 40), class: "avatar s40", alt: ''
.user-info
= link_to user.name, user_path(user), class: 'member'
= user_status(user)
%span.cgray= user.to_reference
 
- if user == current_user
Loading
Loading
Loading
Loading
@@ -31,7 +31,9 @@
.note-header
.note-header-info
%a{ href: user_path(note.author) }
%span.note-header-author-name= sanitize(note.author.name)
%span.note-header-author-name
= sanitize(note.author.name)
= user_status(note.author)
%span.note-headline-light
= note.author.to_reference
%span.note-headline-light
Loading
Loading
Loading
Loading
@@ -8,6 +8,7 @@
Authored
= time_ago_with_tooltip(@snippet.created_at, placement: 'bottom', html_class: 'snippet_updated_ago')
by #{link_to_member(@project, @snippet.author, size: 24, author_class: "author item-title", avatar_class: "d-none d-sm-inline")}
= user_status(@snippet.author)
 
.detail-page-header-actions
- if @snippet.project_id?
Loading
Loading
Loading
Loading
@@ -40,6 +40,11 @@
.cover-title
= @user.name
 
- if @user.status
.cover-status
= emoji_icon(@user.status.emoji)
= markdown_field(@user.status, :message)
.cover-desc.member-date
%p
%span.middle-dot-divider
Loading
Loading
---
title: Users can set a status message and emoji
merge_request: 20614
author:
type: added
Loading
Loading
@@ -993,6 +993,29 @@ describe Projects::IssuesController do
expect(json_response.first.keys).to match_array(%w[id reply_id expanded notes diff_discussion discussion_path individual_note resolvable resolved resolved_at resolved_by resolved_by_push commit_id for_commit project_id])
end
 
it 'renders the author status html if there is a status' do
create(:user_status, user: discussion.author)
get :discussions, namespace_id: project.namespace, project_id: project, id: issue.iid
note_json = json_response.first['notes'].first
expect(note_json['author']['status_tooltip_html']).to be_present
end
it 'does not cause an extra query for the status' do
control = ActiveRecord::QueryRecorder.new do
get :discussions, namespace_id: project.namespace, project_id: project, id: issue.iid
end
create(:user_status, user: discussion.author)
second_discussion = create(:discussion_note_on_issue, noteable: issue, project: issue.project, author: create(:user))
create(:user_status, user: second_discussion.author)
expect { get :discussions, namespace_id: project.namespace, project_id: project, id: issue.iid }
.not_to exceed_query_limit(control)
end
context 'with cross-reference system note', :request_store do
let(:new_issue) { create(:issue) }
let(:cross_reference) { "mentioned in #{new_issue.to_reference(issue.project)}" }
Loading
Loading
Loading
Loading
@@ -9,7 +9,7 @@ describe 'Groups > Members > List members' do
let(:nested_group) { create(:group, parent: group) }
 
before do
gitlab_sign_in(user1)
sign_in(user1)
end
 
it 'show members from current group and parent', :nested_groups do
Loading
Loading
@@ -32,6 +32,18 @@ describe 'Groups > Members > List members' do
expect(second_row).to be_blank
end
 
describe 'showing status of members' do
before do
group.add_developer(user2)
end
subject { visit group_group_members_path(group) }
it_behaves_like 'showing user status' do
let(:user_with_status) { user2 }
end
end
def first_row
page.all('ul.content-list > li')[0]
end
Loading
Loading
# frozen_string_literal: true
require 'spec_helper'
describe 'Project > Commit > View user status' do
include RepoHelpers
set(:project) { create(:project, :repository) }
set(:user) { create(:user) }
let(:commit_author) { create(:user, email: sample_commit.author_email) }
before do
sign_in(user)
project.add_developer(user)
end
subject { visit(project_commit_path(project, sample_commit.id)) }
describe 'status for the commit author' do
it_behaves_like 'showing user status' do
let(:user_with_status) { commit_author }
end
end
describe 'status for a comment on the commit' do
let(:note) { create(:note, :on_commit, project: project) }
it_behaves_like 'showing user status' do
let(:user_with_status) { note.author }
end
end
describe 'status for a diff note on the commit' do
let(:note) { create(:diff_note_on_commit, project: project) }
it_behaves_like 'showing user status' do
let(:user_with_status) { note.author }
end
end
end
Loading
Loading
@@ -29,4 +29,22 @@ describe "User views issue" do
expect(page).not_to have_link('Close issue')
end
end
describe 'user status' do
subject { visit(project_issue_path(project, issue)) }
describe 'showing status of the author of the issue' do
it_behaves_like 'showing user status' do
let(:user_with_status) { issue.author }
end
end
describe 'showing status of a user who commented on an issue', :js do
let!(:note) { create(:note, noteable: issue, project: project, author: user_with_status) }
it_behaves_like 'showing user status' do
let(:user_with_status) { create(:user) }
end
end
end
end
Loading
Loading
@@ -87,4 +87,12 @@ describe 'Projects members' do
end
end
end
describe 'showing status of members' do
it_behaves_like 'showing user status' do
let(:user_with_status) { developer }
subject { visit project_settings_members_path(project) }
end
end
end
# frozen_string_literal: true
require 'spec_helper'
describe 'Project > Merge request > View user status' do
let(:project) { create(:project, :public, :repository) }
let(:merge_request) do
create(:merge_request, source_project: project, target_project: project, author: create(:user))
end
subject { visit merge_request_path(merge_request) }
describe 'the status of the merge request author' do
it_behaves_like 'showing user status' do
let(:user_with_status) { merge_request.author }
end
end
context 'for notes', :js do
describe 'the status of the author of a note on a merge request' do
let(:note) { create(:note, noteable: merge_request, project: project, author: create(:user)) }
it_behaves_like 'showing user status' do
let(:user_with_status) { note.author }
end
end
describe 'the status of the author of a diff note on a merge request' do
let(:note) { create(:diff_note_on_merge_request, noteable: merge_request, project: project, author: create(:user)) }
it_behaves_like 'showing user status' do
let(:user_with_status) { note.author }
end
end
end
end
Loading
Loading
@@ -63,6 +63,12 @@ describe 'Pipeline', :js do
expect(page).to have_css('#js-tab-pipeline.active')
end
 
it_behaves_like 'showing user status' do
let(:user_with_status) { pipeline.user }
subject { visit project_pipeline_path(project, pipeline) }
end
describe 'pipeline graph' do
context 'when pipeline has running builds' do
it 'shows a running icon and a cancel action for the running build' do
Loading
Loading
Loading
Loading
@@ -141,4 +141,16 @@ describe 'Projects > Snippets > Project snippet', :js do
end
end
end
it_behaves_like 'showing user status' do
let(:file_name) { 'ruby-style-guide.md' }
let(:content) { project.repository.blob_at('master', 'files/markdown/ruby-style-guide.md').data }
let(:user_with_status) { snippet.author }
subject do
visit project_snippet_path(project, snippet)
wait_for_requests
end
end
end
Loading
Loading
@@ -16,6 +16,8 @@ describe 'Comments on personal snippets', :js do
before do
sign_in user
visit snippet_path(snippet)
wait_for_requests
end
 
subject { page }
Loading
Loading
@@ -42,6 +44,15 @@ describe 'Comments on personal snippets', :js do
expect(page).to have_selector('.note-emoji-button')
end
end
it 'shows the status of a note author' do
status = create(:user_status, user: user)
visit snippet_path(snippet)
within("#note_#{snippet_notes[0].id}") do
expect(page).to show_user_status(status)
end
end
end
 
context 'when submitting a note' do
Loading
Loading
Loading
Loading
@@ -155,4 +155,12 @@ describe 'Snippet', :js do
end
end
end
it_behaves_like 'showing user status' do
let(:file_name) { 'popen.rb' }
let(:content) { project.repository.blob_at('master', 'files/ruby/popen.rb').data }
let(:user_with_status) { snippet.author }
subject { visit snippet_path(snippet) }
end
end
Loading
Loading
@@ -53,6 +53,14 @@ describe 'User page' do
end
end
 
it 'shows the status if there was one' do
create(:user_status, user: user, message: "Working hard!")
visit(user_path(user))
expect(page).to have_content("Working hard!")
end
context 'signup disabled' do
it 'shows the sign in link' do
stub_application_setting(signup_enabled: false)
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment