Skip to content

Commit

Permalink
[Platform]: Rollback AotF search input in public (#400)
Browse files Browse the repository at this point in the history
  • Loading branch information
carcruz authored Jun 26, 2024
1 parent fc8bbeb commit 4a4b1cf
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { useEffect, useState } from "react";
import { Grid, Input, IconButton } from "@mui/material";
import { styled } from "@mui/material/styles";
import { faXmark, faMagnifyingGlass } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { useDebounce } from "ui";
import useAotfContext from "../hooks/useAotfContext";

const InputContainer = styled(Grid)({
marginRight: "15px",
width: "250px",
"& input": {
width: "220px",
},
});

function SearchInput({ placeholder = "Search" }) {
const { handleSearchInputChange } = useAotfContext();
const [inputValue, setInputValue] = useState("");
const debouncedInputValue = useDebounce(inputValue, 200);

const handleInputChange = e => {
setInputValue(e.target.value);
};

const handleInputClean = () => {
setInputValue("");
};

useEffect(
() => {
handleSearchInputChange(debouncedInputValue);
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[debouncedInputValue]
);

return (
<InputContainer container>
<Grid item xs={12}>
<Input
name="associationsSearchInput"
autoComplete="off"
startAdornment={<FontAwesomeIcon icon={faMagnifyingGlass} />}
endAdornment={
!!inputValue && (
<IconButton onClick={handleInputClean}>
<FontAwesomeIcon icon={faXmark} size="2xs" />
</IconButton>
)
}
placeholder={placeholder}
label="Filter"
onChange={handleInputChange}
value={inputValue}
/>
</Grid>
</InputContainer>
);
}

export default SearchInput;
1 change: 1 addition & 0 deletions apps/platform/src/components/AssociationsToolkit/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export { default as TableAssociations } from "./components/Table/TableAssociatio
export { default as TargetPrioritisationSwitch } from "./components/TargetPrioritisationSwitch";
export { default as DataDownloader } from "./components/DataDownloader";
export { default as DataUploader } from "./components/DataUploader/DataUploader";
export { default as SearchInput } from "./components/SearchInput";
export { default as AotfApiPlayground } from "./components/AotfApiPlayground";
export {
default as AssociationsContext,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ReactElement } from "react";
import { Box, Divider } from "@mui/material";
import { usePermissions } from "ui";
import {
TableAssociations,
AdvanceOptionsMenu,
Expand All @@ -9,6 +10,7 @@ import {
ControlsSection,
DataUploader,
AotfApiPlayground,
SearchInput,
} from "../../../components/AssociationsToolkit";
import { ENTITY } from "../../../components/AssociationsToolkit/types";
import DISEASE_ASSOCIATIONS_QUERY from "./DiseaseAssociationsQuery.gql";
Expand All @@ -19,6 +21,7 @@ type DiseaseAssociationsProps = {
};

function DiseaseAssociations(pros: DiseaseAssociationsProps): ReactElement {
const { isPartnerPreview } = usePermissions();
return (
<AssociationsProvider
id={pros.efoId}
Expand All @@ -27,7 +30,7 @@ function DiseaseAssociations(pros: DiseaseAssociationsProps): ReactElement {
>
<ControlsSection>
<Box sx={{ flex: 2, display: "flex", flexWrap: "wrap", gap: theme => theme.spacing(2) }}>
<FacetsSearch />
{isPartnerPreview ? <FacetsSearch /> : <SearchInput />}
<AdvanceOptionsMenu />
<DataUploader />
<Divider orientation="vertical" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ReactElement } from "react";
import { Box, Divider } from "@mui/material";
import { usePermissions } from "ui";
import {
TableAssociations,
AdvanceOptionsMenu,
Expand All @@ -8,6 +9,7 @@ import {
ControlsSection,
DataUploader,
AotfApiPlayground,
SearchInput,
} from "../../../components/AssociationsToolkit";
import { ENTITY } from "../../../components/AssociationsToolkit/types";
import TARGET_ASSOCIATIONS_QUERY from "./TargetAssociationsQuery.gql";
Expand All @@ -18,11 +20,12 @@ type TargetAssociationsProps = {
};

function TargetAssociations({ ensgId }: TargetAssociationsProps): ReactElement {
const { isPartnerPreview } = usePermissions();
return (
<AssociationsProvider id={ensgId} entity={ENTITY.TARGET} query={TARGET_ASSOCIATIONS_QUERY}>
<ControlsSection>
<Box sx={{ flex: 2, display: "flex", flexWrap: "wrap", gap: theme => theme.spacing(2) }}>
<FacetsSearch />
{isPartnerPreview ? <FacetsSearch /> : <SearchInput />}
<AdvanceOptionsMenu />
<DataUploader />
<Divider orientation="vertical" />
Expand Down

0 comments on commit 4a4b1cf

Please sign in to comment.