From 1f5912c232ffa4318261d92a1d1ea914341ed343 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Tue, 31 Jan 2023 00:33:30 -0800 Subject: [PATCH] Support custom search in quicklaunch web search --- public/locales/en/common.json | 3 ++- src/components/quicklaunch.jsx | 2 +- src/pages/index.jsx | 8 +++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/public/locales/en/common.json b/public/locales/en/common.json index fda372722..52db2cb40 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -283,7 +283,8 @@ "quicklaunch": { "bookmark": "Bookmark", "service": "Service", - "search": "Search" + "search": "Search", + "custom": "Custom" }, "wmo": { "0-day": "Sunny", diff --git a/src/components/quicklaunch.jsx b/src/components/quicklaunch.jsx index 877b98e54..cc19aaf94 100644 --- a/src/components/quicklaunch.jsx +++ b/src/components/quicklaunch.jsx @@ -80,7 +80,7 @@ export default function QuickLaunch({servicesAndBookmarks, searchString, setSear newResults.push( { href: searchProvider.url + encodeURIComponent(searchString), - name: `${searchProvider.name} ${t("quicklaunch.search")} `, + name: `${searchProvider.name ?? t("quicklaunch.custom")} ${t("quicklaunch.search")} `, type: 'search', } ) diff --git a/src/pages/index.jsx b/src/pages/index.jsx index 7db02ef44..22b10248a 100644 --- a/src/pages/index.jsx +++ b/src/pages/index.jsx @@ -197,7 +197,13 @@ function Home({ initialSettings }) { let searchProvider = null; const searchWidget = Object.values(widgets).find(w => w.type === "search"); if (searchWidget) { - searchProvider = searchProviders[searchWidget.options?.provider]; + if (searchWidget.options?.provider === 'custom') { + searchProvider = { + url: searchWidget.options.url + } + } else { + searchProvider = searchProviders[searchWidget.options?.provider]; + } } useEffect(() => {