From 05b6992dd48adcf11ba0486c9083dc78362ce52b Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Mon, 19 Oct 2020 19:06:31 +0300 Subject: [PATCH] Add actor_type filter --- src/api/users.js | 8 ++++---- src/store/modules/users.js | 12 ++++++++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/api/users.js b/src/api/users.js index 1d9c5551..7b275e18 100644 --- a/src/api/users.js +++ b/src/api/users.js @@ -110,10 +110,10 @@ export async function fetchUser(id, authHost, token) { }) } -export async function fetchUsers(filters, authHost, token, page = 1) { +export async function fetchUsers(filters, actorTypeFilters, authHost, token, page = 1) { return await request({ baseURL: baseName(authHost), - url: `/api/pleroma/admin/users?page=${page}&filters=${filters}`, + url: `/api/pleroma/admin/users?page=${page}&filters=${filters}&actor_types=${actorTypeFilters}`, method: 'get', headers: authHeaders(token) }) @@ -175,10 +175,10 @@ export async function resendConfirmationEmail(nicknames, authHost, token) { }) } -export async function searchUsers(query, filters, authHost, token, page = 1) { +export async function searchUsers(query, filters, actorTypeFilters, authHost, token, page = 1) { return await request({ baseURL: baseName(authHost), - url: `/api/pleroma/admin/users?query=${query}&page=${page}&filters=${filters}`, + url: `/api/pleroma/admin/users?query=${query}&page=${page}&filters=${filters}&actor_types=${actorTypeFilters}`, method: 'get', headers: authHeaders(token) }) diff --git a/src/store/modules/users.js b/src/store/modules/users.js index 5e1fff1a..6b93fb2a 100644 --- a/src/store/modules/users.js +++ b/src/store/modules/users.js @@ -31,6 +31,7 @@ const users = { totalUsersCount: 0, currentPage: 1, pageSize: 50, + actorTypeFilters: [], filters: { local: false, external: false, @@ -46,6 +47,9 @@ const users = { tags: [] }, mutations: { + SET_ACTOR_TYPE_FILTERS: (state, actorTypeFilters) => { + state.actorTypeFilters = actorTypeFilters + }, SET_USERS: (state, users) => { state.fetchedUsers = users }, @@ -248,7 +252,7 @@ const users = { async FetchUsers({ commit, dispatch, getters, state }, { page }) { commit('SET_LOADING', true) const filters = Object.keys(state.filters).filter(filter => state.filters[filter]).join() - const response = await fetchUsers(filters, getters.authHost, getters.token, page) + const response = await fetchUsers(filters, state.actorTypeFilters, getters.authHost, getters.token, page) await dispatch('GetNodeInfo') loadUsers(commit, page, response.data) }, @@ -299,7 +303,7 @@ const users = { commit('SET_SEARCH_QUERY', query) const filters = Object.keys(state.filters).filter(filter => state.filters[filter]).join() - const response = await searchUsers(query, filters, getters.authHost, getters.token, page) + const response = await searchUsers(query, filters, state.actorTypeFilters, getters.authHost, getters.token, page) loadUsers(commit, page, response.data) } @@ -310,6 +314,10 @@ const users = { duration: 5 * 1000 }) }, + async ToggleActorTypeFilter({ commit, dispatch, state }, actorTypeFilters) { + commit('SET_ACTOR_TYPE_FILTERS', actorTypeFilters) + dispatch('SearchUsers', { query: state.searchQuery, page: 1 }) + }, async ToggleUsersFilter({ commit, dispatch, state }, filters) { const defaultFilters = { local: false,