Skip to content

Commit

Permalink
fix: existing tests after refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
kaloster committed Jul 20, 2024
1 parent cd60fde commit 50dae4e
Show file tree
Hide file tree
Showing 15 changed files with 56 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .infra/rdev/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ stack:
services:
explorer:
image:
tag: sha-44567a92
tag: sha-419fde2c
replicaCount: 1
env:
# env vars common to all deployment stages
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import React from "react";
import { kebabCase } from "lodash";
import { InfoContainer, InfoWrapper } from "../style";
import { ErrorInfo, LoadingInfo, NoneSelected, ShowInfo } from "../loadingInfo";
import {
ErrorInfo,
LoadingInfo,
NoneSelected,
ShowInfo,
} from "../infoPanelParts";
import { ExtendedInfoProps } from "../types";

function ContainerInfo(props: ExtendedInfoProps) {
Expand All @@ -21,19 +26,20 @@ function ContainerInfo(props: ExtendedInfoProps) {

const entityTag = kebabCase(entity);

const wrapperTestId = `${entity === "Gene" ? symbol : id}:${entityTag}-info`;

return (
<InfoWrapper
id={`${entityTag}info_wrapper`}
data-testid={`${id}:${entityTag}-info`}
>
<InfoWrapper id={`${entityTag}info_wrapper`} data-testid={wrapperTestId}>
<InfoContainer id={`${entityTag}-info`}>
{/* Loading */}
{(name || symbol) && !error && loading && (
<LoadingInfo name={name} entity={entity} />
)}

{/* None Selected */}
{!entity && error === null && <NoneSelected entity={entity} />}
{name === "" && error === null && !loading && (
<NoneSelected entity={entity} />
)}

{/* Error */}
{error && <ErrorInfo name={name} entity={entity} />}
Expand Down
32 changes: 32 additions & 0 deletions client/src/components/geneExpression/infoPanel/connect.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { ChangeEvent, useEffect, useState } from "react";
import { AppDispatch } from "../../../reducers";

function useConnect({
dispatch,
activeTab,
}: {
dispatch: AppDispatch;
activeTab: string;
}) {
const [value, setValue] = useState(1);

const handleTabsChange = (
_: ChangeEvent<Record<string, unknown>>,
tabsValue: unknown
) => {
setValue(tabsValue as number);
dispatch({
type: "toggle active info panel",
activeTab:
tabsValue === 0 ? "Gene" : tabsValue === 1 ? "CellType" : "Dataset",
});
};

useEffect(() => {
setValue(activeTab === "Gene" ? 0 : activeTab === "CellType" ? 1 : 2);
}, [activeTab]);

return { value, handleTabsChange };
}

export default useConnect;
27 changes: 6 additions & 21 deletions client/src/components/geneExpression/infoPanel/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, ChangeEvent, useEffect } from "react";
import React from "react";
import { connect } from "react-redux";
import { AnchorButton, ButtonGroup } from "@blueprintjs/core";
import { Tabs, Tab } from "czifui";
Expand All @@ -9,30 +9,15 @@ import {
InfoPanelHeader,
InfoPanelWrapper,
} from "./style";
import CellTypeInfo from "./cellTypeInfo";
import GeneInfo from "./geneInfo";
import DatasetInfo from "./datasetInfo";
import CellTypeInfo from "./infoPanelCellType";
import GeneInfo from "./infoPanelGene";
import DatasetInfo from "./infoPanelDataset";
import { Props, mapStateToProps } from "./types";
import useConnect from "./connect";

function InfoPanel(props: Props) {
const { activeTab, dispatch, infoPanelMinimized, infoPanelHidden } = props;
const [value, setValue] = useState(1);

const handleTabsChange = (
_: ChangeEvent<Record<string, unknown>>,
tabsValue: unknown
) => {
setValue(tabsValue as number);
dispatch({
type: "toggle active info panel",
activeTab:
tabsValue === 0 ? "Gene" : tabsValue === 1 ? "CellType" : "Dataset",
});
};

useEffect(() => {
setValue(activeTab === "Gene" ? 0 : activeTab === "CellType" ? 1 : 2);
}, [activeTab]);
const { value, handleTabsChange } = useConnect({ dispatch, activeTab });

return (
<InfoPanelWrapper
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { connect } from "react-redux";
import { Props, mapStateToProps } from "./types";
import ContainerInfo from "../common/containerInfo";
import ContainerInfo from "../common/infoPanelContainer";
import { CELLGUIDE_URL } from "../common/constants";

function CellTypeInfo(props: Props) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { connect } from "react-redux";
import { Props, mapStateToProps } from "./types";
import ContainerInfo from "../common/containerInfo";
import ContainerInfo from "../common/infoPanelContainer";

function GeneInfo(props: Props) {
const { geneInfo } = props;
Expand Down
3 changes: 1 addition & 2 deletions client/src/reducers/controls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ const Controls = (
activeTab: ActiveTab.Dataset,
infoPanelHidden: true,
infoPanelMinimized: false,
imageOpacity: 100,
dotOpacity: 100,
unsMetadata: {
imageWidth: 1955,
imageHeight: 1955,
Expand Down Expand Up @@ -212,6 +210,7 @@ const Controls = (
...state,
activeTab: action.activeTab,
infoPanelHidden: false,
infoPanelMinimized: false,
};
}
case "close info panel": {
Expand Down
3 changes: 2 additions & 1 deletion server/common/utils/cell_type_info.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import requests
from typing import Dict, List, TypedDict, cast

import requests

from server.common.constants import CELLGUIDE_BASE_URL


Expand Down

0 comments on commit 50dae4e

Please sign in to comment.