Skip to content

Commit

Permalink
revert to window.open
Browse files Browse the repository at this point in the history
  • Loading branch information
mlacadie committed Dec 12, 2024
1 parent 5167626 commit 2182d18
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 25 deletions.
4 changes: 1 addition & 3 deletions screen2.0/src/app/_mainsearch/bedupload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import React, { useCallback, useState } from "react"
import { Button, Typography, Stack, Container, IconButton } from "@mui/material"
import { useDropzone } from "react-dropzone"
import { useRouter } from 'next/navigation'
import UploadFileIcon from '@mui/icons-material/UploadFile';
import { Cancel, Search } from "@mui/icons-material"
import { LoadingButton } from "@mui/lab"
Expand All @@ -12,7 +11,6 @@ import { useLazyQuery } from "@apollo/client"
import { BED_INTERSECT_QUERY } from "./queries"

const BedUpload = (props: { assembly: "mm10" | "GRCh38", header?: boolean }) => {
const router = useRouter()

const [files, setFiles] = useState<File[]>([])
const [loading, setLoading] = useState(false)
Expand Down Expand Up @@ -84,7 +82,7 @@ const BedUpload = (props: { assembly: "mm10" | "GRCh38", header?: boolean }) =>
} else {
sessionStorage.setItem("warning", "false")
}
router.push(`/search?intersect=t&assembly=${props.assembly}`)
window.open(`/search?intersect=t&assembly=${props.assembly}`, '_self')

},
//Error
Expand Down
6 changes: 2 additions & 4 deletions screen2.0/src/app/_mainsearch/ccreautocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ import { IconButton, Stack } from "@mui/material"
import { Search } from "@mui/icons-material"
import { useQuery } from "@apollo/client"
import { client } from "../search/_ccredetails/client"
import { useRouter } from "next/navigation"

export const CcreAutoComplete: React.FC<{ assembly: string, header?: boolean }> = (props) => {
const [value, setValue] = useState(null)
const [inputValue, setInputValue] = useState("")
const [options, setOptions] = useState([])
const [ccreAccessions, setCcreAccessions] = useState([])
const router = useRouter();

const {loading: loadingOptions} = useQuery(CCRE_AUTOCOMPLETE_QUERY,
{
Expand Down Expand Up @@ -73,7 +71,7 @@ export const CcreAutoComplete: React.FC<{ assembly: string, header?: boolean }>
onKeyDown={(event) => {
if (event.key === "Enter") {
event.defaultPrevented = true
router.push(handleSubmit())
window.open(handleSubmit(), '_self')
}
}}
value={value}
Expand Down Expand Up @@ -133,7 +131,7 @@ export const CcreAutoComplete: React.FC<{ assembly: string, header?: boolean }>
)
}}
/>
<IconButton aria-label="Search" type="submit" onClick={() => router.push(handleSubmit())} sx={{ color: `${props.header ? "white" : "black"}`, maxHeight: "100%" }}>
<IconButton aria-label="Search" type="submit" onClick={() => window.open(handleSubmit(), '_self')} sx={{ color: `${props.header ? "white" : "black"}`, maxHeight: "100%" }}>
<Search />
</IconButton>
</Stack>
Expand Down
8 changes: 3 additions & 5 deletions screen2.0/src/app/_mainsearch/celltypeautocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ import { Search } from "@mui/icons-material"
import { parseGenomicRegion } from "./parsegenomicregion"
import { biosampleQuery } from "../../common/lib/queries"
import { RegistryBiosample } from "../search/types"
import { useRouter } from "next/navigation"

export const CelltypeAutocomplete: React.FC<{ assembly: string, header?: boolean }> = (props) => {
const [valueCellType, setValueCellType] = useState<RegistryBiosample>(null)
const [valueRegion, setValueRegion] = useState("")
const [inputValue, setInputValue] = useState("")
const [options, setOptions] = useState<RegistryBiosample[]>([])
const router = useRouter();

/**
* @todo move this fetch to client side. Invoking server action to fetch data has no clear benefit
Expand Down Expand Up @@ -66,7 +64,7 @@ export const CelltypeAutocomplete: React.FC<{ assembly: string, header?: boolean
onKeyDown={(event) => {
if (event.key === "Enter" && valueCellType) {
event.defaultPrevented = true
router.push(handleSubmit())
window.open(handleSubmit(), '_self')
}
}}
value={valueCellType}
Expand Down Expand Up @@ -143,7 +141,7 @@ export const CelltypeAutocomplete: React.FC<{ assembly: string, header?: boolean
}}
onKeyDown={(event) => {
if (event.key === "Enter" && valueCellType) {
router.push(handleSubmit())
window.open(handleSubmit(), '_self')
}
if (event.key === "Tab" && !valueRegion) {
const defaultGenomicRegion = `chr12:${(53380176).toLocaleString()}-${(53416446).toLocaleString()}`
Expand All @@ -162,7 +160,7 @@ export const CelltypeAutocomplete: React.FC<{ assembly: string, header?: boolean
}}
size={props.header ? "small" : "medium"}
/>
<IconButton aria-label="Search" type="submit" onClick={() => router.push(handleSubmit())} sx={{ color: `${props.header ? "white" : "black"}`, maxHeight: "100%" }}>
<IconButton aria-label="Search" type="submit" onClick={() => window.open(handleSubmit(), '_self')} sx={{ color: `${props.header ? "white" : "black"}`, maxHeight: "100%" }}>
<Search />
</IconButton>
</Stack>
Expand Down
10 changes: 4 additions & 6 deletions screen2.0/src/app/_mainsearch/genomicregion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { useState, SetStateAction, useEffect, useMemo } from "react"
import { Search } from "@mui/icons-material"
import Grid from "@mui/material/Grid2"
import { parseGenomicRegion } from "./parsegenomicregion"
import { useRouter } from "next/navigation"

//https://mui.com/material-ui/react-text-field/#integration-with-3rd-party-input-libraries
//For formatting the start/end as it's being entered.
Expand Down Expand Up @@ -53,7 +52,6 @@ const GenomicRegion = (props: { assembly: "mm10" | "GRCh38"; header?: boolean })
const [error, setError] = useState(false)
const [sepErrStart, setSepErrStart] = useState(false)
const [sepErrEnd, setSepErrEnd] = useState(false)
const router = useRouter();

const handleChange = (event: { target: { value: SetStateAction<string> } }) => {
setValue(event.target.value)
Expand Down Expand Up @@ -267,7 +265,7 @@ const GenomicRegion = (props: { assembly: "mm10" | "GRCh38"; header?: boolean })
}}
onKeyDown={(event) => {
if (event.key === "Enter") {
router.push(url);
window.open(url, '_self')
}
if (event.key === "Tab" && !start) {
setStart("53380176")
Expand Down Expand Up @@ -304,7 +302,7 @@ const GenomicRegion = (props: { assembly: "mm10" | "GRCh38"; header?: boolean })
}}
onKeyDown={(event) => {
if (event.key === "Enter") {
router.push(url);
window.open(url, '_self')
}
if (event.key === "Tab" && !end) {
setEnd("53416446")
Expand Down Expand Up @@ -349,7 +347,7 @@ const GenomicRegion = (props: { assembly: "mm10" | "GRCh38"; header?: boolean })
onKeyDown={(event) => {
if (event.key === "Enter") {
if (!error) {
router.push(url);
window.open(url, '_self')
}
}
if (event.key === "Tab" && !value) {
Expand Down Expand Up @@ -381,7 +379,7 @@ const GenomicRegion = (props: { assembly: "mm10" | "GRCh38"; header?: boolean })
sx={{ color: `${props.header ? "white" : "black"}`, maxHeight: "100%" }}
onClick={() => {
if ((inputType !== "Separated" && !error) || (inputType === "Separated" && !sepErrStart && !sepErrEnd)) {
router.push(url);
window.open(url, '_self')
}
}}
>
Expand Down
4 changes: 1 addition & 3 deletions screen2.0/src/app/_mainsearch/mainsearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import BedUpload from "./bedupload"
import GenomicRegion from "./genomicregion"
import { GeneAutocomplete } from "../search/_geneAutocomplete/GeneAutocomplete"
import { GeneInfo } from "../search/_geneAutocomplete/types"
import { useRouter } from "next/navigation"

export type MainSearchProps = InputBaseProps & {
//false for human, true for mouse
Expand All @@ -22,7 +21,6 @@ export type MainSearchProps = InputBaseProps & {
export const MainSearch: React.FC<MainSearchProps> = (props: MainSearchProps) => {
const [assembly, setAssembly] = useState<"GRCh38" | "mm10">("GRCh38")
const [selectedSearch, setSelectedSearch] = useState<string>("Genomic Region")
const router = useRouter();

const handleSearchChange = (event: SelectChangeEvent) => {
setSelectedSearch(event.target.value)
Expand All @@ -40,7 +38,7 @@ export const MainSearch: React.FC<MainSearchProps> = (props: MainSearchProps) =>
const start = gene.coordinates.start
const end = gene.coordinates.end
const name = gene.name
router.push(`/search?assembly=${assembly}&chromosome=${chrom}&start=${start}&end=${end}&gene=${name}&tssDistance=0`)
window.open(`/search?assembly=${assembly}&chromosome=${chrom}&start=${start}&end=${end}&gene=${name}&tssDistance=0`, '_self')
}
}

Expand Down
6 changes: 2 additions & 4 deletions screen2.0/src/app/_mainsearch/snpautocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ import Config from "../../config.json"
import Grid from "@mui/material/Grid2"
import { IconButton, Stack } from "@mui/material"
import { Search } from "@mui/icons-material"
import { useRouter } from "next/navigation"

export const SnpAutoComplete: React.FC<{ assembly: string, header?: boolean }> = (props) => {
const [value, setValue] = useState(null)
const [inputValue, setInputValue] = useState("")
const [options, setOptions] = useState([])
const [snpids, setSnpIds] = useState([])
const router = useRouter();

const onSearchChange = async (value: string, assembly: string) => {
setOptions([])
Expand Down Expand Up @@ -79,7 +77,7 @@ export const SnpAutoComplete: React.FC<{ assembly: string, header?: boolean }> =
onKeyDown={(event) => {
if (event.key === "Enter" && value) {
event.defaultPrevented = true
router.push(handleSubmit())
window.open(handleSubmit(), '_self')
}
}}
value={value}
Expand Down Expand Up @@ -141,7 +139,7 @@ export const SnpAutoComplete: React.FC<{ assembly: string, header?: boolean }> =
)
}}
/>
<IconButton aria-label="Search" type="submit" onClick={() => router.push(handleSubmit())} sx={{ color: `${props.header ? "white" : "black"}`, maxHeight: "100%" }}>
<IconButton aria-label="Search" type="submit" onClick={() => window.open(handleSubmit(), '_self')} sx={{ color: `${props.header ? "white" : "black"}`, maxHeight: "100%" }}>
<Search />
</IconButton>
</Stack>
Expand Down

0 comments on commit 2182d18

Please sign in to comment.