mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-11 07:55:52 +01:00
✨ Add migrator for search engine
This commit is contained in:
@@ -4,6 +4,7 @@ import { AppIntegrationType, AppType, IntegrationType } from '../../types/app';
|
|||||||
import { AreaType } from '../../types/area';
|
import { AreaType } from '../../types/area';
|
||||||
import { CategoryType } from '../../types/category';
|
import { CategoryType } from '../../types/category';
|
||||||
import { ConfigType } from '../../types/config';
|
import { ConfigType } from '../../types/config';
|
||||||
|
import { SearchEngineCommonSettingsType } from '../../types/settings';
|
||||||
import { IBitTorrent } from '../../widgets/bitTorrent/BitTorrentTile';
|
import { IBitTorrent } from '../../widgets/bitTorrent/BitTorrentTile';
|
||||||
import { ICalendarWidget } from '../../widgets/calendar/CalendarTile';
|
import { ICalendarWidget } from '../../widgets/calendar/CalendarTile';
|
||||||
import { IDashDotTile } from '../../widgets/dashDot/DashDotTile';
|
import { IDashDotTile } from '../../widgets/dashDot/DashDotTile';
|
||||||
@@ -25,13 +26,7 @@ export function migrateConfig(config: Config): ConfigType {
|
|||||||
apps: [],
|
apps: [],
|
||||||
settings: {
|
settings: {
|
||||||
common: {
|
common: {
|
||||||
searchEngine: {
|
searchEngine: migrateSearchEngine(config),
|
||||||
type: 'google',
|
|
||||||
properties: {
|
|
||||||
enabled: true,
|
|
||||||
openInNewTab: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
defaultConfig: 'default',
|
defaultConfig: 'default',
|
||||||
},
|
},
|
||||||
customization: {
|
customization: {
|
||||||
@@ -86,6 +81,44 @@ export function migrateConfig(config: Config): ConfigType {
|
|||||||
return newConfig;
|
return newConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const migrateSearchEngine = (config: Config): SearchEngineCommonSettingsType => {
|
||||||
|
switch (config.settings.searchUrl) {
|
||||||
|
case 'https://bing.com/search?q=':
|
||||||
|
return {
|
||||||
|
type: 'bing',
|
||||||
|
properties: {
|
||||||
|
enabled: true,
|
||||||
|
openInNewTab: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
case 'https://google.com/search?q=':
|
||||||
|
return {
|
||||||
|
type: 'google',
|
||||||
|
properties: {
|
||||||
|
enabled: true,
|
||||||
|
openInNewTab: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
case 'https://duckduckgo.com/?q=':
|
||||||
|
return {
|
||||||
|
type: 'duckDuckGo',
|
||||||
|
properties: {
|
||||||
|
enabled: true,
|
||||||
|
openInNewTab: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
default:
|
||||||
|
return {
|
||||||
|
type: 'custom',
|
||||||
|
properties: {
|
||||||
|
enabled: true,
|
||||||
|
openInNewTab: true,
|
||||||
|
template: config.settings.searchUrl,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const getConfigAndCreateIfNotExsists = (
|
const getConfigAndCreateIfNotExsists = (
|
||||||
config: ConfigType,
|
config: ConfigType,
|
||||||
categoryName: string
|
categoryName: string
|
||||||
|
|||||||
Reference in New Issue
Block a user