Skip to content

Commit

Permalink
Static demos
Browse files Browse the repository at this point in the history
  • Loading branch information
kirill-konshin committed Jun 12, 2020
1 parent 25907c8 commit 18864ae
Show file tree
Hide file tree
Showing 40 changed files with 267 additions and 199 deletions.
49 changes: 0 additions & 49 deletions .gitlab-ci.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ before_install: npm config set //registry.npmjs.org/:_authToken=${NPM_TOKEN}

before_script:
- DEBUG=eslint:cli-engine yarn lint:all
- yarn build
- yarn build:quick

deploy:
- provider: script
Expand Down
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: yarn serve
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1068,10 +1068,6 @@ SKIP_PREFLIGHT_CHECK=true
REACT_APP_VERSION=1.0.0
REACT_APP_API_SERVER=http://pla01-t11-wap11.lab.nordigy.ru:8080
REACT_APP_HOST_CLIENT_ID=wap-rel-all-permissions-app-key
REACT_APP_FRAME_CLIENT_ID=wap-app-test-key
REACT_APP_HOST_PORT=3000
REACT_APP_HOST_WC_PORT=3001
REACT_APP_REACT_PORT=4001
Expand All @@ -1080,6 +1076,8 @@ REACT_APP_IFRAME_PORT=4003
REACT_APP_ADMIN_PORT=4005
REACT_APP_REACT_MENU_PORT=4006
REACT_APP_ANGULAR_PORT=4007
REACT_APP_PRODUCTION_HOST=http://localhost
```

Then you can start the watchers/servers:
Expand Down
6 changes: 3 additions & 3 deletions demo/admin/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
</head>
<body>
<h1>Admin</h1>
<p><a href="other.html">Go to other page</a></p>
<script type="text/javascript" src="node_modules/@ringcentral/web-apps-sync-iframe/dist/ringcentral-web-apps-iframe.js"></script>
<script type="text/javascript" src="scripts.js"></script>
<p><a href="/demo/admin/other.html">Go to other page</a></p>
<script type="text/javascript" src="/demo/admin/node_modules/@ringcentral/web-apps-sync-iframe/dist/ringcentral-web-apps-iframe.js"></script>
<script type="text/javascript" src="/demo/admin/scripts.js"></script>
</body>
</html>
7 changes: 4 additions & 3 deletions demo/admin/other.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
<html>
<head>
<title>Admin</title>
<base href="/demo/admin">
</head>
<body>

<h1>Admin > Other</h1>

<p><a href="/">Go to index page</a></p>
<p><a href="/demo/admin/">Go to index page</a></p>

<hr/>

Expand Down Expand Up @@ -164,7 +165,7 @@ <h1>1914 translation by H. Rackham</h1>
matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he
endures pains to avoid worse pains."</p>

<script type="text/javascript" src="node_modules/@ringcentral/web-apps-sync-iframe/dist/ringcentral-web-apps-iframe.js"></script>
<script type="text/javascript" src="scripts.js"></script>
<script type="text/javascript" src="/demo/admin/node_modules/@ringcentral/web-apps-sync-iframe/dist/ringcentral-web-apps-iframe.js"></script>
<script type="text/javascript" src="/demo/admin/scripts.js"></script>
</body>
</html>
4 changes: 2 additions & 2 deletions demo/admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"version": "0.6.0",
"private": true,
"scripts": {
"start": "http-server -p $REACT_APP_ADMIN_PORT --cors"
"start": "serve -l $REACT_APP_ADMIN_PORT"
},
"dependencies": {
"@ringcentral/web-apps-sync-iframe": "*"
},
"devDependencies": {
"http-server": "0.11.1"
"serve": "11.3.2"
},
"workspaces": {
"nohoist": [
Expand Down
1 change: 1 addition & 0 deletions demo/admin/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ let sync = new RCApps.IFrameSDK.IFrameSync({
history: 'html5',
id: 'admin',
sendInitialLocation: true,
base: '/demo/admin',
});
8 changes: 8 additions & 0 deletions demo/admin/serve.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"rewrites": [
{
"source": "/demo/admin/**",
"destination": "/"
}
]
}
2 changes: 1 addition & 1 deletion demo/angular/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/demo-angular",
"outputPath": "dist",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
Expand Down
2 changes: 1 addition & 1 deletion demo/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"scripts": {
"ng": "ng",
"start": "ng serve --port=$REACT_APP_ANGULAR_PORT",
"build": "ng build"
"build": "ng build --base-href /demo/angular/dist/"
},
"private": true,
"dependencies": {
Expand Down
5 changes: 3 additions & 2 deletions demo/fed/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
"@babel/core": "7.10.2",
"@babel/preset-react": "7.10.1",
"babel-loader": "8.1.0",
"serve": "11.3.0",
"http-server": "0.12.3",
"webpack": "^5.0.0-beta.17",
"webpack-cli": "3.3.11",
"webpack-dev-server": "3.11.0"
},
"scripts": {
"start": "webpack-dev-server"
"start": "webpack-dev-server",
"build": "webpack --progress"
},
"dependencies": {
"react": "^16.13.0",
Expand Down
7 changes: 5 additions & 2 deletions demo/fed/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ const path = require('path');

module.exports = {
entry: './src/index',
mode: 'development',
mode: process.env.NODE_ENV || 'development',
devServer: {
contentBase: path.join(__dirname, 'dist'),
port: process.env.REACT_APP_FED_PORT,
},
output: {
publicPath: `http://localhost:${process.env.REACT_APP_FED_PORT}/`,
publicPath:
process.env.NODE_ENV === 'production'
? '/demo/fed/dist/'
: `http://localhost:${process.env.REACT_APP_FED_PORT}/`,
},
module: {
rules: [
Expand Down
3 changes: 2 additions & 1 deletion demo/host-web-component/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"version": "0.0.0",
"private": true,
"scripts": {
"start": "PORT=$REACT_APP_HOST_WC_PORT react-scripts start"
"start": "PORT=$REACT_APP_HOST_WC_PORT react-scripts start",
"build": "react-scripts build"
},
"browserslist": [
"IE 11"
Expand Down
4 changes: 3 additions & 1 deletion demo/host/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"version": "0.0.0",
"private": true,
"scripts": {
"start": "webpack-dev-server"
"start": "webpack-dev-server",
"build": "webpack --progress"
},
"browserslist": [
"IE 11"
Expand All @@ -24,6 +25,7 @@
"@babel/preset-react": "7.10.1",
"babel-loader": "8.1.0",
"css-loader": "^3.5.3",
"http-server": "0.12.3",
"style-loader": "^1.2.1",
"html-webpack-plugin": "^4.3.0",
"webpack": "^5.0.0-beta.17",
Expand Down
1 change: 0 additions & 1 deletion demo/host/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="fragment" content="!">
<meta charset="utf-8">
<base href="/">
<title>Service Web</title>
</head>
<body>
Expand Down
86 changes: 64 additions & 22 deletions demo/host/src/lib/registry.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// This could be any other provisioning method
const fetchManifest = async url => (await fetch(`${url}/asset-manifest.json`)).json();

const angularSuffix = process.env.NODE_ENV === 'production' ? '-es5' : '';

// Special treatment of Create React App manifest
const getFilesFromManifest = (url, manifest) =>
[
Expand All @@ -12,56 +14,96 @@ const getFilesFromManifest = (url, manifest) =>
export const appRegistry = {
react: {
type: 'script',
getUrl: async (url = `http://localhost:${process.env.REACT_APP_REACT_MENU_PORT}`) =>
getFilesFromManifest(url, await fetchManifest(url)),
getUrl: async (
url = process.env.NODE_ENV === 'production'
? `/demo/react-menu/build`
: `http://localhost:${process.env.REACT_APP_REACT_MENU_PORT}`,
) => getFilesFromManifest(url, await fetchManifest(url)),
},
reactMenuIframe: {
type: 'iframe',
origin: `http://localhost:${process.env.REACT_APP_REACT_MENU_IFRAME_PORT}`,
getUrl: async (url = `http://localhost:${process.env.REACT_APP_REACT_MENU_IFRAME_PORT}`) => url,
origin:
process.env.NODE_ENV === 'production'
? window.location.origin
: `http://localhost:${process.env.REACT_APP_REACT_MENU_IFRAME_PORT}`,
getUrl: async (
url = process.env.NODE_ENV === 'production'
? `/demo/react-menu-iframe/build/`
: `http://localhost:${process.env.REACT_APP_REACT_MENU_IFRAME_PORT}`,
) => url,
},
global: {
type: 'global',
getUrl: async (url = `http://localhost:${process.env.REACT_APP_REACT_PORT}`) =>
getFilesFromManifest(url, await fetchManifest(url)),
getUrl: async (
url = process.env.NODE_ENV === 'production'
? `/demo/react/build`
: `http://localhost:${process.env.REACT_APP_REACT_PORT}`,
) => getFilesFromManifest(url, await fetchManifest(url)),
},
vue: {
type: 'script',
getUrl: (url = `http://localhost:${process.env.REACT_APP_VUE_PORT}`) => [
`${url}/js/app.js`,
`${url}/js/chunk-vendors.js`,
],
getUrl: (
url = process.env.NODE_ENV === 'production'
? `/demo/vue/dist`
: `http://localhost:${process.env.REACT_APP_VUE_PORT}`,
) => [`${url}/js/app.js`, `${url}/js/chunk-vendors.js`],
},
iframe: {
type: 'iframe',
origin: `http://localhost:${process.env.REACT_APP_IFRAME_PORT}`,
getUrl: (url = `http://localhost:${process.env.REACT_APP_IFRAME_PORT}`) => url, // add # to URL enable hash history in IFRAME
origin:
process.env.NODE_ENV === 'production'
? window.location.origin
: `http://localhost:${process.env.REACT_APP_IFRAME_PORT}`,
getUrl: (
url = process.env.NODE_ENV === 'production'
? `/demo/iframe/build`
: `http://localhost:${process.env.REACT_APP_IFRAME_PORT}`,
) => url, // add # to URL enable hash history in IFRAME
},
admin: {
type: 'iframe',
origin: `http://localhost:${process.env.REACT_APP_ADMIN_PORT}`,
getUrl: (url = `http://localhost:${process.env.REACT_APP_ADMIN_PORT}`) => url,
origin:
process.env.NODE_ENV === 'production'
? window.location.origin
: `http://localhost:${process.env.REACT_APP_ADMIN_PORT}`,
getUrl: (
url = process.env.NODE_ENV === 'production'
? `/demo/admin`
: `http://localhost:${process.env.REACT_APP_ADMIN_PORT}`,
) => url,
},
angular: {
type: 'script',
getUrl: (url = `http://localhost:${process.env.REACT_APP_ANGULAR_PORT}`) => [
url + `/runtime.js`,
url + `/polyfills.js`,
url + `/styles.js`,
url + `/vendor.js`,
url + `/main.js`,
getUrl: (
url = process.env.NODE_ENV === 'production'
? `/demo/angular/dist`
: `http://localhost:${process.env.REACT_APP_ANGULAR_PORT}`,
) => [
url + `/runtime${angularSuffix}.js`,
url + `/polyfills${angularSuffix}.js`,
url + `/styles${angularSuffix}.js`,
url + `/vendor${angularSuffix}.js`,
url + `/main${angularSuffix}.js`,
],
},
federation: {
type: 'global',
getUrl: async (url = `http://localhost:${process.env.REACT_APP_FED_PORT}`) => url + '/remoteEntry.js',
getUrl: async (
url = process.env.NODE_ENV === 'production'
? `/demo/fed/dist`
: `http://localhost:${process.env.REACT_APP_FED_PORT}`,
) => url + '/remoteEntry.js',
options: {
federation: true,
},
},
federationDirect: {
type: 'global',
getUrl: async (url = `http://localhost:${process.env.REACT_APP_FED_PORT}`) => url + '/remoteEntry.js',
getUrl: async (
url = process.env.NODE_ENV === 'production'
? `/demo/fed/dist`
: `http://localhost:${process.env.REACT_APP_FED_PORT}`,
) => url + '/remoteEntry.js',
options: {
federation: true,
module: './App',
Expand Down
6 changes: 3 additions & 3 deletions demo/host/src/pages/LoggedInWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import {FederationDirectApp} from './FederationDirectApp';

const logout = () => alert('Logout');

const Layout = () => (
const Layout = ({match}) => (
<>
<MenuApp logout={logout} />
<MenuAppIframe logout={logout} />

<Switch>
<Route path="/application/apps" component={Index} exact />
<Route path="/application/apps/:appId" component={App} />
<Route path={`${match.url}`} component={Index} exact />
<Route path={`${match.url}/:appId`} component={App} />
</Switch>

<FederationApp />
Expand Down
Loading

0 comments on commit 18864ae

Please sign in to comment.