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:
parent
96ec3ab78a
commit
23162c8625
1 changed files with 16 additions and 8 deletions
|
@ -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,14 +35,21 @@ 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) {
|
||||||
return true;
|
scalarUrls = [SdkConfig.get().integrations_rest_url];
|
||||||
|
}
|
||||||
|
|
||||||
|
const url = wurl.format();
|
||||||
|
for (const scalarUrl of scalarUrls) {
|
||||||
|
if (url.startsWith(scalarUrl)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue