-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Pagination component implemented
- Loading branch information
1 parent
200792a
commit ab41e36
Showing
5 changed files
with
143 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 27 additions & 42 deletions
69
splunk_add_on_ucc_framework/ucc_ui_lib/src/main/webapp/pages/entry_page.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,51 @@ | ||
import React from 'react'; | ||
import layout from '@splunk/react-page'; | ||
import { SplunkThemeProvider } from '@splunk/themes'; | ||
import { defaultTheme } from '@splunk/splunk-utils/themes'; | ||
|
||
import { StyledContainer } from './EntryPageStyle'; | ||
import { StyledContainer, ThemeProviderSettings } from './EntryPageStyle'; | ||
import ConfigManager from '../util/configManager'; | ||
import InputPage from './Input/InputPage'; | ||
import ConfigurationPage from './Configuration/ConfigurationPage'; | ||
import { InputRowContextProvider } from '../context/InputRowContext'; | ||
|
||
const defaultThemeSplunkThemeProviderMap = { | ||
enterprise: { | ||
family: 'enterprise', | ||
colorScheme: 'light', | ||
density: 'comfortable', | ||
}, | ||
enterpriseDark: { | ||
family: 'enterprise', | ||
colorScheme: 'dark', | ||
density: 'comfortable', | ||
}, | ||
lite: { | ||
family: 'enterprise', | ||
colorScheme: 'light', | ||
density: 'comfortable', | ||
}, | ||
// Take in a component as argument WrappedComponent | ||
function higherOrderComponent(WrappedComponent) { | ||
// And return another component | ||
// eslint-disable-next-line react/prefer-stateless-function | ||
class HOC extends React.Component { | ||
|
||
render() { | ||
return ( | ||
<SplunkThemeProvider {...ThemeProviderSettings}> | ||
<StyledContainer> | ||
<ConfigManager> | ||
{({ loading, appData }) => { | ||
return !loading && appData && <WrappedComponent {...this.props} /> | ||
}} | ||
</ConfigManager> | ||
</StyledContainer> | ||
</SplunkThemeProvider> | ||
) | ||
} | ||
} | ||
return HOC; | ||
}; | ||
|
||
const themeProviderSettings = | ||
defaultThemeSplunkThemeProviderMap[defaultTheme()] || | ||
defaultThemeSplunkThemeProviderMap.enterprise; | ||
// Create a new component | ||
const InputPageComponent = higherOrderComponent(InputPage); | ||
const ConfigurationPageComponent = higherOrderComponent(ConfigurationPage); | ||
|
||
const url = window.location.pathname; | ||
const urlParts = url.substring(1).split('/'); | ||
const page = urlParts[urlParts.length - 1]; | ||
|
||
if (page === 'inputs') { | ||
layout( | ||
<InputRowContextProvider value={null}> | ||
<SplunkThemeProvider {...themeProviderSettings}> | ||
<StyledContainer> | ||
<ConfigManager> | ||
{({ loading, appData }) => { | ||
return !loading && appData && <InputPage isInput serviceName="" /> | ||
}} | ||
</ConfigManager> | ||
</StyledContainer> | ||
</SplunkThemeProvider> | ||
</InputRowContextProvider>, | ||
<InputPageComponent isInput serviceName="" />, | ||
{ pageTitle: 'Inputs' } | ||
); | ||
} else if (page === 'configuration') { | ||
layout( | ||
<SplunkThemeProvider {...themeProviderSettings}> | ||
<StyledContainer> | ||
<ConfigManager> | ||
{({ loading, appData }) => { | ||
return !loading && appData && <ConfigurationPage /> | ||
}} | ||
</ConfigManager> | ||
</StyledContainer> | ||
</SplunkThemeProvider>, | ||
<ConfigurationPageComponent />, | ||
{ pageTitle: 'Configuration' } | ||
); | ||
} |