feat: [ritik/code-1773] Added global variable for hiding semantic search in public view

public-test-gitness
Ritik Kapoor 2024-05-07 23:20:02 +05:30
parent b58e1ddade
commit a04d766ed3
5 changed files with 12 additions and 5 deletions

View File

@ -49,7 +49,8 @@ const App: React.FC<AppProps> = React.memo(function App({
customComponents,
currentUserProfileURL = '',
defaultSettingsURL = '',
isPublicAccessEnabledOnResources = false
isPublicAccessEnabledOnResources = false,
isCurrentSessionPublic = false
}: AppProps) {
const [strings, setStrings] = useState<LanguageRecord>()
const getRequestOptions = useCallback(
@ -92,7 +93,8 @@ const App: React.FC<AppProps> = React.memo(function App({
customComponents,
currentUserProfileURL,
defaultSettingsURL,
isPublicAccessEnabledOnResources
isPublicAccessEnabledOnResources,
isCurrentSessionPublic
}}>
<IconoirProvider
iconProps={{

View File

@ -54,7 +54,8 @@ const AppContext = React.createContext<AppContextProps>({
currentUserProfileURL: '',
routingId: '',
defaultSettingsURL: '',
isPublicAccessEnabledOnResources: false
isPublicAccessEnabledOnResources: false,
isCurrentSessionPublic: false
})
export const AppContextProvider: React.FC<{ value: AppProps }> = React.memo(function AppContextProvider({

View File

@ -79,4 +79,5 @@ export interface AppProps {
currentUserProfileURL: string
defaultSettingsURL: string
isPublicAccessEnabledOnResources: boolean
isCurrentSessionPublic: boolean
}

View File

@ -51,6 +51,7 @@ ReactDOM.render(
routingId=""
defaultSettingsURL=""
isPublicAccessEnabledOnResources
isCurrentSessionPublic={false}
/>,
document.getElementById('react-root')
)

View File

@ -42,7 +42,7 @@ const KEYWORD_REGEX = /((?:(?:-{0,1})(?:repo|lang|file|case|count)):\S*|(?: or|a
const CodeSearchBar: FC<CodeSearchBarProps> = ({ value, onChange, onSearch, onKeyDown, searchMode, setSearchMode }) => {
const { getString } = useStrings()
const { hooks, routingId, defaultSettingsURL } = useAppContext()
const { hooks, routingId, defaultSettingsURL, isCurrentSessionPublic } = useAppContext()
const { SEMANTIC_SEARCH_ENABLED: isSemanticSearchFFEnabled } = hooks?.useFeatureFlags()
const { orgIdentifier, projectIdentifier } = useParams<Identifier>()
const { data: aidaSettingResponse, loading: isAidaSettingLoading } = hooks?.useGetSettingValue({
@ -51,7 +51,9 @@ const CodeSearchBar: FC<CodeSearchBarProps> = ({ value, onChange, onSearch, onKe
})
const [enableSemanticSearch, setEnableSemanticSearch] = useState<boolean>(false)
useEffect(() => {
setEnableSemanticSearch(isSemanticSearchFFEnabled && aidaSettingResponse?.data?.value == 'true')
setEnableSemanticSearch(
isSemanticSearchFFEnabled && aidaSettingResponse?.data?.value == 'true' && !isCurrentSessionPublic
)
}, [isAidaSettingLoading, isSemanticSearchFFEnabled])
const isSemanticMode = enableSemanticSearch && searchMode === SEARCH_MODE.SEMANTIC
return (