Skip to content

Commit

Permalink
ADDON-34283: ucc_ui_lib: updated configs and structure to have single…
Browse files Browse the repository at this point in the history
… entry point js and template file
  • Loading branch information
harshpatel-crest committed Mar 2, 2021
1 parent 6328fdf commit e04d1db
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 146 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>${_('Inputs')}</title>
<title>${_('Loading')}</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="apple-touch-icon" href="apple-touch-icon.png">
</head>
Expand All @@ -22,7 +22,7 @@
</script>

<%
page_path = "/static/app/" + app_name + "/js/build/" + page + ".js"
page_path = "/static/app/" + app_name + "/js/build/entry_page.js"
%>

<script src="${make_url(page_path)}"></script>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<view template="${package.name}:/templates/configuration.html" type="html" isDashboard="False">
<view template="${package.name}:/templates/base.html" type="html" isDashboard="False">
<label>Configuration</label>
</view>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<view template="${package.name}:/templates/inputs.html" type="html" isDashboard="False">
<view template="${package.name}:/templates/base.html" type="html" isDashboard="False">
<label>Inputs</label>
</view>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import React from 'react';

import layout from '@splunk/react-page';
import { SplunkThemeProvider } from '@splunk/themes';

import { defaultTheme } from '@splunk/splunk-utils/themes';

import TestComponent from '../components/TestComponent';
import { StyledContainer, StyledGreeting } from './StartStyles';

const defaultThemeSplunkThemeProviderMap = {
enterprise: {
family: 'enterprise',
colorScheme: 'light',
density: 'comfortable',
},
enterpriseDark: {
family: 'enterprise',
colorScheme: 'dark',
density: 'comfortable',
},
lite: {
family: 'enterprise',
colorScheme: 'light',
density: 'comfortable',
},
};

const themeProviderSettings =
defaultThemeSplunkThemeProviderMap[defaultTheme()] ||
defaultThemeSplunkThemeProviderMap.enterprise;

const url = window.location.pathname;
const urlParts = url.substring(1).split('/');
const page = urlParts[urlParts.length - 1];

if (page === 'inputs') {
layout(
<SplunkThemeProvider {...themeProviderSettings}>
<StyledContainer>
<StyledGreeting>Hello, from inside Inputs!</StyledGreeting>
<div>Your component will appear below.</div>
<TestComponent name="from inside TestComponent" />
</StyledContainer>
</SplunkThemeProvider>,
{ pageTitle: 'Inputs' }
);
} else if (page === 'configuration') {
layout(
<SplunkThemeProvider {...themeProviderSettings}>
<StyledContainer>
<StyledGreeting>Hello, from inside Configuration!</StyledGreeting>
<div>Your component will appear below.</div>
<TestComponent name="from inside TestComponent" />
</StyledContainer>
</SplunkThemeProvider>,
{ pageTitle: 'Configuration' }
);
}

This file was deleted.

This file was deleted.

13 changes: 2 additions & 11 deletions splunk_add_on_ucc_framework/ucc_ui_lib/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,11 @@ const CopyWebpackPlugin = require('copy-webpack-plugin');
const webpackMerge = require('webpack-merge');
const baseConfig = require('@splunk/webpack-configs/base.config').default;

// Set up an entry config by iterating over the files in the pages directory.
const entries = fs
.readdirSync(path.join(__dirname, 'src/main/webapp/pages'))
.filter((pageFile) => !/^\./.test(pageFile))
.reduce((accum, page) => {
accum[page] = path.join(__dirname, 'src/main/webapp/pages', page);
return accum;
}, {});

module.exports = webpackMerge(baseConfig, {
entry: entries,
entry: path.join(__dirname, 'src/main/webapp/pages/entry_page'),
output: {
path: path.join(__dirname, 'stage/appserver/static/js/build'),
filename: '[name].js',
filename: 'entry_page.js',
},
plugins: [
new CopyWebpackPlugin([
Expand Down

0 comments on commit e04d1db

Please sign in to comment.