From 4df74315758b71d8eacfc8fd76509e36f69874e0 Mon Sep 17 00:00:00 2001 From: megala21 Date: Mon, 11 Sep 2017 13:06:05 +0530 Subject: [PATCH] Refactoring --- .../src/main/resources/publisher/src/App.jsx | 23 +++++++++++-------- .../main/resources/publisher/src/config.json | 2 +- .../publisher/src/themes/custom-theme.js | 2 +- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.jsx b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.jsx index c76c69af13e..6ba02176e57 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.jsx +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.jsx @@ -33,6 +33,19 @@ import { } from './components'; const history = createHistory({basename: '/publisher'}); +/** + * User can define the themes in the config.json. The themes will be loaded based on the user preference. + */ +const theme = require("./config.json").theme; +let muiTheme = null; +if (theme.current === "default") { + let defaultTheme = require("material-ui/styles/baseThemes/" + theme.default); + muiTheme = getMuiTheme(defaultTheme.default); +} else { + let customTheme = require("./themes/" + theme.custom); + muiTheme = getMuiTheme(customTheme.default); +} + /** * This component defines the layout and the routes for the app. * All the content will be loaded inside the Base component. @@ -46,16 +59,6 @@ const history = createHistory({basename: '/publisher'}); * HashRouter is used because the other router types need the server to serve those urls. In hashRouter, server does * not want to serve the URL. * */ -const theme = require("./config.json").theme; -let muiTheme = null; -if (theme.current === "default") { - let defaultTheme = require("material-ui/styles/baseThemes/" + theme.default); - muiTheme = getMuiTheme(defaultTheme.default); -} else { - let customTheme = require("./themes/" + theme.custom); - muiTheme = getMuiTheme(customTheme.default); -} - class Base extends Component { constructor() { super(); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/config.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/config.json index 62a1565130f..cb7ead56b15 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/config.json +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/config.json @@ -4,4 +4,4 @@ "default" : "lightBaseTheme", "custom" : "custom-theme" } -} \ No newline at end of file +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/themes/custom-theme.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/themes/custom-theme.js index 6664416c93c..8342d4da36d 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/themes/custom-theme.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/themes/custom-theme.js @@ -9,4 +9,4 @@ export default { accent1Color: redA200, pickerHeaderColor: indigo500, }, -}; \ No newline at end of file +};