2019-07-10 08:06:19 -04:00
|
|
|
import { DEFAULT_THEME_NAME, DEFAULT_USER_THEME_NAME } from '../../initializers/constants'
|
2019-07-09 05:45:19 -04:00
|
|
|
import { PluginManager } from './plugin-manager'
|
|
|
|
import { CONFIG } from '../../initializers/config'
|
|
|
|
|
2019-07-10 08:06:19 -04:00
|
|
|
function getThemeOrDefault (name: string, defaultTheme: string) {
|
2019-07-09 05:45:19 -04:00
|
|
|
if (isThemeRegistered(name)) return name
|
|
|
|
|
|
|
|
// Fallback to admin default theme
|
2019-07-10 08:06:19 -04:00
|
|
|
if (name !== CONFIG.THEME.DEFAULT) return getThemeOrDefault(CONFIG.THEME.DEFAULT, DEFAULT_THEME_NAME)
|
2019-07-09 05:45:19 -04:00
|
|
|
|
2019-07-10 08:06:19 -04:00
|
|
|
return defaultTheme
|
2019-07-09 05:45:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function isThemeRegistered (name: string) {
|
2019-07-10 08:06:19 -04:00
|
|
|
if (name === DEFAULT_THEME_NAME || name === DEFAULT_USER_THEME_NAME) return true
|
2019-07-09 05:45:19 -04:00
|
|
|
|
|
|
|
return !!PluginManager.Instance.getRegisteredThemes()
|
|
|
|
.find(r => r.name === name)
|
|
|
|
}
|
|
|
|
|
|
|
|
export {
|
|
|
|
getThemeOrDefault,
|
|
|
|
isThemeRegistered
|
|
|
|
}
|