From 0b171f60951f6fbf7ce0b666d72259a4325cf9e0 Mon Sep 17 00:00:00 2001 From: fenn-cs Date: Thu, 7 Dec 2023 13:20:59 +0100 Subject: Rename "global search" to "unified search" - Changes appearances of "Global search" to "Unified search" in UI - Refactors code, to remove usage of term "GlobalSearch" in files and code structure - Rename old unified search to `legacy-unified-search` Signed-off-by: fenn-cs --- .../GlobalSearch/CustomDateRangeModal.vue | 103 --- .../components/GlobalSearch/SearchFilterChip.vue | 75 -- core/src/components/GlobalSearch/SearchResult.vue | 169 ---- .../src/components/GlobalSearch/SearchableList.vue | 162 ---- .../UnifiedSearch/CustomDateRangeModal.vue | 103 +++ .../UnifiedSearch/LegacySearchResult.vue | 259 +++++++ .../components/UnifiedSearch/SearchFilterChip.vue | 75 ++ core/src/components/UnifiedSearch/SearchResult.vue | 286 +++---- .../components/UnifiedSearch/SearchableList.vue | 162 ++++ core/src/global-search.js | 55 -- core/src/legacy-unified-search.js | 55 ++ core/src/services/GlobalSearchService.js | 107 --- core/src/services/LegacyUnifiedSearchService.js | 96 +++ core/src/services/UnifiedSearchService.js | 43 +- core/src/unified-search.js | 4 +- core/src/views/GlobalSearch.vue | 96 --- core/src/views/GlobalSearchModal.vue | 612 --------------- core/src/views/LegacyUnifiedSearch.vue | 863 +++++++++++++++++++++ core/src/views/UnifiedSearch.vue | 853 +------------------- core/src/views/UnifiedSearchModal.vue | 611 +++++++++++++++ 20 files changed, 2394 insertions(+), 2395 deletions(-) delete mode 100644 core/src/components/GlobalSearch/CustomDateRangeModal.vue delete mode 100644 core/src/components/GlobalSearch/SearchFilterChip.vue delete mode 100644 core/src/components/GlobalSearch/SearchResult.vue delete mode 100644 core/src/components/GlobalSearch/SearchableList.vue create mode 100644 core/src/components/UnifiedSearch/CustomDateRangeModal.vue create mode 100644 core/src/components/UnifiedSearch/LegacySearchResult.vue create mode 100644 core/src/components/UnifiedSearch/SearchFilterChip.vue create mode 100644 core/src/components/UnifiedSearch/SearchableList.vue delete mode 100644 core/src/global-search.js create mode 100644 core/src/legacy-unified-search.js delete mode 100644 core/src/services/GlobalSearchService.js create mode 100644 core/src/services/LegacyUnifiedSearchService.js delete mode 100644 core/src/views/GlobalSearch.vue delete mode 100644 core/src/views/GlobalSearchModal.vue create mode 100644 core/src/views/LegacyUnifiedSearch.vue create mode 100644 core/src/views/UnifiedSearchModal.vue (limited to 'core/src') diff --git a/core/src/components/GlobalSearch/CustomDateRangeModal.vue b/core/src/components/GlobalSearch/CustomDateRangeModal.vue deleted file mode 100644 index 0ba6ddca015..00000000000 --- a/core/src/components/GlobalSearch/CustomDateRangeModal.vue +++ /dev/null @@ -1,103 +0,0 @@ - - - - - diff --git a/core/src/components/GlobalSearch/SearchFilterChip.vue b/core/src/components/GlobalSearch/SearchFilterChip.vue deleted file mode 100644 index 8342e9e256d..00000000000 --- a/core/src/components/GlobalSearch/SearchFilterChip.vue +++ /dev/null @@ -1,75 +0,0 @@ - - - - - diff --git a/core/src/components/GlobalSearch/SearchResult.vue b/core/src/components/GlobalSearch/SearchResult.vue deleted file mode 100644 index a746a5751b7..00000000000 --- a/core/src/components/GlobalSearch/SearchResult.vue +++ /dev/null @@ -1,169 +0,0 @@ - - - - - diff --git a/core/src/components/GlobalSearch/SearchableList.vue b/core/src/components/GlobalSearch/SearchableList.vue deleted file mode 100644 index 43f7ace1b64..00000000000 --- a/core/src/components/GlobalSearch/SearchableList.vue +++ /dev/null @@ -1,162 +0,0 @@ - - - - - - - diff --git a/core/src/components/UnifiedSearch/CustomDateRangeModal.vue b/core/src/components/UnifiedSearch/CustomDateRangeModal.vue new file mode 100644 index 00000000000..ec592732a8d --- /dev/null +++ b/core/src/components/UnifiedSearch/CustomDateRangeModal.vue @@ -0,0 +1,103 @@ + + + + + diff --git a/core/src/components/UnifiedSearch/LegacySearchResult.vue b/core/src/components/UnifiedSearch/LegacySearchResult.vue new file mode 100644 index 00000000000..01f48a36709 --- /dev/null +++ b/core/src/components/UnifiedSearch/LegacySearchResult.vue @@ -0,0 +1,259 @@ + + + + + + diff --git a/core/src/components/UnifiedSearch/SearchFilterChip.vue b/core/src/components/UnifiedSearch/SearchFilterChip.vue new file mode 100644 index 00000000000..8342e9e256d --- /dev/null +++ b/core/src/components/UnifiedSearch/SearchFilterChip.vue @@ -0,0 +1,75 @@ + + + + + diff --git a/core/src/components/UnifiedSearch/SearchResult.vue b/core/src/components/UnifiedSearch/SearchResult.vue index 03496fc5d92..a746a5751b7 100644 --- a/core/src/components/UnifiedSearch/SearchResult.vue +++ b/core/src/components/UnifiedSearch/SearchResult.vue @@ -1,73 +1,40 @@ - + + diff --git a/core/src/global-search.js b/core/src/global-search.js deleted file mode 100644 index f0c47fa1895..00000000000 --- a/core/src/global-search.js +++ /dev/null @@ -1,55 +0,0 @@ -/** - * @copyright Copyright (c) 2020 Fon E. Noel NFEBE - * - * @author Fon E. Noel NFEBE - * - * @license AGPL-3.0-or-later - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - */ - -import { getLoggerBuilder } from '@nextcloud/logger' -import { getRequestToken } from '@nextcloud/auth' -import { translate as t, translatePlural as n } from '@nextcloud/l10n' -import Vue from 'vue' - -import GlobalSearch from './views/GlobalSearch.vue' - -// eslint-disable-next-line camelcase -__webpack_nonce__ = btoa(getRequestToken()) - -const logger = getLoggerBuilder() - .setApp('global-search') - .detectUser() - .build() - -Vue.mixin({ - data() { - return { - logger, - } - }, - methods: { - t, - n, - }, -}) - -export default new Vue({ - el: '#global-search', - // eslint-disable-next-line vue/match-component-file-name - name: 'GlobalSearchRoot', - render: h => h(GlobalSearch), -}) diff --git a/core/src/legacy-unified-search.js b/core/src/legacy-unified-search.js new file mode 100644 index 00000000000..943081f3d23 --- /dev/null +++ b/core/src/legacy-unified-search.js @@ -0,0 +1,55 @@ +/** + * @copyright Copyright (c) 2020 John Molakvoæ + * + * @author John Molakvoæ + * + * @license AGPL-3.0-or-later + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +import { getLoggerBuilder } from '@nextcloud/logger' +import { getRequestToken } from '@nextcloud/auth' +import { translate as t, translatePlural as n } from '@nextcloud/l10n' +import Vue from 'vue' + +import UnifiedSearch from './views/LegacyUnifiedSearch.vue' + +// eslint-disable-next-line camelcase +__webpack_nonce__ = btoa(getRequestToken()) + +const logger = getLoggerBuilder() + .setApp('unified-search') + .detectUser() + .build() + +Vue.mixin({ + data() { + return { + logger, + } + }, + methods: { + t, + n, + }, +}) + +export default new Vue({ + el: '#unified-search', + // eslint-disable-next-line vue/match-component-file-name + name: 'UnifiedSearchRoot', + render: h => h(UnifiedSearch), +}) diff --git a/core/src/services/GlobalSearchService.js b/core/src/services/GlobalSearchService.js deleted file mode 100644 index e477a59eb4c..00000000000 --- a/core/src/services/GlobalSearchService.js +++ /dev/null @@ -1,107 +0,0 @@ -/** - * @copyright 2023, Fon E. Noel NFEBE - * - * @author Fon E. Noel NFEBE - * - * @license AGPL-3.0-or-later - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - */ - -import { generateOcsUrl, generateUrl } from '@nextcloud/router' -import axios from '@nextcloud/axios' - -/** - * Create a cancel token - * - * @return {import('axios').CancelTokenSource} - */ -const createCancelToken = () => axios.CancelToken.source() - -/** - * Get the list of available search providers - * - * @return {Promise} - */ -export async function getProviders() { - try { - const { data } = await axios.get(generateOcsUrl('search/providers'), { - params: { - // Sending which location we're currently at - from: window.location.pathname.replace('/index.php', '') + window.location.search, - }, - }) - if ('ocs' in data && 'data' in data.ocs && Array.isArray(data.ocs.data) && data.ocs.data.length > 0) { - // Providers are sorted by the api based on their order key - return data.ocs.data - } - } catch (error) { - console.error(error) - } - return [] -} - -/** - * Get the list of available search providers - * - * @param {object} options destructuring object - * @param {string} options.type the type to search - * @param {string} options.query the search - * @param {number|string|undefined} options.cursor the offset for paginated searches - * @param {string} options.since the search - * @param {string} options.until the search - * @param {string} options.limit the search - * @param {string} options.person the search - * @return {object} {request: Promise, cancel: Promise} - */ -export function search({ type, query, cursor, since, until, limit, person }) { - /** - * Generate an axios cancel token - */ - const cancelToken = createCancelToken() - - const request = async () => axios.get(generateOcsUrl('search/providers/{type}/search', { type }), { - cancelToken: cancelToken.token, - params: { - term: query, - cursor, - since, - until, - limit, - person, - // Sending which location we're currently at - from: window.location.pathname.replace('/index.php', '') + window.location.search, - }, - }) - - return { - request, - cancel: cancelToken.cancel, - } -} - -/** - * Get the list of active contacts - * - * @param {object} filter filter contacts by string - * @param filter.searchTerm - * @return {object} {request: Promise} - */ -export async function getContacts({ searchTerm }) { - const { data: { contacts } } = await axios.post(generateUrl('/contactsmenu/contacts'), { - filter: searchTerm, - }) - return contacts -} diff --git a/core/src/services/LegacyUnifiedSearchService.js b/core/src/services/LegacyUnifiedSearchService.js new file mode 100644 index 00000000000..3c673479771 --- /dev/null +++ b/core/src/services/LegacyUnifiedSearchService.js @@ -0,0 +1,96 @@ +/** + * @copyright 2020, John Molakvoæ + * + * @author Christoph Wurst + * @author Daniel Calviño Sánchez + * @author Joas Schilling + * @author John Molakvoæ + * + * @license AGPL-3.0-or-later + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +import { generateOcsUrl } from '@nextcloud/router' +import { loadState } from '@nextcloud/initial-state' +import axios from '@nextcloud/axios' + +export const defaultLimit = loadState('unified-search', 'limit-default') +export const minSearchLength = loadState('unified-search', 'min-search-length', 1) +export const enableLiveSearch = loadState('unified-search', 'live-search', true) + +export const regexFilterIn = /(^|\s)in:([a-z_-]+)/ig +export const regexFilterNot = /(^|\s)-in:([a-z_-]+)/ig + +/** + * Create a cancel token + * + * @return {import('axios').CancelTokenSource} + */ +const createCancelToken = () => axios.CancelToken.source() + +/** + * Get the list of available search providers + * + * @return {Promise} + */ +export async function getTypes() { + try { + const { data } = await axios.get(generateOcsUrl('search/providers'), { + params: { + // Sending which location we're currently at + from: window.location.pathname.replace('/index.php', '') + window.location.search, + }, + }) + if ('ocs' in data && 'data' in data.ocs && Array.isArray(data.ocs.data) && data.ocs.data.length > 0) { + // Providers are sorted by the api based on their order key + return data.ocs.data + } + } catch (error) { + console.error(error) + } + return [] +} + +/** + * Get the list of available search providers + * + * @param {object} options destructuring object + * @param {string} options.type the type to search + * @param {string} options.query the search + * @param {number|string|undefined} options.cursor the offset for paginated searches + * @return {object} {request: Promise, cancel: Promise} + */ +export function search({ type, query, cursor }) { + /** + * Generate an axios cancel token + */ + const cancelToken = createCancelToken() + + const request = async () => axios.get(generateOcsUrl('search/providers/{type}/search', { type }), { + cancelToken: cancelToken.token, + params: { + term: query, + cursor, + // Sending which location we're currently at + from: window.location.pathname.replace('/index.php', '') + window.location.search, + }, + }) + + return { + request, + cancel: cancelToken.cancel, + } +} diff --git a/core/src/services/UnifiedSearchService.js b/core/src/services/UnifiedSearchService.js index 3c673479771..e477a59eb4c 100644 --- a/core/src/services/UnifiedSearchService.js +++ b/core/src/services/UnifiedSearchService.js @@ -1,10 +1,7 @@ /** - * @copyright 2020, John Molakvoæ + * @copyright 2023, Fon E. Noel NFEBE * - * @author Christoph Wurst - * @author Daniel Calviño Sánchez - * @author Joas Schilling - * @author John Molakvoæ + * @author Fon E. Noel NFEBE * * @license AGPL-3.0-or-later * @@ -23,17 +20,9 @@ * */ -import { generateOcsUrl } from '@nextcloud/router' -import { loadState } from '@nextcloud/initial-state' +import { generateOcsUrl, generateUrl } from '@nextcloud/router' import axios from '@nextcloud/axios' -export const defaultLimit = loadState('unified-search', 'limit-default') -export const minSearchLength = loadState('unified-search', 'min-search-length', 1) -export const enableLiveSearch = loadState('unified-search', 'live-search', true) - -export const regexFilterIn = /(^|\s)in:([a-z_-]+)/ig -export const regexFilterNot = /(^|\s)-in:([a-z_-]+)/ig - /** * Create a cancel token * @@ -46,7 +35,7 @@ const createCancelToken = () => axios.CancelToken.source() * * @return {Promise} */ -export async function getTypes() { +export async function getProviders() { try { const { data } = await axios.get(generateOcsUrl('search/providers'), { params: { @@ -71,9 +60,13 @@ export async function getTypes() { * @param {string} options.type the type to search * @param {string} options.query the search * @param {number|string|undefined} options.cursor the offset for paginated searches + * @param {string} options.since the search + * @param {string} options.until the search + * @param {string} options.limit the search + * @param {string} options.person the search * @return {object} {request: Promise, cancel: Promise} */ -export function search({ type, query, cursor }) { +export function search({ type, query, cursor, since, until, limit, person }) { /** * Generate an axios cancel token */ @@ -84,6 +77,10 @@ export function search({ type, query, cursor }) { params: { term: query, cursor, + since, + until, + limit, + person, // Sending which location we're currently at from: window.location.pathname.replace('/index.php', '') + window.location.search, }, @@ -94,3 +91,17 @@ export function search({ type, query, cursor }) { cancel: cancelToken.cancel, } } + +/** + * Get the list of active contacts + * + * @param {object} filter filter contacts by string + * @param filter.searchTerm + * @return {object} {request: Promise} + */ +export async function getContacts({ searchTerm }) { + const { data: { contacts } } = await axios.post(generateUrl('/contactsmenu/contacts'), { + filter: searchTerm, + }) + return contacts +} diff --git a/core/src/unified-search.js b/core/src/unified-search.js index cc390c0d6e7..f9bddff4c68 100644 --- a/core/src/unified-search.js +++ b/core/src/unified-search.js @@ -1,7 +1,7 @@ /** - * @copyright Copyright (c) 2020 John Molakvoæ + * @copyright Copyright (c) 2020 Fon E. Noel NFEBE * - * @author John Molakvoæ + * @author Fon E. Noel NFEBE * * @license AGPL-3.0-or-later * diff --git a/core/src/views/GlobalSearch.vue b/core/src/views/GlobalSearch.vue deleted file mode 100644 index 09e2d4f725b..00000000000 --- a/core/src/views/GlobalSearch.vue +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - diff --git a/core/src/views/GlobalSearchModal.vue b/core/src/views/GlobalSearchModal.vue deleted file mode 100644 index 6d9920afaf7..00000000000 --- a/core/src/views/GlobalSearchModal.vue +++ /dev/null @@ -1,612 +0,0 @@ - - - - - diff --git a/core/src/views/LegacyUnifiedSearch.vue b/core/src/views/LegacyUnifiedSearch.vue new file mode 100644 index 00000000000..04e4c77fe39 --- /dev/null +++ b/core/src/views/LegacyUnifiedSearch.vue @@ -0,0 +1,863 @@ + + + + + + diff --git a/core/src/views/UnifiedSearch.vue b/core/src/views/UnifiedSearch.vue index 6bbaf8bca77..419c0b47c41 100644 --- a/core/src/views/UnifiedSearch.vue +++ b/core/src/views/UnifiedSearch.vue @@ -1,7 +1,7 @@ diff --git a/core/src/views/UnifiedSearchModal.vue b/core/src/views/UnifiedSearchModal.vue new file mode 100644 index 00000000000..ca314fa2673 --- /dev/null +++ b/core/src/views/UnifiedSearchModal.vue @@ -0,0 +1,611 @@ + + + + + -- cgit v1.2.3