summaryrefslogtreecommitdiff
path: root/app/assets
diff options
context:
space:
mode:
authorHeinrich Lee Yu <heinrich@gitlab.com>2019-08-07 15:45:23 +0000
committerClement Ho <408677-ClemMakesApps@users.noreply.gitlab.com>2019-08-07 15:45:23 +0000
commitb689ddd9b6d7ebed2f4d014a77ee223df2d3491b (patch)
treec8b0d42bb5d7ab104f7727ef9462b1ec8c96f362 /app/assets
parentaf2edf28259ff1c236af346cfa6c62092afe7391 (diff)
downloadgitlab-ce-b689ddd9b6d7ebed2f4d014a77ee223df2d3491b.tar.gz
Do not persist notes filter when auto-switching
Send a `persist_filter: false` param to backend when opening links to notes and auto-switching to show all notes
Diffstat (limited to 'app/assets')
-rw-r--r--app/assets/javascripts/notes/components/discussion_filter.vue10
-rw-r--r--app/assets/javascripts/notes/services/notes_service.js7
-rw-r--r--app/assets/javascripts/notes/stores/actions.js8
3 files changed, 16 insertions, 9 deletions
diff --git a/app/assets/javascripts/notes/components/discussion_filter.vue b/app/assets/javascripts/notes/components/discussion_filter.vue
index eb3fbbe1385..743684e7046 100644
--- a/app/assets/javascripts/notes/components/discussion_filter.vue
+++ b/app/assets/javascripts/notes/components/discussion_filter.vue
@@ -61,7 +61,7 @@ export default {
},
methods: {
...mapActions(['filterDiscussion', 'setCommentsDisabled', 'setTargetNoteHash']),
- selectFilter(value) {
+ selectFilter(value, persistFilter = true) {
const filter = parseInt(value, 10);
// close dropdown
@@ -69,7 +69,11 @@ export default {
if (filter === this.currentValue) return;
this.currentValue = filter;
- this.filterDiscussion({ path: this.getNotesDataByProp('discussionsPath'), filter });
+ this.filterDiscussion({
+ path: this.getNotesDataByProp('discussionsPath'),
+ filter,
+ persistFilter,
+ });
this.toggleCommentsForm();
},
toggleDropdown() {
@@ -85,7 +89,7 @@ export default {
const hash = getLocationHash();
if (/^note_/.test(hash) && this.currentValue !== DISCUSSION_FILTERS_DEFAULT_VALUE) {
- this.selectFilter(this.defaultValue);
+ this.selectFilter(this.defaultValue, false);
this.toggleDropdown(); // close dropdown
this.setTargetNoteHash(hash);
}
diff --git a/app/assets/javascripts/notes/services/notes_service.js b/app/assets/javascripts/notes/services/notes_service.js
index 9e0392110b6..3d239d8cb6b 100644
--- a/app/assets/javascripts/notes/services/notes_service.js
+++ b/app/assets/javascripts/notes/services/notes_service.js
@@ -5,8 +5,11 @@ import * as constants from '../constants';
Vue.use(VueResource);
export default {
- fetchDiscussions(endpoint, filter) {
- const config = filter !== undefined ? { params: { notes_filter: filter } } : null;
+ fetchDiscussions(endpoint, filter, persistFilter = true) {
+ const config =
+ filter !== undefined
+ ? { params: { notes_filter: filter, persist_filter: persistFilter } }
+ : null;
return Vue.http.get(endpoint, config);
},
replyToDiscussion(endpoint, data) {
diff --git a/app/assets/javascripts/notes/stores/actions.js b/app/assets/javascripts/notes/stores/actions.js
index 762a87ce0ff..b7857997d42 100644
--- a/app/assets/javascripts/notes/stores/actions.js
+++ b/app/assets/javascripts/notes/stores/actions.js
@@ -46,9 +46,9 @@ export const setNotesFetchedState = ({ commit }, state) =>
export const toggleDiscussion = ({ commit }, data) => commit(types.TOGGLE_DISCUSSION, data);
-export const fetchDiscussions = ({ commit, dispatch }, { path, filter }) =>
+export const fetchDiscussions = ({ commit, dispatch }, { path, filter, persistFilter }) =>
service
- .fetchDiscussions(path, filter)
+ .fetchDiscussions(path, filter, persistFilter)
.then(res => res.json())
.then(discussions => {
commit(types.SET_INITIAL_DISCUSSIONS, discussions);
@@ -411,9 +411,9 @@ export const setLoadingState = ({ commit }, data) => {
commit(types.SET_NOTES_LOADING_STATE, data);
};
-export const filterDiscussion = ({ dispatch }, { path, filter }) => {
+export const filterDiscussion = ({ dispatch }, { path, filter, persistFilter }) => {
dispatch('setLoadingState', true);
- dispatch('fetchDiscussions', { path, filter })
+ dispatch('fetchDiscussions', { path, filter, persistFilter })
.then(() => {
dispatch('setLoadingState', false);
dispatch('setNotesFetchedState', true);