Skip to content

Commit

Permalink
fix: Assume navbar present by default and only remove padding if data…
Browse files Browse the repository at this point in the history
…set metadata errors (#517)

* branch init

* assume navbar present by default and don't remove padding unless metadata errors

* update

* update test

Co-authored-by: atarashansky <[email protected]>
  • Loading branch information
atarashansky and atarashansky authored Oct 25, 2022
1 parent 31ce63c commit fde15ae
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 30 deletions.
2 changes: 1 addition & 1 deletion client/__tests__/e2e/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const datasets = {
lasso: [
{
"coordinates-as-percent": { x1: 0.1, y1: 0.25, x2: 0.7, y2: 0.75 },
count: "1131",
count: "1094",
},
],
categorical: [
Expand Down
47 changes: 27 additions & 20 deletions client/src/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,26 +89,33 @@ async function datasetMetadataFetchAndLoad(
oldPrefix: string,
config: Config
): Promise<void> {
const datasetMetadataResponse = await fetchJson<{
metadata: DatasetMetadata;
}>("dataset-metadata", oldPrefix);

// Create new dataset array with large datasets removed
const { metadata: datasetMetadata } = datasetMetadataResponse;
const datasets = removeLargeDatasets(
datasetMetadata.collection_datasets,
globals.DATASET_MAX_CELL_COUNT
);

const { links } = config;
dispatch({
type: "dataset metadata load complete",
datasetMetadata: {
...datasetMetadata,
collection_datasets: datasets,
},
portalUrl: links["collections-home-page"],
});
try {
const datasetMetadataResponse = await fetchJson<{
metadata: DatasetMetadata;
}>("dataset-metadata", oldPrefix);

// Create new dataset array with large datasets removed
const { metadata: datasetMetadata } = datasetMetadataResponse;
const datasets = removeLargeDatasets(
datasetMetadata.collection_datasets,
globals.DATASET_MAX_CELL_COUNT
);

const { links } = config;
dispatch({
type: "dataset metadata load complete",
datasetMetadata: {
...datasetMetadata,
collection_datasets: datasets,
},
portalUrl: links["collections-home-page"],
});
} catch (error) {
dispatch({
type: "dataset metadata load error",
error,
});
}
}

interface GeneInfoAPI {
Expand Down
8 changes: 5 additions & 3 deletions client/src/components/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ interface Props {
tosURL: string | undefined;
privacyURL: string | undefined;
seamlessEnabled: boolean;
datasetMetadataError: string | null;
}

class App extends React.Component<Props> {
Expand All @@ -55,8 +56,8 @@ class App extends React.Component<Props> {
tosURL,
privacyURL,
seamlessEnabled,
datasetMetadataError,
} = this.props;

return (
<Container>
<StylesProvider injectFirst>
Expand All @@ -76,12 +77,12 @@ class App extends React.Component<Props> {
error loading cellxgene
</div>
) : null}
{seamlessEnabled && (
{(seamlessEnabled || datasetMetadataError === null) && (
<Header tosURL={tosURL} privacyURL={privacyURL} />
)}
{loading || error ? null : (
<Layout
seamlessEnabled={seamlessEnabled}
datasetMetadataError={datasetMetadataError}
renderGraph={(viewportRef: HTMLDivElement) => (
<>
<GlobalHotkeys />
Expand Down Expand Up @@ -120,4 +121,5 @@ export default connect((state: RootState) => ({
tosURL: state.config?.parameters?.about_legal_tos,
privacyURL: state.config?.parameters?.about_legal_privacy,
seamlessEnabled: selectIsSeamlessEnabled(state),
datasetMetadataError: state.datasetMetadata.error,
}))(App);
7 changes: 3 additions & 4 deletions client/src/components/framework/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { Children, useState } from "react";
import * as globals from "../../globals";

interface Props {
seamlessEnabled?: boolean;
datasetMetadataError: string | null;
renderGraph?: (viewport: HTMLDivElement) => React.ReactNode;
}

Expand All @@ -20,7 +20,7 @@ interface Props {
const Layout: React.FC<Props> = (props) => {
const [viewportRef, setViewportRef] = useState<HTMLDivElement | null>(null);

const { children, seamlessEnabled, renderGraph } = props;
const { children, datasetMetadataError, renderGraph } = props;
const [leftSidebar, rightSidebar] = Children.toArray(children);
let graphComponent = null;
if (viewportRef && renderGraph) {
Expand All @@ -30,7 +30,7 @@ const Layout: React.FC<Props> = (props) => {
<div
style={{
display: "grid",
paddingTop: seamlessEnabled ? globals.HEADER_HEIGHT_PX : 0,
paddingTop: !datasetMetadataError ? globals.HEADER_HEIGHT_PX : 0,
gridTemplateColumns: `
[left-sidebar-start] ${globals.leftSidebarWidth + 1}px
[left-sidebar-end graph-start] auto
Expand Down Expand Up @@ -90,7 +90,6 @@ const Layout: React.FC<Props> = (props) => {
};

Layout.defaultProps = {
seamlessEnabled: undefined,
renderGraph: undefined,
};
export default Layout;
2 changes: 1 addition & 1 deletion client/src/components/framework/layoutSkeleton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const WIDTH_MENUBAR = 482;
*/
function LayoutSkeleton(): JSX.Element {
return (
<Layout>
<Layout datasetMetadataError={null}>
<LeftSidebarSkeleton />
{() => (
<Controls>
Expand Down
2 changes: 1 addition & 1 deletion client/src/reducers/datasetMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const DatasetMetadata = (
portalUrl,
};
}
case "initial data load error": {
case "dataset metadata load error": {
const { error } = action as DatasetMetadataAction;

return {
Expand Down

0 comments on commit fde15ae

Please sign in to comment.