Merge branch 'new-queue' of github.com:coralproject/talk into new-queue

This commit is contained in:
Belen Curcio
2017-07-28 09:54:55 -03:00
23 changed files with 142 additions and 73 deletions
+4 -1
View File
@@ -1,5 +1,6 @@
import React from 'react';
import {Router, Route, IndexRedirect, browserHistory, Redirect} from 'react-router';
import {useBasename} from 'history';
import Configure from 'routes/Configure';
import Dashboard from 'routes/Dashboard';
@@ -59,6 +60,8 @@ const routes = (
</div>
);
const AppRouter = () => <Router history={browserHistory} routes={routes} />;
const AppRouter = () => <Router history={useBasename(() => browserHistory)({
basename: '/talk/'
})} routes={routes}/>;
export default AppRouter;
@@ -2,6 +2,7 @@ import React, {Component} from 'react';
import t from 'coral-framework/services/i18n';
import styles from './Configure.css';
import {Button, Card} from 'coral-ui';
import {BASE_URL} from 'coral-framework/constants/url';
class EmbedLink extends Component {
@@ -24,21 +25,14 @@ class EmbedLink extends Component {
}
render () {
const location = window.location;
const talkBaseUrl = [
location.protocol,
'//',
location.hostname,
location.port ? (`:${window.location.port}`) : ''
].join('');
const coralJsUrl = [talkBaseUrl, '/embed.js'].join('');
const coralJsUrl = [BASE_URL, '/embed.js'].join('');
const nonce = String(Math.random()).slice(2);
const streamElementId = `coral_talk_${nonce}`;
const embedText = `
<div id="${streamElementId}"></div>
<script src="${coralJsUrl}" async onload="
Coral.Talk.render(document.getElementById('${streamElementId}'), {
talk: '${talkBaseUrl}'
talk: '${BASE_URL}'
});
"></script>
`.trim();
+7
View File
@@ -0,0 +1,7 @@
import url from 'url';
const base = document.querySelector('base');
const baseUrl = base && url.parse(base.href) || {};
export const BASE_URL = base.href;
export const BASE_PATH = baseUrl.pathname;
+2 -1
View File
@@ -2,6 +2,7 @@ import bowser from 'bowser';
import * as Storage from './storage';
import merge from 'lodash/merge';
import {getStore} from 'coral-framework/services/store';
import {BASE_PATH} from 'coral-framework/constants/url';
/**
* getAuthToken returns the active auth token or null
@@ -75,7 +76,7 @@ const handleResp = (res) => {
}
};
export const base = '/api/v1';
export const base = `${BASE_PATH}api/v1`;
export default (url, options) => {
return fetch(`${base}${url}`, buildOptions(options)).then(handleResp);
+2 -1
View File
@@ -4,6 +4,7 @@ import {SubscriptionClient, addGraphQLSubscriptions} from 'subscriptions-transpo
import MessageTypes from 'subscriptions-transport-ws/dist/message-types';
import {getAuthToken} from '../helpers/request';
import introspectionQueryResultData from '../graphql/introspection.json';
import {BASE_PATH} from 'coral-framework/constants/url';
let client, wsClient = null, wsClientToken = null;
@@ -33,7 +34,7 @@ export function getClient(options = {}) {
}
const protocol = location.protocol === 'https:' ? 'wss' : 'ws';
wsClient = new SubscriptionClient(`${protocol}://${location.host}/api/v1/live`, {
wsClient = new SubscriptionClient(`${protocol}://${location.host}${BASE_PATH}api/v1/live`, {
reconnect: true,
lazy: true,
connectionParams: {
+2 -1
View File
@@ -1,12 +1,13 @@
import {createNetworkInterface} from 'apollo-client';
import {getAuthToken} from '../helpers/request';
import {BASE_PATH} from 'coral-framework/constants/url';
//==============================================================================
// NETWORK INTERFACE
//==============================================================================
const networkInterface = createNetworkInterface({
uri: '/api/v1/graph/ql',
uri: `${BASE_PATH}api/v1/graph/ql`,
opts: {
credentials: 'same-origin'
}