From cdbdbf40cab05135e10a9bbb3e0753a5831b8e55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maren=20S=C3=BCwer?= Date: Mon, 2 Jul 2018 14:50:13 +0200 Subject: [PATCH] initial import for scm ui --- .hgignore | 3 +- scm-ui/package.json | 27 +++++++ scm-ui/public/favicon.ico | Bin 0 -> 3870 bytes scm-ui/public/index.html | 40 ++++++++++ scm-ui/public/manifest.json | 15 ++++ scm-ui/src/App.js | 20 +++++ scm-ui/src/Main.js | 36 +++++++++ scm-ui/src/Navigation.js | 52 +++++++++++++ scm-ui/src/containers/Page.js | 3 + scm-ui/src/createReduxStore.js | 22 ++++++ scm-ui/src/index.js | 32 ++++++++ scm-ui/src/modules/page.js | 3 + scm-ui/src/registerServiceWorker.js | 117 ++++++++++++++++++++++++++++ scm.iml | 16 ++++ 14 files changed, 385 insertions(+), 1 deletion(-) create mode 100644 scm-ui/package.json create mode 100644 scm-ui/public/favicon.ico create mode 100644 scm-ui/public/index.html create mode 100644 scm-ui/public/manifest.json create mode 100644 scm-ui/src/App.js create mode 100644 scm-ui/src/Main.js create mode 100644 scm-ui/src/Navigation.js create mode 100644 scm-ui/src/containers/Page.js create mode 100644 scm-ui/src/createReduxStore.js create mode 100644 scm-ui/src/index.js create mode 100644 scm-ui/src/modules/page.js create mode 100644 scm-ui/src/registerServiceWorker.js create mode 100644 scm.iml diff --git a/.hgignore b/.hgignore index 71fbaa8735..4e95a4bedc 100644 --- a/.hgignore +++ b/.hgignore @@ -30,7 +30,8 @@ Desktop DF$ rebel.xml \.pyc # ui -scm-ui/node_modules/ +scm-ui/node_modules scm-ui/yarn.lock scm-ui/.gitignore scm-ui/package-lock.json +node_modules diff --git a/scm-ui/package.json b/scm-ui/package.json new file mode 100644 index 0000000000..c56f88f9e1 --- /dev/null +++ b/scm-ui/package.json @@ -0,0 +1,27 @@ +{ + "name": "scm-ui", + "version": "0.1.0", + "private": true, + "dependencies": { + "ces-theme": "https://github.com/cloudogu/ces-theme.git", + "classnames": "^2.2.5", + "react": "^16.4.1", + "react-dom": "^16.4.1", + "react-jss": "^8.6.0", + "react-redux": "^5.0.7", + "react-scripts": "1.1.4", + "redux": "^4.0.0", + "redux-logger": "^3.0.6", + "redux-thunk": "^2.3.0", + "history": "^4.7.2", + "react-router-dom": "^4.3.1", + "react-router-redux": "^5.0.0-alpha.9", + "redux-devtools-extension": "^2.13.5" + }, + "scripts": { + "start": "react-scripts start", + "build": "react-scripts build", + "test": "react-scripts test --env=jsdom", + "eject": "react-scripts eject" + } +} diff --git a/scm-ui/public/favicon.ico b/scm-ui/public/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..a11777cc471a4344702741ab1c8a588998b1311a GIT binary patch literal 3870 zcma);c{J4h9>;%nil|2-o+rCuEF-(I%-F}ijC~o(k~HKAkr0)!FCj~d>`RtpD?8b; zXOC1OD!V*IsqUwzbMF1)-gEDD=A573Z-&G7^LoAC9|WO7Xc0Cx1g^Zu0u_SjAPB3vGa^W|sj)80f#V0@M_CAZTIO(t--xg= z!sii`1giyH7EKL_+Wi0ab<)&E_0KD!3Rp2^HNB*K2@PHCs4PWSA32*-^7d{9nH2_E zmC{C*N*)(vEF1_aMamw2A{ZH5aIDqiabnFdJ|y0%aS|64E$`s2ccV~3lR!u<){eS` z#^Mx6o(iP1Ix%4dv`t@!&Za-K@mTm#vadc{0aWDV*_%EiGK7qMC_(`exc>-$Gb9~W!w_^{*pYRm~G zBN{nA;cm^w$VWg1O^^<6vY`1XCD|s_zv*g*5&V#wv&s#h$xlUilPe4U@I&UXZbL z0)%9Uj&@yd03n;!7do+bfixH^FeZ-Ema}s;DQX2gY+7g0s(9;`8GyvPY1*vxiF&|w z>!vA~GA<~JUqH}d;DfBSi^IT*#lrzXl$fNpq0_T1tA+`A$1?(gLb?e#0>UELvljtQ zK+*74m0jn&)5yk8mLBv;=@}c{t0ztT<v;Avck$S6D`Z)^c0(jiwKhQsn|LDRY&w(Fmi91I7H6S;b0XM{e zXp0~(T@k_r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`0nz6N{T?(A&Iz)2!DEecLyRa&FI!id#5Z7B*O2=PsR0 zEvc|8{NS^)!d)MDX(97Xw}m&kEO@5jqRaDZ!+%`wYOI<23q|&js`&o4xvjP7D_xv@ z5hEwpsp{HezI9!~6O{~)lLR@oF7?J7i>1|5a~UuoN=q&6N}EJPV_GD`&M*v8Y`^2j zKII*d_@Fi$+i*YEW+Hbzn{iQk~yP z>7N{S4)r*!NwQ`(qcN#8SRQsNK6>{)X12nbF`*7#ecO7I)Q$uZsV+xS4E7aUn+U(K baj7?x%VD!5Cxk2YbYLNVeiXvvpMCWYo=by@ literal 0 HcmV?d00001 diff --git a/scm-ui/public/index.html b/scm-ui/public/index.html new file mode 100644 index 0000000000..ed0ebafa1b --- /dev/null +++ b/scm-ui/public/index.html @@ -0,0 +1,40 @@ + + + + + + + + + + + React App + + + +
+ + + diff --git a/scm-ui/public/manifest.json b/scm-ui/public/manifest.json new file mode 100644 index 0000000000..ef19ec243e --- /dev/null +++ b/scm-ui/public/manifest.json @@ -0,0 +1,15 @@ +{ + "short_name": "React App", + "name": "Create React App Sample", + "icons": [ + { + "src": "favicon.ico", + "sizes": "64x64 32x32 24x24 16x16", + "type": "image/x-icon" + } + ], + "start_url": "./index.html", + "display": "standalone", + "theme_color": "#000000", + "background_color": "#ffffff" +} diff --git a/scm-ui/src/App.js b/scm-ui/src/App.js new file mode 100644 index 0000000000..79083246bd --- /dev/null +++ b/scm-ui/src/App.js @@ -0,0 +1,20 @@ +import React, { Component } from 'react'; +import Navigation from './Navigation'; +import Main from './Main'; +import {withRouter} from 'react-router-dom'; +import 'ces-theme/dist/css/ces.css'; + + + +class App extends Component { + render() { + return ( +
+ +
+
+ ); + } +} + +export default withRouter(App); diff --git a/scm-ui/src/Main.js b/scm-ui/src/Main.js new file mode 100644 index 0000000000..068bc38a01 --- /dev/null +++ b/scm-ui/src/Main.js @@ -0,0 +1,36 @@ +//@flow +import React from 'react'; +import injectSheet from 'react-jss'; +import classNames from 'classnames'; + +import { Route, withRouter } from 'react-router'; + +import Page from './containers/Page'; +import {Switch} from 'react-router-dom'; + +const styles = { + content: { + paddingTop: '60px' + }, +}; + +type Props = { + classes: any +} + +class Main extends React.Component { + + render() { + const { classes } = this.props; + return ( +
+ + + +
+ ); + } + +} + +export default withRouter(injectSheet(styles)(Main)); diff --git a/scm-ui/src/Navigation.js b/scm-ui/src/Navigation.js new file mode 100644 index 0000000000..76dd76b268 --- /dev/null +++ b/scm-ui/src/Navigation.js @@ -0,0 +1,52 @@ +//@flow +import React from 'react'; +import {Link} from 'react-router-dom'; + +type Props = {}; + +type State = { + collapsed: boolean +}; + +class Navigation extends React.Component { + + constructor(props: Props) { + super(props); + this.state = { + collapsed: true + }; + } + + toggleCollapse = () => { + this.setState({ + collapsed: !this.state.collapsed + }); + }; + + render() { + + return ( + + ); + } + +} + +export default Navigation; diff --git a/scm-ui/src/containers/Page.js b/scm-ui/src/containers/Page.js new file mode 100644 index 0000000000..6594520ff4 --- /dev/null +++ b/scm-ui/src/containers/Page.js @@ -0,0 +1,3 @@ +/** + * Created by masuewer on 02.07.18. + */ diff --git a/scm-ui/src/createReduxStore.js b/scm-ui/src/createReduxStore.js new file mode 100644 index 0000000000..9b53bb0f3d --- /dev/null +++ b/scm-ui/src/createReduxStore.js @@ -0,0 +1,22 @@ +import thunk from 'redux-thunk'; +import logger from 'redux-logger'; +import { createStore, compose, applyMiddleware, combineReducers } from 'redux'; +import { routerReducer, routerMiddleware } from 'react-router-redux'; + +import page from './modules/page'; + +function createReduxStore(history) { + const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose; + + const reducer = combineReducers({ + router: routerReducer, + page + }); + + return createStore( + reducer, + composeEnhancers(applyMiddleware(routerMiddleware(history), thunk, logger)) + ); +} + +export default createReduxStore; diff --git a/scm-ui/src/index.js b/scm-ui/src/index.js new file mode 100644 index 0000000000..12d8f58f94 --- /dev/null +++ b/scm-ui/src/index.js @@ -0,0 +1,32 @@ +import React from 'react'; +import ReactDOM from 'react-dom'; +import App from './App'; +import registerServiceWorker from './registerServiceWorker'; + +import { Provider } from 'react-redux'; +import createHistory from 'history/createBrowserHistory'; +import createReduxStore from './createReduxStore'; +import { ConnectedRouter } from 'react-router-redux'; + + +// Create a history of your choosing (we're using a browser history in this case) +const history = createHistory({ + basename: process.env.PUBLIC_URL +}); + +window.appHistory = history; +// Add the reducer to your store on the `router` key +// Also apply our middleware for navigating +const store = createReduxStore(history); + +ReactDOM.render( + + { /* ConnectedRouter will use the store from Provider automatically */} + + + + , + document.getElementById('root') +); + +registerServiceWorker(); diff --git a/scm-ui/src/modules/page.js b/scm-ui/src/modules/page.js new file mode 100644 index 0000000000..6594520ff4 --- /dev/null +++ b/scm-ui/src/modules/page.js @@ -0,0 +1,3 @@ +/** + * Created by masuewer on 02.07.18. + */ diff --git a/scm-ui/src/registerServiceWorker.js b/scm-ui/src/registerServiceWorker.js new file mode 100644 index 0000000000..a3e6c0cfc1 --- /dev/null +++ b/scm-ui/src/registerServiceWorker.js @@ -0,0 +1,117 @@ +// In production, we register a service worker to serve assets from local cache. + +// This lets the app load faster on subsequent visits in production, and gives +// it offline capabilities. However, it also means that developers (and users) +// will only see deployed updates on the "N+1" visit to a page, since previously +// cached resources are updated in the background. + +// To learn more about the benefits of this model, read https://goo.gl/KwvDNy. +// This link also includes instructions on opting out of this behavior. + +const isLocalhost = Boolean( + window.location.hostname === 'localhost' || + // [::1] is the IPv6 localhost address. + window.location.hostname === '[::1]' || + // 127.0.0.1/8 is considered localhost for IPv4. + window.location.hostname.match( + /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ + ) +); + +export default function register() { + if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { + // The URL constructor is available in all browsers that support SW. + const publicUrl = new URL(process.env.PUBLIC_URL, window.location); + if (publicUrl.origin !== window.location.origin) { + // Our service worker won't work if PUBLIC_URL is on a different origin + // from what our page is served on. This might happen if a CDN is used to + // serve assets; see https://github.com/facebookincubator/create-react-app/issues/2374 + return; + } + + window.addEventListener('load', () => { + const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; + + if (isLocalhost) { + // This is running on localhost. Lets check if a service worker still exists or not. + checkValidServiceWorker(swUrl); + + // Add some additional logging to localhost, pointing developers to the + // service worker/PWA documentation. + navigator.serviceWorker.ready.then(() => { + console.log( + 'This web app is being served cache-first by a service ' + + 'worker. To learn more, visit https://goo.gl/SC7cgQ' + ); + }); + } else { + // Is not local host. Just register service worker + registerValidSW(swUrl); + } + }); + } +} + +function registerValidSW(swUrl) { + navigator.serviceWorker + .register(swUrl) + .then(registration => { + registration.onupdatefound = () => { + const installingWorker = registration.installing; + installingWorker.onstatechange = () => { + if (installingWorker.state === 'installed') { + if (navigator.serviceWorker.controller) { + // At this point, the old content will have been purged and + // the fresh content will have been added to the cache. + // It's the perfect time to display a "New content is + // available; please refresh." message in your web app. + console.log('New content is available; please refresh.'); + } else { + // At this point, everything has been precached. + // It's the perfect time to display a + // "Content is cached for offline use." message. + console.log('Content is cached for offline use.'); + } + } + }; + }; + }) + .catch(error => { + console.error('Error during service worker registration:', error); + }); +} + +function checkValidServiceWorker(swUrl) { + // Check if the service worker can be found. If it can't reload the page. + fetch(swUrl) + .then(response => { + // Ensure service worker exists, and that we really are getting a JS file. + if ( + response.status === 404 || + response.headers.get('content-type').indexOf('javascript') === -1 + ) { + // No service worker found. Probably a different app. Reload the page. + navigator.serviceWorker.ready.then(registration => { + registration.unregister().then(() => { + window.location.reload(); + }); + }); + } else { + // Service worker found. Proceed as normal. + registerValidSW(swUrl); + } + }) + .catch(() => { + console.log( + 'No internet connection found. App is running in offline mode.' + ); + }); +} + +export function unregister() { + if ('serviceWorker' in navigator) { + navigator.serviceWorker.ready.then(registration => { + registration.unregister(); + }); + } +} diff --git a/scm.iml b/scm.iml new file mode 100644 index 0000000000..a0d516ed9a --- /dev/null +++ b/scm.iml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file