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 {
},
selectedValue: {
type: Number,
default: null,
default: DISCUSSION_FILTERS_DEFAULT_VALUE,
required: false,
},
},
......
......@@ -6,12 +6,16 @@ export default store => {
if (discussionFilterEl) {
const { defaultFilter, notesFilters } = discussionFilterEl.dataset;
const selectedValue = defaultFilter ? parseInt(defaultFilter, 10) : null;
const filterValues = notesFilters ? JSON.parse(notesFilters) : {};
const filters = Object.keys(filterValues).map(entry => ({
title: entry,
value: filterValues[entry],
}));
const props = { filters };
if (defaultFilter) {
props.selectedValue = parseInt(defaultFilter, 10);
}
return new Vue({
el: discussionFilterEl,
......@@ -21,12 +25,7 @@ export default store => {
},
store,
render(createElement) {
return createElement('discussion-filter', {
props: {
filters,
selectedValue,
},
});
return createElement('discussion-filter', { props });
},
});
}
......
......@@ -6,9 +6,8 @@ import createStore from './stores';
document.addEventListener('DOMContentLoaded', () => {
const store = createStore();
initDiscussionFilters(store);
return new Vue({
// eslint-disable-next-line no-new
new Vue({
el: '#js-vue-notes',
components: {
notesApp,
......@@ -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