Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions redisinsight/ui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
} from './components'
import { ThemeProvider } from './contexts/themeContext'
import MainComponent from './components/main/MainComponent'
import ThemeComponent from './components/theme/ThemeComponent'
import MonacoEnvironmentInitializer from './components/MonacoEnvironmentInitializer/MonacoEnvironmentInitializer'
import GlobalDialogs from './components/global-dialogs'
import NotFoundErrorPage from './pages/not-found-error/NotFoundErrorPage'
Expand Down Expand Up @@ -51,7 +50,6 @@ const App = ({ children }: { children?: ReactElement[] }) => {
}, [serverLoading])
return (
<div className="main-container">
<ThemeComponent />
<MonacoEnvironmentInitializer />
<Switch>
<Route exact path={Pages.notFound} component={NotFoundErrorPage} />
Expand Down
10 changes: 0 additions & 10 deletions redisinsight/ui/src/components/theme/ThemeComponent.spec.tsx

This file was deleted.

34 changes: 0 additions & 34 deletions redisinsight/ui/src/components/theme/ThemeComponent.tsx

This file was deleted.

12 changes: 10 additions & 2 deletions redisinsight/ui/src/contexts/themeContext.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import React, { useContext } from 'react'
import { ThemeProvider as StyledThemeProvider } from 'styled-components'
import {
theme as redisUiOldTheme,
Expand Down Expand Up @@ -44,6 +44,10 @@
},
}

export const isValidTheme = (theme: unknown): theme is Theme => {
return typeof theme === 'string' && THEME_NAMES.includes(theme as Theme)
}

export const ThemeContext = React.createContext(defaultState)

export class ThemeProvider extends React.Component<Props> {
Expand All @@ -57,7 +61,7 @@

if (queryTheme) {
theme = queryTheme
} else if (storedThemeValue && THEME_NAMES.includes(storedThemeValue)) {
} else if (storedThemeValue && isValidTheme(storedThemeValue)) {
theme = storedThemeValue
}

Expand Down Expand Up @@ -120,5 +124,9 @@
)
}
}

export const useThemeContext = () => {
return useContext(ThemeContext)

Check warning on line 129 in redisinsight/ui/src/contexts/themeContext.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}

export default ThemeProvider
Loading