diff --git a/src/components/custom/edit/dataset/AncestorIds.jsx b/src/components/custom/edit/dataset/AncestorIds.jsx index c2b7577f..42301266 100644 --- a/src/components/custom/edit/dataset/AncestorIds.jsx +++ b/src/components/custom/edit/dataset/AncestorIds.jsx @@ -1,4 +1,4 @@ -import React, {useContext, useEffect, useState} from 'react'; +import React, {useContext, useState} from 'react'; import {Form} from 'react-bootstrap'; import {Results, SearchBox} from "@elastic/react-search-ui"; import {Layout} from "@elastic/react-search-ui-views"; @@ -16,11 +16,13 @@ import {getUBKGFullName} from "../../js/functions"; import SenNetPopover from "../../../SenNetPopover"; import SearchUIContainer from 'search-ui/components/core/SearchUIContainer'; import FacetsContent from '../../search/FacetsContent'; -import SearchUIContext from 'search-ui/components/core/SearchUIContext'; import AppContext from "../../../../context/AppContext"; +import { useSearchUIContext } from "search-ui/components/core/SearchUIContext"; function BodyContent({ handleChangeAncestor, data }) { - const { wasSearched, filters } = useContext(SearchUIContext) + + const { wasSearched, filters } = useSearchUIContext(); + const {hasAuthenticationCookie, isUnauthorized } = useContext(AppContext) const addConditional = (key, entity) => { valid_dataset_ancestor_config['searchQuery']['conditionalFacets'][key] = ({filters}) => { diff --git a/src/components/custom/edit/sample/AncestorId.jsx b/src/components/custom/edit/sample/AncestorId.jsx index f0ad7157..d854d91b 100644 --- a/src/components/custom/edit/sample/AncestorId.jsx +++ b/src/components/custom/edit/sample/AncestorId.jsx @@ -13,13 +13,13 @@ import SelectedFilters from "../../layout/SelectedFilters"; import {getUBKGFullName} from "../../js/functions"; import SenNetPopover from "../../../SenNetPopover"; import SearchUIContainer from 'search-ui/components/core/SearchUIContainer'; -import SearchUIContext from 'search-ui/components/core/SearchUIContext'; import FacetsContent from '../../search/FacetsContent'; import AppContext from "../../../../context/AppContext"; +import { useSearchUIContext } from "search-ui/components/core/SearchUIContext"; function BodyContent({ handleChangeSource, data }) { const {hasAuthenticationCookie, isUnauthorized } = useContext(AppContext) - const { filters } = useContext(SearchUIContext) + const { filters } = useSearchUIContext(); const includedExclude = useRef(false) exclude_dataset_config['searchQuery']['conditionalFacets']['rui_location'] = ({filters}) => { @@ -51,6 +51,12 @@ function BodyContent({ handleChangeSource, data }) { } const AncestorId = ({fetchSource, onChange, source, data}) => { + const { + adminGroup, + authorized, + hasAuthenticationCookie + } = useContext(AppContext); + const [showHideModal, setShowHideModal] = useState(false) const handleSearchFormSubmit = (event, onSubmit) => { @@ -77,6 +83,12 @@ const AncestorId = ({fetchSource, onChange, source, data}) => { hideModal(); } + const authState = { + isAuthenticated: hasAuthenticationCookie() === true, + isAuthorized: authorized === true, + isAdmin: adminGroup === true + } + return ( <>