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>pull/21833/head
							parent
							
								
									96ec3ab78a
								
							
						
					
					
						commit
						23162c8625
					
				|  | @ -2,6 +2,7 @@ import React from 'react'; | |||
| import PropTypes from 'prop-types'; | ||||
| import url from 'url'; | ||||
| import { _t } from '../../../languageHandler'; | ||||
| import SdkConfig from '../../../SdkConfig'; | ||||
| 
 | ||||
| export default class AppPermission extends React.Component { | ||||
|     constructor(props) { | ||||
|  | @ -34,14 +35,21 @@ export default class AppPermission extends React.Component { | |||
|     } | ||||
| 
 | ||||
|     isScalarWurl(wurl) { | ||||
|         if (wurl && wurl.hostname && ( | ||||
|             wurl.hostname === 'scalar.vector.im' || | ||||
|             wurl.hostname === 'scalar-staging.riot.im' || | ||||
|             wurl.hostname === 'scalar-develop.riot.im' || | ||||
|             wurl.hostname === 'demo.riot.im' || | ||||
|             wurl.hostname === 'localhost' | ||||
|         )) { | ||||
|             return true; | ||||
|         // Exit early if we've been given bad data
 | ||||
|         if (!wurl) { | ||||
|             return false; | ||||
|         } | ||||
| 
 | ||||
|         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 false; | ||||
|     } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 Travis Ralston
						Travis Ralston