Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Platform]: Use new Navigate component #577

Merged
merged 3 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions packages/sections/src/credibleSet/GWASColoc/Body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,22 @@ import {
ScientificNotation,
OtTable,
Tooltip,
Navigate,
} from "ui";
import { naLabel } from "../../constants";
import { definition } from ".";
import Description from "./Description";
import GWAS_COLOC_QUERY from "./GWASColocQuery.gql";
import { mantissaExponentComparator, variantComparator } from "../../utils/comparators";
import { getStudyCategory } from "../../utils/getStudyCategory";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faArrowRightToBracket } from "@fortawesome/free-solid-svg-icons";
import { Box } from "@mui/material";

const columns = [
{
id: "otherStudyLocus.studyLocusId",
label: "Navigate",
renderCell: ({ otherStudyLocus }) => {
if (!otherStudyLocus?.variant) return naLabel;
return (<Box sx={{ display: "flex" }}>
<Link to={`./${otherStudyLocus.studyLocusId}`}>
<FontAwesomeIcon icon={faArrowRightToBracket} />
</Link>
</Box>)
return <Navigate to={`./${otherStudyLocus.studyLocusId}`} />;
},
},
{
Expand Down
10 changes: 2 additions & 8 deletions packages/sections/src/credibleSet/GWASMolQTL/Body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,22 @@ import {
ScientificNotation,
OtTable,
Tooltip,
Navigate,
} from "ui";
import { naLabel } from "../../constants";
import { definition } from ".";
import Description from "./Description";
import GWAS_COLOC_QUERY from "./GWASMolQTLColocQuery.gql";
import { mantissaExponentComparator, variantComparator } from "../../utils/comparators";
import { getStudyCategory } from "../../utils/getStudyCategory";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faArrowRightToBracket } from "@fortawesome/free-solid-svg-icons";
import { Box } from "@mui/material";

const columns = [
{
id: "otherStudyLocus.studyLocusId",
label: "Navigate",
renderCell: ({ otherStudyLocus }) => {
if (!otherStudyLocus?.variant) return naLabel;
return (<Box sx={{ display: "flex" }}>
<Link to={`./${otherStudyLocus.studyLocusId}`}>
<FontAwesomeIcon icon={faArrowRightToBracket} />
</Link>
</Box>)
return <Navigate to={`./${otherStudyLocus.studyLocusId}`} />;
},
},
{
Expand Down
17 changes: 4 additions & 13 deletions packages/sections/src/evidence/GWASCredibleSets/Body.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useQuery } from "@apollo/client";
// import { Tooltip } from "@mui/material";
import {
SectionItem,
Link,
Expand All @@ -9,6 +8,7 @@ import {
ClinvarStars,
OtScoreLinearBar,
Tooltip,
Navigate,
} from "ui";

import { naLabel, sectionsBaseSizeQuery, credsetConfidenceMap } from "../../constants";
Expand All @@ -17,31 +17,22 @@ import Description from "./Description";
import { dataTypesMap } from "../../dataTypes";
import GWAS_CREDIBLE_SETS_QUERY from "./sectionQuery.gql";
import { mantissaExponentComparator } from "../../utils/comparators";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faArrowRightToBracket } from "@fortawesome/free-solid-svg-icons";
import { Box } from "@mui/material";

function getColumns() {
return [
{
id: "credibleSet",
label: "Navigate",
renderCell: ({ credibleSet }) => {
return (
<Box sx={{ display: "flex", justifyContent: "center" }}>
<Link to={`/credible-set/${credibleSet?.studyLocusId}`}>
<FontAwesomeIcon icon={faArrowRightToBracket} />
</Link>
</Box>
);
return <Navigate to={`/credible-set/${credibleSet?.studyLocusId}`} />;
},
},
{
id: "variantId",
label: "Lead Variant",
renderCell: ({ credibleSet }) => {
const variant = credibleSet.variant;
if (variant?.id) return <Link to={`/variant/${variant?.id}`}>{variant?.id}</Link>;
const variantId = credibleSet?.variant?.id;
if (variantId) return <Link to={`/variant/${variantId}`}>{variantId}</Link>;
return naLabel;
},
},
Expand Down
10 changes: 2 additions & 8 deletions packages/sections/src/study/GWASCredibleSets/Body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@ import {
OtScoreLinearBar,
OtTable,
useBatchQuery,
Navigate,
} from "ui";
import { Box } from "@mui/material";
import { naLabel, credsetConfidenceMap, initialResponse, table5HChunkSize } from "../../constants";
import { definition } from ".";
import Description from "./Description";
import GWAS_CREDIBLE_SETS_QUERY from "./GWASCredibleSetsQuery.gql";
import { mantissaExponentComparator, variantComparator } from "../../utils/comparators";
import ManhattanPlot from "./ManhattanPlot";
import { faArrowRightToBracket } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { useEffect, useState } from "react";
import { responseType } from "ui/src/types/response";

Expand All @@ -26,11 +24,7 @@ const columns = [
id: "studyLocusId",
label: "Navigate",
renderCell: ({ studyLocusId }) => (
<Box sx={{ display: "flex" }}>
<Link to={`/credible-set/${studyLocusId}`}>
<FontAwesomeIcon icon={faArrowRightToBracket} />
</Link>
</Box>
<Navigate to={`/credible-set/${studyLocusId}`} />
),
},
{
Expand Down
20 changes: 10 additions & 10 deletions packages/sections/src/study/QTLCredibleSets/Body.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import { useQuery } from "@apollo/client";
import { Link, SectionItem, ScientificNotation, DisplayVariantId, OtTable } from "ui";
import { Box } from "@mui/material";
import {
Link,
SectionItem,
ScientificNotation,
DisplayVariantId,
OtTable,
Navigate,
} from "ui";
import { naLabel } from "../../constants";
import { definition } from ".";
import Description from "./Description";
import QTL_CREDIBLE_SETS_QUERY from "./QTLCredibleSetsQuery.gql";
import { mantissaExponentComparator, variantComparator } from "../../utils/comparators";
import { faArrowRightToBracket } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";

const columns = [
{
id: "studyLocusId",
label: "Navigate",
renderCell: ({ studyLocusId }) => (
<Box sx={{ display: "flex" }}>
<Link to={`/credible-set/${studyLocusId}`}>
<FontAwesomeIcon icon={faArrowRightToBracket} />
</Link>
</Box>
),
<Navigate to={`/credible-set/${studyLocusId}`} />
)
},
{
id: "leadVariant",
Expand Down
9 changes: 2 additions & 7 deletions packages/sections/src/variant/GWASCredibleSets/Body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
ClinvarStars,
OtScoreLinearBar,
useBatchQuery,
Navigate,
} from "ui";
import { Box, Chip } from "@mui/material";
import { credsetConfidenceMap, initialResponse, naLabel, table5HChunkSize } from "../../constants";
Expand All @@ -17,8 +18,6 @@ import GWAS_CREDIBLE_SETS_QUERY from "./GWASCredibleSetsQuery.gql";
import { Fragment } from "react/jsx-runtime";
import { mantissaExponentComparator, variantComparator } from "../../utils/comparators";
import PheWasPlot from "./PheWasPlot";
import { faArrowRightToBracket } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { useEffect, useState } from "react";
import { responseType } from "ui/src/types/response";

Expand All @@ -34,11 +33,7 @@ function getColumns({ id, referenceAllele, alternateAllele }: getColumnsType) {
id: "studyLocusId",
label: "Navigate",
renderCell: ({ studyLocusId }) => (
<Box sx={{ display: "flex", justifyContent: "center" }}>
<Link to={`/credible-set/${studyLocusId}`}>
<FontAwesomeIcon icon={faArrowRightToBracket} />
</Link>
</Box>
<Navigate to={`/credible-set/${studyLocusId}`} />
),
},
{
Expand Down
9 changes: 2 additions & 7 deletions packages/sections/src/variant/QTLCredibleSets/Body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
Tooltip,
ClinvarStars,
useBatchQuery,
Navigate,
} from "ui";
import { Box, Chip } from "@mui/material";
import { credsetConfidenceMap, initialResponse, naLabel, table5HChunkSize } from "../../constants";
Expand All @@ -16,8 +17,6 @@ import QTL_CREDIBLE_SETS_QUERY from "./QTLCredibleSetsQuery.gql";
import { mantissaExponentComparator, variantComparator } from "../../utils/comparators";
import { ReactNode, useEffect, useState } from "react";
import { responseType } from "ui/src/types/response";
import { faArrowRightToBracket } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";

type getColumnsType = {
id: string;
Expand All @@ -31,11 +30,7 @@ function getColumns({ id, referenceAllele, alternateAllele }: getColumnsType) {
id: "studyLocusId",
label: "Navigate",
renderCell: ({ studyLocusId }) => (
<Box sx={{ display: "flex", justifyContent: "center" }}>
<Link to={`/credible-set/${studyLocusId}`}>
<FontAwesomeIcon icon={faArrowRightToBracket} />
</Link>
</Box>
<Navigate to={`/credible-set/${studyLocusId}`} />
),
},
{
Expand Down
19 changes: 19 additions & 0 deletions packages/ui/src/components/Navigate.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

import { Box } from "@mui/material";
import Link from "./Link";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faArrowRightToBracket } from "@fortawesome/free-solid-svg-icons";

type NavigateProps = {
to: string;
};

export default function Navigate({ to }: NavigateProps) {
return (
<Box display="flex" justifyContent="center">
<Link to={to}>
<FontAwesomeIcon icon={faArrowRightToBracket} />
</Link>
</Box>
);
}
1 change: 1 addition & 0 deletions packages/ui/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export { default as SummaryContainer } from "./components/Summary/SummaryContain
export { default as SummaryItem } from "./components/Summary/SummaryItem";
export { default as Tooltip } from "./components/Tooltip";
export { default as Link } from "./components/Link";
export { default as Navigate } from "./components/Navigate";
export { default as Chip } from "./components/Chip";
export { default as ChipList } from "./components/ChipList";
export { default as TooltipStyledLabel } from "./components/TooltipStyledLabel";
Expand Down