Skip to content
This repository has been archived by the owner on Jul 9, 2024. It is now read-only.

Commit

Permalink
trying eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
samrichca committed Apr 25, 2019
1 parent f4b7127 commit ae7e116
Show file tree
Hide file tree
Showing 533 changed files with 13,619 additions and 11,496 deletions.
54 changes: 26 additions & 28 deletions src/Root.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,23 @@ import { PersistGate } from 'redux-persist/lib/integration/react';
import setupStore from '@ncigdc/dux';
import { fetchApiVersionInfo } from '@ncigdc/dux/versionInfo';
import { viewerQuery } from '@ncigdc/routes/queries';
import Portal from './Portal';
import { API, IS_AUTH_PORTAL, AWG } from '@ncigdc/utils/constants';
import { fetchUser, forceLogout } from '@ncigdc/dux/auth';
import Login from '@ncigdc/routes/Login';
import { redirectToLogin } from '@ncigdc/utils/auth';
import consoleDebug from '@ncigdc/utils/consoleDebug';
import { fetchNotifications } from '@ncigdc/dux/bannerNotification';
import Loader from '@ncigdc/uikit/Loaders/Loader';
import Portal from './Portal';

const retryStatusCodes = [500, 503, 504];
const retryStatusCodes = [
500,
503,
504,
];

const AccessError = message => {
let instance = new Error(message);
const instance = new Error(message);
instance.name = 'AccessError';
return instance;
};
Expand All @@ -59,10 +63,7 @@ Relay.injectNetworkLayer(
const hash =
parse(search).hash ||
md5(
[
req.relayReqObj._printedQuery.text,
JSON.stringify(req.relayReqObj._printedQuery.variables),
].join(':')
[req.relayReqObj._printedQuery.text, JSON.stringify(req.relayReqObj._printedQuery.variables)].join(':')
);

req.url = `${url}?hash=${hash}`;
Expand All @@ -73,9 +74,9 @@ Relay.injectNetworkLayer(

req.credentials = 'include';

let { user } = window.store.getState().auth;
const { user } = window.store.getState().auth;

let parsedBody = JSON.parse(req.body);
const parsedBody = JSON.parse(req.body);
req.body = JSON.stringify(parsedBody);
return next(req)
.then(res => {
Expand All @@ -84,8 +85,8 @@ Relay.injectNetworkLayer(
throw res;
}

let { json } = res;
let { user } = window.store.getState().auth;
const { json } = res;
const { user } = window.store.getState().auth;

if (user) {
if (!json.fence_projects[0]) {
Expand All @@ -104,24 +105,23 @@ Relay.injectNetworkLayer(
return res;
})
.catch(err => {
let { user } = window.store.getState().auth;
const { user } = window.store.getState().auth;
if (err.name === 'AccessError') {
consoleDebug(`Access error message: ${err.message}`);
return redirectToLogin(err.message);
} else {
consoleDebug(`Something went wrong in Root network layer: ${err}`);
}
consoleDebug(`Something went wrong in Root network layer: ${err}`);
// not able to pass the response status from throw so need to exclude by error message
let errorMessage = err.message
const errorMessage = err.message
? JSON.parse(err.message).message
: null;
if (
IS_AUTH_PORTAL &&
if (
IS_AUTH_PORTAL &&
user &&
errorMessage ===
'Your token is invalid or expired. Please get a new token from GDC Data Portal.'
) {
return redirectToLogin('timeout');
}
) {
return redirectToLogin('timeout');
}
});
},
Expand All @@ -146,10 +146,11 @@ if (process.env.NODE_ENV !== 'development') {
}
class RelayRoute extends Relay.Route {
static routeName = 'RootRoute';

static queries = viewerQuery;
}

let HasUser = connect(state => state.auth)(props => {
const HasUser = connect(state => state.auth)(props => {
return props.children({
user: props.user,
failed: props.failed,
Expand All @@ -165,12 +166,11 @@ const Root = (props: mixed) => (
{!IS_AUTH_PORTAL ? (
<Relay.Renderer
Container={Portal}
queryConfig={new RelayRoute(props)}
environment={Relay.Store}
/>
queryConfig={new RelayRoute(props)} />
) : (
<Switch>
<Route exact path="/login" component={Login} />
<Route component={Login} exact path="/login" />
<Route
render={props => (
<HasUser>
Expand All @@ -193,9 +193,8 @@ const Root = (props: mixed) => (
return (
<Relay.Renderer
Container={Portal}
queryConfig={new RelayRoute(props)}
environment={Relay.Store}
/>
queryConfig={new RelayRoute(props)} />
);
}
consoleDebug(
Expand All @@ -204,8 +203,7 @@ const Root = (props: mixed) => (
return <Redirect to="/login" />;
}}
</HasUser>
)}
/>
)} />
</Switch>
)}
</React.Fragment>
Expand Down
32 changes: 12 additions & 20 deletions src/packages/@ncigdc/components/AWGHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,15 @@ const Header = compose(
setIsInSearchMode,
}) => (
<header
id="header"
className="navbar navbar-default navbar-static-top"
role="banner"
>
id="header"
role="banner">
<div className="container-fluid">
<div className="navbar-header">
<button
type="button"
className="navbar-toggle"
onClick={() => setIsCollapsed(!isCollapsed)}
>
type="button">
<span className="sr-only test-toggle-navigation">
Toggle navigation
</span>
Expand All @@ -67,27 +65,24 @@ const Header = compose(
</button>
<HomeLink
className="navbar-brand"
tabIndex="0"
style={{ padding: 0 }}
>
tabIndex="0">
<img
style={{ width: 260 }}
src="https://i.imgur.com/O33FmeE.png"
alt="gdc-logo"
/>
src="https://i.imgur.com/O33FmeE.png"
style={{ width: 260 }} />
<Hidden>
<h1>Home</h1>
</Hidden>
</HomeLink>
</div>
<nav
style={{ outline: 'none' }}
aria-label="Site Navigation"
className={`navbar-collapse ${isCollapsed ? 'collapse' : ''}`}
data-uib-collapse="hc.isCollapsed"
tabIndex="-1"
aria-label="Site Navigation"
onClick={() => setIsCollapsed(true)}
>
style={{ outline: 'none' }}
tabIndex="-1">
<ul className="nav navbar-nav">
<li>
<ProjectsLink exact activeStyle={styles.activeNavLink(theme)}>
Expand All @@ -109,8 +104,7 @@ const Header = compose(
<QuickSearch
isInSearchMode={isInSearchMode}
setIsInSearchMode={setIsInSearchMode}
tabIndex="0"
/>
tabIndex="0" />
</li>
{user && !isInSearchMode && (
<li className="header-hidden-xs">
Expand All @@ -124,12 +118,10 @@ const Header = compose(
<span>
<i
className="fa fa-shopping-cart"
style={styles.iconPadding}
/>
style={styles.iconPadding} />
<span
className="header-hidden-sm header-hidden-md"
style={styles.iconPadding}
>
style={styles.iconPadding}>
Cart
</span>
<span className="label label-primary">
Expand Down
49 changes: 24 additions & 25 deletions src/packages/@ncigdc/components/ActionsRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { fetchFilesAndAdd } from '@ncigdc/dux/cart';
import { ShoppingCartIcon } from '@ncigdc/theme/icons';
import DownloadManifestButton from '@ncigdc/components/DownloadManifestButton';
import { IGroupFilter } from '@ncigdc/utils/filters/types';
import { DISPLAY_SLIDES } from '@ncigdc/utils/constants';
import { DISPLAY_SLIDES, AWG } from '@ncigdc/utils/constants';
import { RepositorySlideCount } from '@ncigdc/modern_components/Counts';
import { Tooltip } from '@ncigdc/uikit/Tooltip';
import Spinner from '@ncigdc/theme/icons/Spinner';
Expand All @@ -23,7 +23,7 @@ import { linkButton } from '@ncigdc/theme/mixins';
import ImageViewerLink from '@ncigdc/components/Links/ImageViewerLink';
import { withTheme } from '@ncigdc/theme';
import pluralize from '@ncigdc/utils/pluralize';
import { AWG } from '@ncigdc/utils/constants';


const ImageViewerLinkAsButton = styled(ImageViewerLink, {
marginLeft: '5px',
Expand Down Expand Up @@ -57,22 +57,19 @@ export default compose(
alignItems: 'center',
justifyContent: 'space-between',
padding: '0 0 2rem',
}}
>
}}>
<Row spacing="0.2rem">
<Button
onClick={() => dispatch(fetchFilesAndAdd(filters, totalFiles))}
leftIcon={<ShoppingCartIcon />}
>
onClick={() => dispatch(fetchFilesAndAdd(filters, totalFiles))}>
Add All Files to Cart
</Button>
<DownloadManifestButton fileCount={totalFiles} filters={filters} />
{!AWG ? (
filters ? (
<CreateRepositoryCaseSetButton
filters={filters}
disabled={!totalCases}
style={{ paddingLeft: '5px' }}
filters={filters}
onComplete={(setId: String) => {
push({
pathname: '/exploration',
Expand All @@ -92,22 +89,24 @@ export default compose(
},
});
}}
>
style={{ paddingLeft: '5px' }}>
{'View '}
{totalCases.toLocaleString()} {pluralize(' Case', totalCases)}
{totalCases.toLocaleString()}
{' '}
{pluralize(' Case', totalCases)}
{' in Exploration'}
</CreateRepositoryCaseSetButton>
) : (
<Button
disabled={!totalCases}
style={{ paddingLeft: '5px' }}
onClick={() =>
push({
pathname: '/exploration',
})}
>
onClick={() => push({
pathname: '/exploration',
})}
style={{ paddingLeft: '5px' }}>
{'View '}
{totalCases.toLocaleString()} {pluralize(' Case', totalCases)}
{totalCases.toLocaleString()}
{' '}
{pluralize(' Case', totalCases)}
{' in Exploration'}
</Button>
)
Expand All @@ -118,21 +117,19 @@ export default compose(
{(count: Number, loading: Boolean) => (
<span style={{ marginTop: '7px' }}>
<Tooltip
Component={count === 0 ? 'No images available' : null}
>
Component={count === 0 ? 'No images available' : null}>
<ImageViewerLinkAsButton
query={{
filters,
}}
style={
loading || count === 0
? {
backgroundColor: theme.greyScale4,
pointerEvents: 'none',
}
backgroundColor: theme.greyScale4,
pointerEvents: 'none',
}
: { cursor: 'pointer' }
}
>
}>
{loading && <Spinner style={{ marginRight: '5px' }} />}
View Images
</ImageViewerLinkAsButton>
Expand All @@ -143,7 +140,9 @@ export default compose(
)}
</Row>
<AnnotationsLink>
<i className="fa fa-edit" /> Browse Annotations
<i className="fa fa-edit" />
{' '}
Browse Annotations
</AnnotationsLink>
</Row>
);
Expand Down
Loading

0 comments on commit ae7e116

Please sign in to comment.