@@ -84,6 +84,7 @@ import RepoSearchAutocomplete from '../repos/RepoSearchAutocomplete'
8484import RepoVersionSearchAutocomplete from '../repos/RepoVersionSearchAutocomplete'
8585import DraggablePaperComponent from '../common/DraggablePaperComponent'
8686import LoaderDialog from '../common/LoaderDialog'
87+ import Error403 from '../errors/Error403'
8788import { HEADERS , SEMANTIC_SEARCH_HEADERS , ROW_STATES , VIEWS , DECISION_TABS , SEMANTIC_BATCH_SIZE , ES_BATCH_SIZE } from './constants'
8889import MapProjectDeleteConfirmDialog from './MapProjectDeleteConfirmDialog' ;
8990import ConfigurationForm from './ConfigurationForm'
@@ -191,6 +192,8 @@ const MapProject = () => {
191192 const [ includeDefaultFilter , setIncludeDefaultFilter ] = React . useState ( true )
192193 const [ analysis , setAnalysis ] = React . useState ( { } )
193194
195+ const [ permissionDenied , setPermissionDenied ] = React . useState ( false )
196+
194197 // algos
195198 const [ algos , setAlgos ] = React . useState ( [
196199 { id : 'es' , label : 'Generic Elastic Search Matching' , description : "Token and Keyword based search using ES" } ,
@@ -222,10 +225,21 @@ const MapProject = () => {
222225 }
223226 } , [ ] )
224227
228+ React . useEffect ( ( ) => {
229+ setPermissionDenied ( false )
230+ } , [ params . projectId ] )
231+
232+
225233 const fetchAndSetProject = ( ) => {
226234 setLoadingProject ( true )
227235 let url = [ '' , params . ownerType , params . owner , 'map-projects' , params . projectId , '' ] . join ( '/' )
228236 APIService . new ( ) . overrideURL ( url ) . get ( ) . then ( response => {
237+ if ( response ?. detail ) {
238+ setPermissionDenied ( true )
239+ baseSetAlert ( { message : response . detail , severity : 'error' } )
240+ setLoadingProject ( false )
241+ return
242+ }
229243 if ( response . data . url ) {
230244 APIService . new ( ) . overrideURL ( response . data . url ) . appendToUrl ( 'logs/' ) . get ( ) . then ( response => setLogs ( response . data . logs || [ ] ) )
231245 }
@@ -236,12 +250,6 @@ const MapProject = () => {
236250 const sheet = workbook . Sheets [ sheetName ] ;
237251 const data = XLSX . utils . sheet_to_json ( sheet , { raw : false , defval : '' } )
238252 setProjectFromData ( data )
239- if ( response ?. data ?. target_repo_url ) {
240- APIService . new ( ) . overrideURL ( response . data . target_repo_url ) . get ( ) . then ( res => {
241- setRepo ( res . data || { } )
242- fetchVersions ( res . data ?. url , res . data ?. version )
243- } )
244- }
245253 setAlgo ( response ?. data ?. matching_algorithm || algo )
246254 if ( response ?. data . columns ?. length > 0 ) {
247255 const _columns = response . data . columns . map ( col => ( { ...omit ( col , [ 'hidden' ] ) } ) )
@@ -1383,7 +1391,7 @@ const MapProject = () => {
13831391
13841392 const getRowNameValue = _row => get ( _row , find ( columns , { label : 'Name' } ) ?. dataKey )
13851393
1386- return (
1394+ return permissionDenied ? < Error403 /> : (
13871395 < div className = 'col-xs-12 padding-0' style = { { borderRadius : '10px' , width : 'calc(100vw - 32px)' } } >
13881396 {
13891397 loadingProject &&
0 commit comments