Commit 4ac99465 authored by Fatih Acet's avatar Fatih Acet

Merge branch '58883-fix-fetching-comments' into 'master'

Initialize discussionFilter after notesApp

Closes #58883

See merge request gitlab-org/gitlab-ce!26092
parents dfd09753 c307bd47
...@@ -22,7 +22,7 @@ export default { ...@@ -22,7 +22,7 @@ export default {
}, },
selectedValue: { selectedValue: {
type: Number, type: Number,
default: null, default: DISCUSSION_FILTERS_DEFAULT_VALUE,
required: false, required: false,
}, },
}, },
......
...@@ -6,12 +6,16 @@ export default store => { ...@@ -6,12 +6,16 @@ export default store => {
if (discussionFilterEl) { if (discussionFilterEl) {
const { defaultFilter, notesFilters } = discussionFilterEl.dataset; const { defaultFilter, notesFilters } = discussionFilterEl.dataset;
const selectedValue = defaultFilter ? parseInt(defaultFilter, 10) : null;
const filterValues = notesFilters ? JSON.parse(notesFilters) : {}; const filterValues = notesFilters ? JSON.parse(notesFilters) : {};
const filters = Object.keys(filterValues).map(entry => ({ const filters = Object.keys(filterValues).map(entry => ({
title: entry, title: entry,
value: filterValues[entry], value: filterValues[entry],
})); }));
const props = { filters };
if (defaultFilter) {
props.selectedValue = parseInt(defaultFilter, 10);
}
return new Vue({ return new Vue({
el: discussionFilterEl, el: discussionFilterEl,
...@@ -21,12 +25,7 @@ export default store => { ...@@ -21,12 +25,7 @@ export default store => {
}, },
store, store,
render(createElement) { render(createElement) {
return createElement('discussion-filter', { return createElement('discussion-filter', { props });
props: {
filters,
selectedValue,
},
});
}, },
}); });
} }
......
...@@ -6,9 +6,8 @@ import createStore from './stores'; ...@@ -6,9 +6,8 @@ import createStore from './stores';
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
const store = createStore(); const store = createStore();
initDiscussionFilters(store); // eslint-disable-next-line no-new
new Vue({
return new Vue({
el: '#js-vue-notes', el: '#js-vue-notes',
components: { components: {
notesApp, notesApp,
...@@ -49,4 +48,6 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -49,4 +48,6 @@ document.addEventListener('DOMContentLoaded', () => {
}); });
}, },
}); });
initDiscussionFilters(store);
}); });
---
title: Fix error shown when loading links to specific comments
merge_request: 26092
author:
type: fixed
# frozen_string_literal: true
require 'spec_helper'
describe 'User opens link to comment', :js do
let(:project) { create(:project, :public) }
let(:note) { create(:note_on_issue, project: project) }
context 'authenticated user' do
let(:user) { create(:user) }
before do
sign_in(user)
end
it 'switches to all activity and does not show error message' do
create(:user_preference, user: user, issue_notes_filter: UserPreference::NOTES_FILTERS[:only_activity])
visit Gitlab::UrlBuilder.build(note)
expect(page.find('#discussion-filter-dropdown')).to have_content('Show all activity')
expect(page).not_to have_content('Something went wrong while fetching comments')
end
end
context 'anonymous user' do
it 'does not show error message' do
visit Gitlab::UrlBuilder.build(note)
expect(page).not_to have_content('Something went wrong while fetching comments')
end
end
end
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