Features: Add searching by URL in quick launch
This commit is contained in:
parent
94bbcbe1fb
commit
5c7f14cbdc
@ -378,6 +378,7 @@ You can use the 'Quick Launch' feature to search services, perform a web search
|
|||||||
There are a few optional settings for the Quick Launch feature:
|
There are a few optional settings for the Quick Launch feature:
|
||||||
|
|
||||||
- `searchDescriptions`: which lets you control whether item descriptions are included in searches. This is false by default. When enabled, results that match the item name will be placed above those that only match the description.
|
- `searchDescriptions`: which lets you control whether item descriptions are included in searches. This is false by default. When enabled, results that match the item name will be placed above those that only match the description.
|
||||||
|
- `searchUrls`: which lets you control whether item URLs are included in searches. This is false by default. When enabled, results that match the item name will be placed above those that only match URLs. When used with `searchDescriptions`, items which match descriptions will show higher than those that match only URLs.
|
||||||
- `hideInternetSearch`: disable automatically including the currently-selected web search (e.g. from the widget) as a Quick Launch option. This is false by default, enabling the feature.
|
- `hideInternetSearch`: disable automatically including the currently-selected web search (e.g. from the widget) as a Quick Launch option. This is false by default, enabling the feature.
|
||||||
- `showSearchSuggestions`: show search suggestions for the internet search. If this is not specified then the setting will be inherited from the search widget. If it is not specified there either, it will default to false. For custom providers the `suggestionUrl` needs to be set in order for this to work.
|
- `showSearchSuggestions`: show search suggestions for the internet search. If this is not specified then the setting will be inherited from the search widget. If it is not specified there either, it will default to false. For custom providers the `suggestionUrl` needs to be set in order for this to work.
|
||||||
- `provider`: search engine provider. If none is specified it will try to use the provider set for the Search Widget, if neither are present then internet search will be disabled.
|
- `provider`: search engine provider. If none is specified it will try to use the provider set for the Search Widget, if neither are present then internet search will be disabled.
|
||||||
@ -386,6 +387,7 @@ There are a few optional settings for the Quick Launch feature:
|
|||||||
```yaml
|
```yaml
|
||||||
quicklaunch:
|
quicklaunch:
|
||||||
searchDescriptions: true
|
searchDescriptions: true
|
||||||
|
searchUrls: true
|
||||||
hideInternetSearch: true
|
hideInternetSearch: true
|
||||||
showSearchSuggestions: true
|
showSearchSuggestions: true
|
||||||
hideVisitURL: true
|
hideVisitURL: true
|
||||||
|
|||||||
@ -12,7 +12,7 @@ export default function QuickLaunch({ servicesAndBookmarks, searchString, setSea
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const { settings } = useContext(SettingsContext);
|
const { settings } = useContext(SettingsContext);
|
||||||
const { searchDescriptions = false, hideVisitURL = false } = settings?.quicklaunch ?? {};
|
const { searchDescriptions = false, searchUrls = false, hideVisitURL = false } = settings?.quicklaunch ?? {};
|
||||||
|
|
||||||
const searchField = useRef();
|
const searchField = useRef();
|
||||||
|
|
||||||
@ -138,10 +138,15 @@ export default function QuickLaunch({ servicesAndBookmarks, searchString, setSea
|
|||||||
descriptionMatch = r.description?.toLowerCase().includes(searchString);
|
descriptionMatch = r.description?.toLowerCase().includes(searchString);
|
||||||
r.priority = nameMatch ? 2 * +nameMatch : +descriptionMatch; // eslint-disable-line no-param-reassign
|
r.priority = nameMatch ? 2 * +nameMatch : +descriptionMatch; // eslint-disable-line no-param-reassign
|
||||||
}
|
}
|
||||||
return nameMatch || descriptionMatch;
|
let urlMatch;
|
||||||
|
if (searchUrls) {
|
||||||
|
urlMatch = r.href?.toLowerCase().includes(searchString);
|
||||||
|
r.priority = nameMatch ? 3 * +nameMatch : descriptionMatch ? 2 * +descriptionMatch : +urlMatch;
|
||||||
|
}
|
||||||
|
return nameMatch || descriptionMatch || urlMatch;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (searchDescriptions) {
|
if (searchDescriptions || searchUrls) {
|
||||||
newResults = newResults.sort((a, b) => b.priority - a.priority);
|
newResults = newResults.sort((a, b) => b.priority - a.priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,7 +210,7 @@ export default function QuickLaunch({ servicesAndBookmarks, searchString, setSea
|
|||||||
return () => {
|
return () => {
|
||||||
abortController.abort();
|
abortController.abort();
|
||||||
};
|
};
|
||||||
}, [searchString, servicesAndBookmarks, searchDescriptions, hideVisitURL, searchSuggestions, searchProvider, url, t]);
|
}, [searchString, servicesAndBookmarks, searchDescriptions, searchUrls, hideVisitURL, searchSuggestions, searchProvider, url, t]);
|
||||||
|
|
||||||
const [hidden, setHidden] = useState(true);
|
const [hidden, setHidden] = useState(true);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user