Refactor quicklaunch fallback to search widget suggestions setting
This commit is contained in:
parent
2729a3b03e
commit
ef25756534
@ -1,7 +1,6 @@
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useEffect, useState, useRef, useCallback, useContext } from "react";
|
import { useEffect, useState, useRef, useCallback, useContext } from "react";
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import useSWR from "swr";
|
|
||||||
|
|
||||||
import ResolvedIcon from "./resolvedicon";
|
import ResolvedIcon from "./resolvedicon";
|
||||||
|
|
||||||
@ -17,18 +16,11 @@ export default function QuickLaunch({
|
|||||||
}) {
|
}) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const { data: widgets } = useSWR("/api/widgets");
|
|
||||||
const searchWidget = Object.values(widgets).find((w) => w.type === "search");
|
|
||||||
|
|
||||||
const { settings } = useContext(SettingsContext);
|
const { settings } = useContext(SettingsContext);
|
||||||
const { searchDescriptions, hideVisitURL } = settings?.quicklaunch
|
const { searchDescriptions = false, hideVisitURL = false } = settings?.quicklaunch ?? {};
|
||||||
? settings.quicklaunch
|
const showSearchSuggestions = !!(
|
||||||
: {
|
settings?.quicklaunch?.showSearchSuggestions ?? searchProvider.showSearchSuggestions
|
||||||
searchDescriptions: false,
|
);
|
||||||
hideVisitURL: false,
|
|
||||||
};
|
|
||||||
const showSearchSuggestions =
|
|
||||||
settings?.quicklaunch?.showSearchSuggestions ?? searchWidget.options.showSearchSuggestions ?? false;
|
|
||||||
|
|
||||||
const searchField = useRef();
|
const searchField = useRef();
|
||||||
|
|
||||||
|
|||||||
@ -211,10 +211,7 @@ function Home({ initialSettings }) {
|
|||||||
// if search provider is a list, try to retrieve from localstorage, fall back to the first
|
// if search provider is a list, try to retrieve from localstorage, fall back to the first
|
||||||
searchProvider = getStoredProvider() ?? searchProviders[searchWidget.options.provider[0]];
|
searchProvider = getStoredProvider() ?? searchProviders[searchWidget.options.provider[0]];
|
||||||
} else if (searchWidget.options?.provider === "custom") {
|
} else if (searchWidget.options?.provider === "custom") {
|
||||||
searchProvider = {
|
searchProvider = searchWidget.options;
|
||||||
url: searchWidget.options.url,
|
|
||||||
suggestionUrl: searchWidget.options.suggestionUrl,
|
|
||||||
};
|
|
||||||
} else {
|
} else {
|
||||||
searchProvider = searchProviders[searchWidget.options?.provider];
|
searchProvider = searchProviders[searchWidget.options?.provider];
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user