mirror of https://github.com/harness/drone.git
feat: [ritik/code-1773] Added global variable for hiding semantic search in public view
parent
b58e1ddade
commit
a04d766ed3
|
@ -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={{
|
||||
|
|
|
@ -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({
|
||||
|
|
|
@ -79,4 +79,5 @@ export interface AppProps {
|
|||
currentUserProfileURL: string
|
||||
defaultSettingsURL: string
|
||||
isPublicAccessEnabledOnResources: boolean
|
||||
isCurrentSessionPublic: boolean
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@ ReactDOM.render(
|
|||
routingId=""
|
||||
defaultSettingsURL=""
|
||||
isPublicAccessEnabledOnResources
|
||||
isCurrentSessionPublic={false}
|
||||
/>,
|
||||
document.getElementById('react-root')
|
||||
)
|
||||
|
|
|
@ -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 (
|
||||
|
|
Loading…
Reference in New Issue