feat(App): remove obsolete config prop

It's obsolete now, since config is handled in Redux. Also add a "defaultUrl"
prop so emdedding applications can select what the default base URL is.
This commit is contained in:
Saúl Ibarra Corretgé 2017-06-09 12:26:21 +02:00 committed by Lyubo Marinov
parent 893d08d614
commit 79d51bc379
5 changed files with 19 additions and 34 deletions

View File

@ -1,4 +0,0 @@
/* global config */
// For legacy reasons, use jitsi-meet's global variable config.
export default typeof config === 'object' ? config : undefined;

View File

@ -20,6 +20,11 @@ import {
declare var APP: Object;
/**
* Default URL to be loaded if no other was specified using props.
*/
const DEFAULT_URL = 'https://meet.jit.si';
/**
* Base (abstract) class for main App component.
*
@ -32,7 +37,14 @@ export class AbstractApp extends Component {
* @static
*/
static propTypes = {
config: React.PropTypes.object,
/**
* Default URL to be loaded by the app when not in any room.
*/
defaultUrl: React.PropTypes.string,
/**
* (Optional) Redux store for this app.
*/
store: React.PropTypes.object,
/**
@ -193,10 +205,9 @@ export class AbstractApp extends Component {
_createElement(component, props) {
/* eslint-disable no-unused-vars, lines-around-comment */
const {
// Don't propagate the config prop(erty) because the config is
// stored inside the Redux state and, thus, is visible to the
// children anyway.
config,
// The defaultUrl property was introduced to be consumed entirely by
// AbstractApp.
defaultUrl,
// Don't propagate the dispatch and store props because they usually
// come from react-redux and programmers don't really expect them to
// be inherited but rather explicitly connected.
@ -265,24 +276,7 @@ export class AbstractApp extends Component {
}
}
// By default, open the domain configured in the configuration file
// which may be the domain at which the whole server infrastructure is
// deployed.
const { config } = this.props;
if (typeof config === 'object') {
const { hosts } = config;
if (typeof hosts === 'object') {
const { domain } = hosts;
if (domain) {
return `https://${domain}`;
}
}
}
return 'https://meet.jit.si';
return this.props.defaultUrl || DEFAULT_URL;
}
/**

View File

@ -14,7 +14,7 @@ export class App extends AbstractApp {
*
* @static
*/
static propTypes = AbstractApp.propTypes
static propTypes = AbstractApp.propTypes;
/**
* Initializes a new App instance.

View File

@ -2,7 +2,6 @@ import 'es6-symbol/implement';
import React, { Component } from 'react';
import { AppRegistry, Linking } from 'react-native';
import config from './config';
import { App } from './features/app';
/**
@ -65,7 +64,6 @@ class Root extends Component {
return (
<App
config = { config }
url = { this.state.url } />
);
}

View File

@ -5,7 +5,6 @@ import ReactDOM from 'react-dom';
import { getJitsiMeetTransport } from '../modules/transport';
import config from './config';
import { App } from './features/app';
const logger = require('jitsi-meet-logger').getLogger(__filename);
@ -20,9 +19,7 @@ document.addEventListener('DOMContentLoaded', () => {
logger.log('(TIME) document ready:\t', now);
// Render the main Component.
ReactDOM.render(
<App config = { config } />,
document.getElementById('react'));
ReactDOM.render(<App />, document.getElementById('react'));
});
/**