Support third party integration managers in AppPermission

Alternative integration managers may wish to also wrap widgets to supply a better user experience. With the previous code, it was not possible to use the integrations_widgets_urls configuration option (described in AppTile). AppPermission should use the same logic to determine if a widget is being wrapped, so it can display a helpful URL for the user (instead of the wrapper URL).

Signed-off-by: Travis Ralston <travpc@gmail.com>
This commit is contained in:
Travis Ralston 2017-10-09 18:50:08 -06:00
parent 96ec3ab78a
commit 23162c8625

View file

@ -2,6 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import url from 'url'; import url from 'url';
import { _t } from '../../../languageHandler'; import { _t } from '../../../languageHandler';
import SdkConfig from '../../../SdkConfig';
export default class AppPermission extends React.Component { export default class AppPermission extends React.Component {
constructor(props) { constructor(props) {
@ -34,15 +35,22 @@ export default class AppPermission extends React.Component {
} }
isScalarWurl(wurl) { isScalarWurl(wurl) {
if (wurl && wurl.hostname && ( // Exit early if we've been given bad data
wurl.hostname === 'scalar.vector.im' || if (!wurl) {
wurl.hostname === 'scalar-staging.riot.im' || return false;
wurl.hostname === 'scalar-develop.riot.im' || }
wurl.hostname === 'demo.riot.im' ||
wurl.hostname === 'localhost' let scalarUrls = SdkConfig.get().integrations_widgets_urls;
)) { if (!scalarUrls || scalarUrls.length == 0) {
scalarUrls = [SdkConfig.get().integrations_rest_url];
}
const url = wurl.format();
for (const scalarUrl of scalarUrls) {
if (url.startsWith(scalarUrl)) {
return true; return true;
} }
}
return false; return false;
} }