Skip to content

Commit

Permalink
Run prettier on all files
Browse files Browse the repository at this point in the history
Signed-off-by: Abeshouse, Adam A./Sloan Kettering Institute <[email protected]>

Former-commit-id: 9c89f21b55bc37e169bf5f92ea93af50ad19c1bd
  • Loading branch information
Abeshouse, Adam A./Sloan Kettering Institute committed Jan 27, 2020
1 parent abf68d2 commit f0f3455
Show file tree
Hide file tree
Showing 866 changed files with 120,136 additions and 69,112 deletions.
86 changes: 47 additions & 39 deletions src/AppStore.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
import {action, computed, observable} from "mobx";
import {addServiceErrorHandler, getBrowserWindow, remoteData} from "cbioportal-frontend-commons";
import {initializeAPIClients} from "./config/config";
import { action, computed, observable } from 'mobx';
import {
addServiceErrorHandler,
getBrowserWindow,
remoteData,
} from 'cbioportal-frontend-commons';
import { initializeAPIClients } from './config/config';
import * as _ from 'lodash';
import internalClient from "shared/api/cbioportalInternalClientInstance";
import {sendSentryMessage} from "./shared/lib/tracking";
import internalClient from 'shared/api/cbioportalInternalClientInstance';
import { sendSentryMessage } from './shared/lib/tracking';

export type SiteError = {
errorObj:any;
dismissed:boolean;
title?:string;
errorObj: any;
dismissed: boolean;
title?: string;
};

export class AppStore {

constructor(){

constructor() {
getBrowserWindow().me = this;
addServiceErrorHandler((error: any) => {
try{
sendSentryMessage("ERRORHANDLER:" + error);
} catch (ex) {};

if (error.status && /400|500/.test(error.status)) {
try {
sendSentryMessage('ERRORHANDLER:' + error);
} catch (ex) {}

sendSentryMessage("ERROR DIALOG SHOWN:" + error);
this.siteErrors.push({errorObj: error, dismissed:false});
if (error.status && /400|500/.test(error.status)) {
sendSentryMessage('ERROR DIALOG SHOWN:' + error);
this.siteErrors.push({ errorObj: error, dismissed: false });
}
});
}
Expand All @@ -33,35 +34,35 @@ export class AppStore {

@observable siteErrors: SiteError[] = [];

@observable userName:string | undefined;
@observable userName: string | undefined;

@observable authMethod:string | undefined;
@observable authMethod: string | undefined;

@computed get isLoggedIn(){
return _.isString(this.userName) && this.userName !== "anonymousUser";
@computed get isLoggedIn() {
return _.isString(this.userName) && this.userName !== 'anonymousUser';
}

@computed get logoutUrl(){
if (this.authMethod === "saml") {
return "saml/logout";
@computed get logoutUrl() {
if (this.authMethod === 'saml') {
return 'saml/logout';
} else {
return "j_spring_security_logout";
return 'j_spring_security_logout';
}
}

@computed get undismissedSiteErrors(){
return _.filter(this.siteErrors.slice(), (err)=>!err.dismissed);
@computed get undismissedSiteErrors() {
return _.filter(this.siteErrors.slice(), err => !err.dismissed);
}

@computed get isErrorCondition(){
@computed get isErrorCondition() {
return this.undismissedSiteErrors.length > 0;
}

@action
public dismissErrors(){
this.siteErrors = this.siteErrors.map((err)=>{
err.dismissed = true;
return err;
public dismissErrors() {
this.siteErrors = this.siteErrors.map(err => {
err.dismissed = true;
return err;
});
}

Expand All @@ -75,14 +76,21 @@ export class AppStore {
}

readonly portalVersion = remoteData<string | undefined>({
invoke:async()=>{
const portalVersionResult = await internalClient.getInfoUsingGET({});
invoke: async () => {
const portalVersionResult = await internalClient.getInfoUsingGET(
{}
);
if (portalVersionResult && portalVersionResult.portalVersion) {
let version = undefined;

// try getting version from branch name assume like release-x.y.z
if (portalVersionResult.gitBranch && portalVersionResult.gitBranch.startsWith("release-")) {
let branchVersion = portalVersionResult.gitBranch.split('-')[1];
if (
portalVersionResult.gitBranch &&
portalVersionResult.gitBranch.startsWith('release-')
) {
let branchVersion = portalVersionResult.gitBranch.split(
'-'
)[1];
if (branchVersion.split('.').length == 3) {
version = branchVersion;
}
Expand All @@ -95,12 +103,12 @@ export class AppStore {
}

// add v prefix if missing
if (version !== undefined && !version.startsWith("v")) {
if (version !== undefined && !version.startsWith('v')) {
version = `v${version}`;
}
return Promise.resolve(version);
}
return undefined;
}
},
});
}
80 changes: 37 additions & 43 deletions src/appBootstrapper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'mobx-react';
import { Router, useRouterHistory } from 'react-router';
import { createHistory } from 'history'
import { syncHistoryWithStore } from 'mobx-react-router';
import { createHistory } from 'history';
import { syncHistoryWithStore } from 'mobx-react-router';
import ExtendedRoutingStore from './shared/lib/ExtendedRouterStore';
import {
fetchServerConfig,
initializeAPIClients,
initializeAppStore,
initializeConfiguration,
setConfigDefaults,
setServerConfig
setServerConfig,
} from './config/config';

import './shared/lib/ajaxQuiet';
Expand All @@ -20,15 +20,15 @@ import * as _ from 'lodash';
import $ from 'jquery';
import * as superagent from 'superagent';
import { getHost, buildCBioPortalPageUrl } from './shared/api/urls';
import AppConfig from "appConfig";
import AppConfig from 'appConfig';
import browser from 'bowser';
import { setNetworkListener } from './shared/lib/ajaxQuiet';
import { initializeTracking } from "shared/lib/tracking";
import { initializeTracking } from 'shared/lib/tracking';
import superagentCache from 'superagent-cache';
import {getBrowserWindow} from "cbioportal-frontend-commons";
import {AppStore} from "./AppStore";
import {handleLongUrls} from "shared/lib/handleLongUrls";
import "shared/polyfill/canvasToBlob";
import { getBrowserWindow } from 'cbioportal-frontend-commons';
import { AppStore } from './AppStore';
import { handleLongUrls } from 'shared/lib/handleLongUrls';
import 'shared/polyfill/canvasToBlob';
import mobx from 'mobx';

superagentCache(superagent);
Expand All @@ -37,39 +37,35 @@ superagentCache(superagent);
// it fixes the hash portion of url when cohort patient list is too long
handleLongUrls();


// YOU MUST RUN THESE initialize and then set the public path after

initializeConfiguration();
// THIS TELLS WEBPACK BUNDLE LOADER WHERE TO LOAD SPLIT BUNDLES
__webpack_public_path__ = AppConfig.frontendUrl;

if (!window.hasOwnProperty("$")) {
if (!window.hasOwnProperty('$')) {
window.$ = $;
}



if (!window.hasOwnProperty("jQuery")) {
if (!window.hasOwnProperty('jQuery')) {
window.jQuery = $;
}

if (!window.hasOwnProperty("mobx")) {
if (!window.hasOwnProperty('mobx')) {
window.mobx = mobx;
}

// write browser name, version to brody tag
if (browser) {
$(document).ready(()=>{
$("body").addClass(browser.name);
$(document).ready(() => {
$('body').addClass(browser.name);
});
}

// e2e test specific stuff
if (getBrowserWindow().navigator.webdriver) {

$(document).ready(()=>{
$("body").addClass("e2etest");
$(document).ready(() => {
$('body').addClass('e2etest');
window.e2etest = true;
});

Expand All @@ -82,25 +78,25 @@ window.FRONTEND_COMMIT = COMMIT;

// this is special function allowing MSKCC CIS to hide login UI in
// portal header
window.postLoadForMskCIS = function(){
window.postLoadForMskCIS = function() {
AppConfig.hide_login = true;
}
};

// make sure lodash doesn't overwrite (or set) global underscore
_.noConflict();

const routingStore = new ExtendedRoutingStore();

const history = useRouterHistory(createHistory)({
basename: AppConfig.basePath || ""
basename: AppConfig.basePath || '',
});

const syncedHistory = syncHistoryWithStore(history, routingStore);

const stores = {
// Key can be whatever you want
routing: routingStore,
appStore:new AppStore()
appStore: new AppStore(),
};

window.globalStores = stores;
Expand All @@ -109,21 +105,25 @@ const end = superagent.Request.prototype.end;

let redirecting = false;

superagent.Request.prototype.end = function (callback) {
superagent.Request.prototype.end = function(callback) {
return end.call(this, (error, response) => {

if (redirecting) {
return;
}
if (response && response.statusCode === 401) {
var storageKey = `redirect${Math.floor(Math.random() * 1000000000000)}`
var storageKey = `redirect${Math.floor(
Math.random() * 1000000000000
)}`;
localStorage.setItem(storageKey, window.location.href);

// build URL with a reference to storage key so that /restore route can restore it after login
const loginUrl = buildCBioPortalPageUrl({
query: {
"spring-security-redirect":buildCBioPortalPageUrl({ pathname:"restore", query: { key: storageKey} })
}
'spring-security-redirect': buildCBioPortalPageUrl({
pathname: 'restore',
query: { key: storageKey },
}),
},
});

redirecting = true;
Expand All @@ -136,22 +136,17 @@ superagent.Request.prototype.end = function (callback) {

window.routingStore = routingStore;


let render = () => {

if (!getBrowserWindow().navigator.webdriver) initializeTracking();

const rootNode = document.getElementById("reactRoot");
const rootNode = document.getElementById('reactRoot');

ReactDOM.render(
<Provider {...stores}>
<Router
history={syncedHistory} routes={makeRoutes()} >
</Router>
</Provider>
, rootNode);


<Router history={syncedHistory} routes={makeRoutes()}></Router>
</Provider>,
rootNode
);
};

if (__DEBUG__ && module.hot) {
Expand All @@ -162,23 +157,22 @@ if (__DEBUG__ && module.hot) {
}

$(document).ready(async () => {

// we show blank page if the window.name is "blank"
if (window.name === "blank") {
if (window.name === 'blank') {
return;
}
// we use rawServerConfig (written by JSP) if it is present
// or fetch from config service if not
// need to use jsonp, so use jquery
let config = window.rawServerConfig || await fetchServerConfig();
let config = window.rawServerConfig || (await fetchServerConfig());

setServerConfig(config);

setConfigDefaults();

initializeAPIClients();

initializeAppStore(stores.appStore,config);
initializeAppStore(stores.appStore, config);

render();

Expand Down
Loading

0 comments on commit f0f3455

Please sign in to comment.