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,
|
customComponents,
|
||||||
currentUserProfileURL = '',
|
currentUserProfileURL = '',
|
||||||
defaultSettingsURL = '',
|
defaultSettingsURL = '',
|
||||||
isPublicAccessEnabledOnResources = false
|
isPublicAccessEnabledOnResources = false,
|
||||||
|
isCurrentSessionPublic = false
|
||||||
}: AppProps) {
|
}: AppProps) {
|
||||||
const [strings, setStrings] = useState<LanguageRecord>()
|
const [strings, setStrings] = useState<LanguageRecord>()
|
||||||
const getRequestOptions = useCallback(
|
const getRequestOptions = useCallback(
|
||||||
|
@ -92,7 +93,8 @@ const App: React.FC<AppProps> = React.memo(function App({
|
||||||
customComponents,
|
customComponents,
|
||||||
currentUserProfileURL,
|
currentUserProfileURL,
|
||||||
defaultSettingsURL,
|
defaultSettingsURL,
|
||||||
isPublicAccessEnabledOnResources
|
isPublicAccessEnabledOnResources,
|
||||||
|
isCurrentSessionPublic
|
||||||
}}>
|
}}>
|
||||||
<IconoirProvider
|
<IconoirProvider
|
||||||
iconProps={{
|
iconProps={{
|
||||||
|
|
|
@ -54,7 +54,8 @@ const AppContext = React.createContext<AppContextProps>({
|
||||||
currentUserProfileURL: '',
|
currentUserProfileURL: '',
|
||||||
routingId: '',
|
routingId: '',
|
||||||
defaultSettingsURL: '',
|
defaultSettingsURL: '',
|
||||||
isPublicAccessEnabledOnResources: false
|
isPublicAccessEnabledOnResources: false,
|
||||||
|
isCurrentSessionPublic: false
|
||||||
})
|
})
|
||||||
|
|
||||||
export const AppContextProvider: React.FC<{ value: AppProps }> = React.memo(function AppContextProvider({
|
export const AppContextProvider: React.FC<{ value: AppProps }> = React.memo(function AppContextProvider({
|
||||||
|
|
|
@ -79,4 +79,5 @@ export interface AppProps {
|
||||||
currentUserProfileURL: string
|
currentUserProfileURL: string
|
||||||
defaultSettingsURL: string
|
defaultSettingsURL: string
|
||||||
isPublicAccessEnabledOnResources: boolean
|
isPublicAccessEnabledOnResources: boolean
|
||||||
|
isCurrentSessionPublic: boolean
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,7 @@ ReactDOM.render(
|
||||||
routingId=""
|
routingId=""
|
||||||
defaultSettingsURL=""
|
defaultSettingsURL=""
|
||||||
isPublicAccessEnabledOnResources
|
isPublicAccessEnabledOnResources
|
||||||
|
isCurrentSessionPublic={false}
|
||||||
/>,
|
/>,
|
||||||
document.getElementById('react-root')
|
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 CodeSearchBar: FC<CodeSearchBarProps> = ({ value, onChange, onSearch, onKeyDown, searchMode, setSearchMode }) => {
|
||||||
const { getString } = useStrings()
|
const { getString } = useStrings()
|
||||||
const { hooks, routingId, defaultSettingsURL } = useAppContext()
|
const { hooks, routingId, defaultSettingsURL, isCurrentSessionPublic } = useAppContext()
|
||||||
const { SEMANTIC_SEARCH_ENABLED: isSemanticSearchFFEnabled } = hooks?.useFeatureFlags()
|
const { SEMANTIC_SEARCH_ENABLED: isSemanticSearchFFEnabled } = hooks?.useFeatureFlags()
|
||||||
const { orgIdentifier, projectIdentifier } = useParams<Identifier>()
|
const { orgIdentifier, projectIdentifier } = useParams<Identifier>()
|
||||||
const { data: aidaSettingResponse, loading: isAidaSettingLoading } = hooks?.useGetSettingValue({
|
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)
|
const [enableSemanticSearch, setEnableSemanticSearch] = useState<boolean>(false)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setEnableSemanticSearch(isSemanticSearchFFEnabled && aidaSettingResponse?.data?.value == 'true')
|
setEnableSemanticSearch(
|
||||||
|
isSemanticSearchFFEnabled && aidaSettingResponse?.data?.value == 'true' && !isCurrentSessionPublic
|
||||||
|
)
|
||||||
}, [isAidaSettingLoading, isSemanticSearchFFEnabled])
|
}, [isAidaSettingLoading, isSemanticSearchFFEnabled])
|
||||||
const isSemanticMode = enableSemanticSearch && searchMode === SEARCH_MODE.SEMANTIC
|
const isSemanticMode = enableSemanticSearch && searchMode === SEARCH_MODE.SEMANTIC
|
||||||
return (
|
return (
|
||||||
|
|
Loading…
Reference in New Issue