Commit cfec125c authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch '30526-be-wiki-activity-on-project-group-user' into 'master'

#30526 (C) Show Wiki Activity in Project, Group and User Activity Streams

See merge request gitlab-org/gitlab!23869
parents e506176d 2e18d59f
...@@ -68,10 +68,12 @@ module EventsHelper ...@@ -68,10 +68,12 @@ module EventsHelper
end end
def event_preposition(event) def event_preposition(event)
if event.push_action? || event.commented_action? || event.target if event.wiki_page?
"at" 'in the wiki for'
elsif event.milestone? elsif event.milestone?
"in" 'in'
elsif event.push_action? || event.commented_action? || event.target
'at'
end end
end end
...@@ -172,6 +174,19 @@ module EventsHelper ...@@ -172,6 +174,19 @@ module EventsHelper
end end
end end
def event_wiki_title_html(event)
capture do
concat content_tag(:span, _('wiki page'), class: "event-target-type append-right-4")
concat link_to(event.target_title, event_wiki_page_target_url(event),
title: event.target_title,
class: 'has-tooltip event-target-link append-right-4')
end
end
def event_wiki_page_target_url(event)
project_wiki_url(event.project, event.target.canonical_slug)
end
def event_note_title_html(event) def event_note_title_html(event)
if event.note_target if event.note_target
capture do capture do
......
...@@ -5,7 +5,9 @@ ...@@ -5,7 +5,9 @@
.event-item-timestamp .event-item-timestamp
#{time_ago_with_tooltip(event.created_at)} #{time_ago_with_tooltip(event.created_at)}
- if event.created_project_action? - if event.wiki_page?
= render "events/event/wiki", event: event
- elsif event.created_project_action?
= render "events/event/created_project", event: event = render "events/event/created_project", event: event
- elsif event.push_action? - elsif event.push_action?
= render "events/event/push", event: event = render "events/event/push", event: event
......
= icon_for_profile_event(event)
= event_user_info(event)
.event-title.d-flex.flex-wrap
= inline_event_icon(event)
%span.event-type.d-inline-block.append-right-4{ class: event.action_name }
= event.action_name
= event_wiki_title_html(event)
= render "events/event_scope", event: event
...@@ -15,4 +15,6 @@ ...@@ -15,4 +15,6 @@
= render_if_exists 'events/epics_filter' = render_if_exists 'events/epics_filter'
- if comments_visible? - if comments_visible?
= event_filter_link EventFilter::COMMENTS, _('Comments'), s_('EventFilterBy|Filter by comments') = event_filter_link EventFilter::COMMENTS, _('Comments'), s_('EventFilterBy|Filter by comments')
- if Feature.enabled?(:wiki_events) && (@project.nil? || @project.has_wiki?)
= event_filter_link EventFilter::WIKI, _('Wiki'), s_('EventFilterBy|Filter by wiki')
= event_filter_link EventFilter::TEAM, _('Team'), s_('EventFilterBy|Filter by team') = event_filter_link EventFilter::TEAM, _('Team'), s_('EventFilterBy|Filter by team')
---
title: Support wiki events in activity streams
merge_request: 23869
author:
type: changed
...@@ -8184,6 +8184,9 @@ msgstr "" ...@@ -8184,6 +8184,9 @@ msgstr ""
msgid "EventFilterBy|Filter by team" msgid "EventFilterBy|Filter by team"
msgstr "" msgstr ""
msgid "EventFilterBy|Filter by wiki"
msgstr ""
msgid "Events" msgid "Events"
msgstr "" msgstr ""
...@@ -24711,6 +24714,9 @@ msgstr "" ...@@ -24711,6 +24714,9 @@ msgstr ""
msgid "vulnerability|dismissed" msgid "vulnerability|dismissed"
msgstr "" msgstr ""
msgid "wiki page"
msgstr ""
msgid "with %{additions} additions, %{deletions} deletions." msgid "with %{additions} additions, %{deletions} deletions."
msgstr "" msgstr ""
......
...@@ -31,6 +31,8 @@ describe DashboardController do ...@@ -31,6 +31,8 @@ describe DashboardController do
before do before do
create(:event, :created, project: project, target: create(:issue)) create(:event, :created, project: project, target: create(:issue))
create(:wiki_page_event, :created, project: project)
create(:wiki_page_event, :updated, project: project)
sign_in(user) sign_in(user)
...@@ -45,7 +47,7 @@ describe DashboardController do ...@@ -45,7 +47,7 @@ describe DashboardController do
it 'returns count' do it 'returns count' do
get :activity, params: { format: :json } get :activity, params: { format: :json }
expect(json_response['count']).to eq(1) expect(json_response['count']).to eq(3)
end end
end end
......
...@@ -88,6 +88,85 @@ describe EventsHelper do ...@@ -88,6 +88,85 @@ describe EventsHelper do
end end
end end
describe '#event_preposition' do
context 'for wiki page events' do
let(:event) { create(:wiki_page_event) }
it 'returns a suitable phrase' do
expect(helper.event_preposition(event)).to eq('in the wiki for')
end
end
context 'for push action events' do
let(:event) { create(:push_event) }
it 'returns a suitable phrase' do
expect(helper.event_preposition(event)).to eq('at')
end
end
context 'for commented actions' do
let(:event) { create(:event, :commented) }
it 'returns a suitable phrase' do
expect(helper.event_preposition(event)).to eq('at')
end
end
context 'for any event with a target' do
let(:event) { create(:event, target: create(:issue)) }
it 'returns a suitable phrase' do
expect(helper.event_preposition(event)).to eq('at')
end
end
context 'for milestone events' do
let(:event) { create(:event, target: create(:milestone)) }
it 'returns a suitable phrase' do
expect(helper.event_preposition(event)).to eq('in')
end
end
context 'for non-matching events' do
let(:event) { create(:event, :created) }
it 'returns no preposition' do
expect(helper.event_preposition(event)).to be_nil
end
end
end
describe 'event_wiki_page_target_url' do
let(:project) { create(:project) }
let(:wiki_page) { create(:wiki_page, wiki: create(:project_wiki, project: project)) }
let(:event) { create(:wiki_page_event, project: project, wiki_page: wiki_page) }
it 'links to the wiki page' do
url = helper.project_wiki_url(project, wiki_page.slug)
expect(helper.event_wiki_page_target_url(event)).to eq(url)
end
end
describe '#event_wiki_title_html' do
let(:event) { create(:wiki_page_event) }
it 'produces a suitable title chunk' do
url = helper.event_wiki_page_target_url(event)
title = event.target_title
html = [
"<span class=\"event-target-type append-right-4\">wiki page</span>",
"<a title=\"#{title}\" class=\"has-tooltip event-target-link append-right-4\" href=\"#{url}\">",
title,
"</a>"
].join
expect(helper.event_wiki_title_html(event)).to eq(html)
end
end
describe '#event_note_target_url' do describe '#event_note_target_url' do
let(:project) { create(:project, :public, :repository) } let(:project) { create(:project, :public, :repository) }
let(:event) { create(:event, project: project) } let(:event) { create(:event, project: project) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment