cluedin-widget
Version:
This project contains all the pages needed for browsing entities and searching them. The aim is to replace the CluedIn.Webapp project with this one when all the pages ( including the Admin page ) will be ported to REACT.
75 lines (62 loc) • 2.46 kB
JavaScript
module.exports = function( protocol, mainDomain, clientId ) {
var goToApp = function( url ) {
return protocol + clientId + mainDomain + url;
};
var getEntityLink = ( id, entityType, isStandAlone ) => {
let orgUrl = '/organization/' + id;
let personUrl = '/person/' + id;
let entityUrl = '/entity/' + id;
if( entityType === '/Organization' ) {
return isStandAlone ? goToApp( orgUrl ) : orgUrl;
}
if( (entityType === '/Person') || ( entityType === '/Infrastructure/User' ) ) {
return isStandAlone ? goToApp( personUrl ) : personUrl;
}
return isStandAlone ? goToApp( entityUrl ) : entityUrl;
};
return {
redirectToUrl: function( url ) {
window.location = url;
},
goToSeeAdministratorLinkPage: function() {
return goToApp( '#/me/organization/administrators' );
},
goToConnectedProvider: function() {
return goToApp( '#/administration/integration/current' );
},
gotToAppProvider: function( params ) {
return goToApp( '#/administration/integration/integration/new/' + params[ 0 ] + '/' + params[ 1 ] );
},
goToSearch: function( searchTerm ) {
return goToApp( '#/search/' + searchTerm );
},
goToEntityFromInsight: function( entityInsight ) {
let id = entityInsight.EntityId;
let entityType = entityInsight.EntityType;
return getEntityLink( id, entityType );
},
goToEntity: function( entity, isStandAlone ) {
let id = entity.id;
let entityType = entity.data ? entity.data.entityType : '';
return getEntityLink( id, entityType, isStandAlone );
},
goToApp: goToApp,
goToInviteUser: function( param ) {
let url = '#/administration/useradmin/domainusers?open=true';
if( param && param.email ) {
url += '&email=' + param.email;
}
if( param && param.name ) {
url += '&name=' + param.name;
}
return goToApp( url );
},
goToAppProvider: function( type ) {
let url = '#/administration/integration/all';
if( type ) {
url += '?type=' + type;
}
return goToApp( url );
}
};
};