@@ -181,9 +181,7 @@ const extension: JupyterFrontEndPlugin<void> = {
181181 const credentials = await authApi ( ) ;
182182 if ( credentials ?. project_id ) {
183183 bigqueryDatasetsResponse =
184- await BigQueryService . listBigQueryDatasetsAPIService (
185- credentials . project_id
186- ) ;
184+ await BigQueryService . checkBigQueryDatasetsAPIService ( ) ;
187185 }
188186
189187 const dataCatalogResponse =
@@ -195,53 +193,57 @@ const extension: JupyterFrontEndPlugin<void> = {
195193 errorKey : 'error.message' ,
196194 errorMessage : 'Cloud Dataproc API has not been used in project' ,
197195 notificationMessage : 'The Cloud Dataproc API is not enabled.' ,
198- enableLink :
199- 'https://console.cloud.google.com/apis/library/dataproc.googleapis.com'
196+ enableLink : `https://console.cloud.google.com/apis/library/dataproc.googleapis.com?project=${ credentials ?. project_id } `
200197 } ,
201198 {
202199 response : bigqueryDatasetsResponse ,
203200 errorKey : 'error' ,
201+ checkType : 'bigquery' ,
204202 errorMessage : 'has not enabled BigQuery' ,
205203 notificationMessage : 'The BigQuery API is not enabled.' ,
206- enableLink :
207- 'https://console.cloud.google.com/apis/library/bigquery.googleapis.com'
204+ enableLink : `https://console.cloud.google.com/apis/library/bigquery.googleapis.com?project=${ credentials ?. project_id } `
208205 } ,
209206 {
210207 response : dataCatalogResponse ,
211208 errorKey : 'error' ,
212209 errorMessage :
213210 'Google Cloud Data Catalog API has not been used in project' ,
214211 notificationMessage : 'Google Cloud Data Catalog API is not enabled.' ,
215- enableLink :
216- 'https://console.cloud.google.com/apis/library/datacatalog.googleapis.com'
212+ enableLink : `https://console.cloud.google.com/apis/library/datacatalog.googleapis.com?project=${ credentials ?. project_id } `
217213 }
218214 ] ;
219-
220- apiChecks . forEach (
221- ( {
222- response,
223- errorKey,
224- errorMessage,
225- notificationMessage,
226- enableLink
227- } ) => {
228- const errorValue = errorKey
215+ apiChecks . forEach ( check => {
216+ if ( check . checkType === 'bigquery' ) {
217+ if ( check . response && check . response . is_enabled === false ) {
218+ Notification . error ( check . notificationMessage , {
219+ actions : [
220+ {
221+ label : 'Enable' ,
222+ callback : ( ) => window . open ( check . enableLink , '_blank' ) ,
223+ displayType : 'link'
224+ }
225+ ] ,
226+ autoClose : false
227+ } ) ;
228+ }
229+ } else {
230+ const errorValue = check . errorKey
229231 . split ( '.' )
230- . reduce ( ( acc , key ) => acc ?. [ key ] , response ) ;
231- if ( errorValue && errorValue . includes ( errorMessage ) ) {
232- Notification . error ( notificationMessage , {
232+ . reduce ( ( acc , key ) => acc ?. [ key ] , check . response ) ;
233+ if ( errorValue && errorValue . includes ( check . errorMessage ) ) {
234+ Notification . error ( check . notificationMessage , {
233235 actions : [
234236 {
235237 label : 'Enable' ,
236- callback : ( ) => window . open ( enableLink , '_blank' ) ,
238+ callback : ( ) => window . open ( check . enableLink , '_blank' ) ,
237239 displayType : 'link'
238240 }
239241 ] ,
240242 autoClose : false
241243 } ) ;
242244 }
243245 }
244- ) ;
246+ } ) ;
245247 } ;
246248
247249 await checkAllApisEnabled ( ) ;
@@ -340,10 +342,7 @@ const extension: JupyterFrontEndPlugin<void> = {
340342 panelDpms . addWidget ( new dpmsWidget ( app as JupyterLab , themeManager ) ) ;
341343 onThemeChanged ( ) ;
342344 app . shell . add ( panelDpms , 'left' , { rank : 1001 } ) ;
343- DataprocLoggingService . log (
344- 'Metastore is enabled' ,
345- LOG_LEVEL . INFO
346- ) ;
345+ DataprocLoggingService . log ( 'Metastore is enabled' , LOG_LEVEL . INFO ) ;
347346 }
348347
349348 if ( enableCloudStorage ) {
@@ -358,10 +357,7 @@ const extension: JupyterFrontEndPlugin<void> = {
358357 ) ;
359358 onThemeChanged ( ) ;
360359 app . shell . add ( panelGcs , 'left' , { rank : 1002 } ) ;
361- DataprocLoggingService . log (
362- 'Cloud storage is enabled' ,
363- LOG_LEVEL . INFO
364- ) ;
360+ DataprocLoggingService . log ( 'Cloud storage is enabled' , LOG_LEVEL . INFO ) ;
365361 }
366362 } ;
367363 onSidePanelEnabled ( ) ;
0 commit comments