mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-10 07:25:48 +01:00
Merge branch 'gridstack' of https://github.com/manuel-rw/homarr into gridstack
This commit is contained in:
@@ -1,44 +0,0 @@
|
|||||||
import { Switch } from '@mantine/core';
|
|
||||||
import { useTranslation } from 'next-i18next';
|
|
||||||
import { useState } from 'react';
|
|
||||||
import { useConfigContext } from '../../../config/provider';
|
|
||||||
import { useConfigStore } from '../../../config/store';
|
|
||||||
import { SearchEngineCommonSettingsType } from '../../../types/settings';
|
|
||||||
|
|
||||||
interface SearchEnabledSwitchProps {
|
|
||||||
defaultValue: boolean | undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function SearchEnabledSwitch({ defaultValue }: SearchEnabledSwitchProps) {
|
|
||||||
const { t } = useTranslation('settings/general/search-engine');
|
|
||||||
const { name: configName } = useConfigContext();
|
|
||||||
const updateConfig = useConfigStore((x) => x.updateConfig);
|
|
||||||
|
|
||||||
const [enabled, setEnabled] = useState<boolean>(defaultValue ?? true);
|
|
||||||
|
|
||||||
if (!configName) return null;
|
|
||||||
|
|
||||||
const toggleEnabled = () => {
|
|
||||||
setEnabled(!enabled);
|
|
||||||
updateConfig(configName, (prev) => ({
|
|
||||||
...prev,
|
|
||||||
settings: {
|
|
||||||
...prev.settings,
|
|
||||||
common: {
|
|
||||||
...prev.settings.common,
|
|
||||||
searchEngine: {
|
|
||||||
...prev.settings.common.searchEngine,
|
|
||||||
properties: {
|
|
||||||
...prev.settings.common.searchEngine.properties,
|
|
||||||
enabled: !enabled,
|
|
||||||
},
|
|
||||||
} as SearchEngineCommonSettingsType,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Switch checked={enabled} onChange={toggleEnabled} size="md" label={t('searchEnabled.label')} />
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Alert, Paper, SegmentedControl, Stack, TextInput, Title } from '@mantine/core';
|
import { Alert, Paper, SegmentedControl, Space, Stack, TextInput, Title } from '@mantine/core';
|
||||||
import { IconInfoCircle } from '@tabler/icons';
|
import { IconInfoCircle } from '@tabler/icons';
|
||||||
import { useTranslation } from 'next-i18next';
|
import { useTranslation } from 'next-i18next';
|
||||||
import { ChangeEventHandler, useState } from 'react';
|
import { ChangeEventHandler, useState } from 'react';
|
||||||
@@ -9,12 +9,12 @@ import {
|
|||||||
SearchEngineCommonSettingsType,
|
SearchEngineCommonSettingsType,
|
||||||
} from '../../../types/settings';
|
} from '../../../types/settings';
|
||||||
import Tip from '../../layout/Tip';
|
import Tip from '../../layout/Tip';
|
||||||
|
import { SearchNewTabSwitch } from './SearchNewTabSwitch';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
searchEngine: SearchEngineCommonSettingsType;
|
searchEngine: SearchEngineCommonSettingsType;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: discuss with @manuel-rw the design of the search engine
|
|
||||||
export const SearchEngineSelector = ({ searchEngine }: Props) => {
|
export const SearchEngineSelector = ({ searchEngine }: Props) => {
|
||||||
const { t } = useTranslation(['settings/general/search-engine']);
|
const { t } = useTranslation(['settings/general/search-engine']);
|
||||||
const { updateSearchEngineConfig } = useUpdateSearchEngineConfig();
|
const { updateSearchEngineConfig } = useUpdateSearchEngineConfig();
|
||||||
@@ -49,18 +49,26 @@ export const SearchEngineSelector = ({ searchEngine }: Props) => {
|
|||||||
onChange={onEngineChange}
|
onChange={onEngineChange}
|
||||||
data={searchEngineOptions}
|
data={searchEngineOptions}
|
||||||
/>
|
/>
|
||||||
{engine === 'custom' && (
|
<Paper p="md" py="sm" mb="md" withBorder>
|
||||||
<Paper p="md" py="sm" mb="xs" withBorder>
|
<Title order={6} mb={0}>
|
||||||
<Title order={6}>{t('customEngine.title')}</Title>
|
Search engine configuration
|
||||||
<Tip>{t('tips.placeholderTip')}</Tip>
|
</Title>
|
||||||
<TextInput
|
|
||||||
label={t('customEngine.label')}
|
<SearchNewTabSwitch defaultValue={searchEngine.properties.openInNewTab} />
|
||||||
placeholder={t('customEngine.placeholder')}
|
|
||||||
value={searchUrl}
|
{engine === 'custom' && (
|
||||||
onChange={onSearchUrlChange}
|
<>
|
||||||
/>
|
<Space mb="md" />
|
||||||
</Paper>
|
<TextInput
|
||||||
)}
|
label={t('customEngine.label')}
|
||||||
|
description={t('tips.placeholderTip')}
|
||||||
|
placeholder={t('customEngine.placeholder')}
|
||||||
|
value={searchUrl}
|
||||||
|
onChange={onSearchUrlChange}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</Paper>
|
||||||
<Alert icon={<IconInfoCircle />} color="blue">
|
<Alert icon={<IconInfoCircle />} color="blue">
|
||||||
{t('tips.generalTip')}
|
{t('tips.generalTip')}
|
||||||
</Alert>
|
</Alert>
|
||||||
@@ -87,10 +95,11 @@ const useUpdateSearchEngineConfig = () => {
|
|||||||
const { name: configName } = useConfigContext();
|
const { name: configName } = useConfigContext();
|
||||||
const updateConfig = useConfigStore((x) => x.updateConfig);
|
const updateConfig = useConfigStore((x) => x.updateConfig);
|
||||||
|
|
||||||
if (!configName)
|
if (!configName) {
|
||||||
return {
|
return {
|
||||||
updateSearchEngineConfig: () => {},
|
updateSearchEngineConfig: () => {},
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const updateSearchEngineConfig = (engine: EngineType, searchUrl: string) => {
|
const updateSearchEngineConfig = (engine: EngineType, searchUrl: string) => {
|
||||||
updateConfig(configName, (prev) => ({
|
updateConfig(configName, (prev) => ({
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ export function SearchNewTabSwitch({ defaultValue }: SearchNewTabSwitchProps) {
|
|||||||
<Switch
|
<Switch
|
||||||
checked={openInNewTab}
|
checked={openInNewTab}
|
||||||
onChange={toggleOpenInNewTab}
|
onChange={toggleOpenInNewTab}
|
||||||
size="md"
|
|
||||||
label={t('searchNewTab.label')}
|
label={t('searchNewTab.label')}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import { useConfigContext } from '../../config/provider';
|
|||||||
import ConfigChanger from '../Config/ConfigChanger';
|
import ConfigChanger from '../Config/ConfigChanger';
|
||||||
import ConfigActions from './Common/ConfigActions';
|
import ConfigActions from './Common/ConfigActions';
|
||||||
import LanguageSelect from './Common/LanguageSelect';
|
import LanguageSelect from './Common/LanguageSelect';
|
||||||
import { SearchEnabledSwitch } from './Common/SearchEngineEnabledSwitch';
|
|
||||||
import { SearchEngineSelector } from './Common/SearchEngineSelector';
|
import { SearchEngineSelector } from './Common/SearchEngineSelector';
|
||||||
import { SearchNewTabSwitch } from './Common/SearchNewTabSwitch';
|
import { SearchNewTabSwitch } from './Common/SearchNewTabSwitch';
|
||||||
|
|
||||||
@@ -21,10 +20,6 @@ export default function CommonSettings() {
|
|||||||
return (
|
return (
|
||||||
<Stack mb="md" mr="sm">
|
<Stack mb="md" mr="sm">
|
||||||
<SearchEngineSelector searchEngine={config.settings.common.searchEngine} />
|
<SearchEngineSelector searchEngine={config.settings.common.searchEngine} />
|
||||||
<SearchNewTabSwitch
|
|
||||||
defaultValue={config.settings.common.searchEngine.properties.openInNewTab}
|
|
||||||
/>
|
|
||||||
<SearchEnabledSwitch defaultValue={config.settings.common.searchEngine.properties.enabled} />
|
|
||||||
<Space />
|
<Space />
|
||||||
<LanguageSelect />
|
<LanguageSelect />
|
||||||
<ConfigChanger />
|
<ConfigChanger />
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ export function Search() {
|
|||||||
const [debounced, cancel] = useDebouncedValue(searchQuery, 250);
|
const [debounced, cancel] = useDebouncedValue(searchQuery, 250);
|
||||||
|
|
||||||
// TODO: ask manuel-rw about overseerr
|
// TODO: ask manuel-rw about overseerr
|
||||||
|
// Answer: We can simply check if there is a service of the type overseer and display results if there is one.
|
||||||
|
// Overseerr is not use anywhere else, so it makes no sense to add a standalone toggle for displaying results
|
||||||
const isOverseerrEnabled = false; //config?.settings.common.enabledModules.overseerr;
|
const isOverseerrEnabled = false; //config?.settings.common.enabledModules.overseerr;
|
||||||
const overseerrService = config?.services.find(
|
const overseerrService = config?.services.find(
|
||||||
(service) =>
|
(service) =>
|
||||||
|
|||||||
Reference in New Issue
Block a user