@@ -20,15 +20,16 @@ import { useState } from 'react';
2020import { useNavigate , useParams } from 'react-router-dom' ;
2121import { Helmet } from 'react-helmet' ;
2222import { DeleteOutlined , FormOutlined } from '@ant-design/icons' ;
23- import { Flex , Table , Popconfirm , Modal , Button } from 'antd' ;
23+ import { Flex , Popconfirm , Modal , Button } from 'antd' ;
2424
2525import API from '@/api' ;
2626import { PageLoading , PageHeader , ExternalLink } from '@/components' ;
2727import { PATHS } from '@/config' ;
2828import { useRefreshData } from '@/hooks' ;
29- import { ScopeConfig , DataScopeSelect , getPluginScopeId } from '@/plugins' ;
29+ import { DataScopeSelect } from '@/plugins' ;
3030import { operator } from '@/utils' ;
3131
32+ import { BlueprintConnectionDetailTable } from './table' ;
3233import * as S from './styled' ;
3334
3435const brandName = import . meta. env . DEVLAKE_BRAND_NAME ?? 'DevLake' ;
@@ -60,13 +61,6 @@ export const BlueprintConnectionDetailPage = () => {
6061 API . connection . get ( plugin , connectionId ) ,
6162 ] ) ;
6263
63- const scopeIds =
64- blueprint . connections
65- . find ( ( cs ) => cs . pluginName === plugin && cs . connectionId === + connectionId )
66- ?. scopes ?. map ( ( sc : any ) => sc . scopeId ) ?? [ ] ;
67-
68- const scopes = await Promise . all ( scopeIds . map ( ( scopeId ) => API . scope . get ( plugin , connectionId , scopeId ) ) ) ;
69-
7064 return {
7165 blueprint,
7266 connection : {
@@ -75,20 +69,18 @@ export const BlueprintConnectionDetailPage = () => {
7569 id : + connectionId ,
7670 name : connection . name ,
7771 } ,
78- scopes : scopes . map ( ( sc ) => ( {
79- id : getPluginScopeId ( plugin , sc . scope ) ,
80- name : sc . scope . fullName ?? sc . scope . name ,
81- scopeConfigId : sc . scopeConfig ?. id ,
82- scopeConfigName : sc . scopeConfig ?. name ,
83- } ) ) ,
72+ scopeIds :
73+ blueprint . connections
74+ . find ( ( cs ) => cs . pluginName === plugin && cs . connectionId === + connectionId )
75+ ?. scopes ?. map ( ( sc : any ) => sc . scopeId ) ?? [ ] ,
8476 } ;
8577 } , [ version , pname , bid ] ) ;
8678
8779 if ( ! ready || ! data ) {
8880 return < PageLoading /> ;
8981 }
9082
91- const { blueprint, connection, scopes } = data ;
83+ const { blueprint, connection, scopeIds } = data ;
9284
9385 const handleShowDataScope = ( ) => setOpen ( true ) ;
9486 const handleHideDataScope = ( ) => setOpen ( false ) ;
@@ -179,26 +171,6 @@ export const BlueprintConnectionDetailPage = () => {
179171 }
180172 } ;
181173
182- const handleChangeScopeConfig = ( ) => {
183- modal . success ( {
184- closable : true ,
185- centered : true ,
186- width : 550 ,
187- title : 'Scope Config Saved' ,
188- content : 'Please re-transform data to apply the updated scope config.' ,
189- footer : (
190- < div style = { { marginTop : 20 , textAlign : 'center' } } >
191- < Button type = "primary" loading = { operating } onClick = { ( ) => handleRun ( { skipCollectors : true } ) } >
192- Re-transform now
193- </ Button >
194- </ div >
195- ) ,
196- onCancel : ( ) => {
197- setVersion ( version + 1 ) ;
198- } ,
199- } ) ;
200- } ;
201-
202174 return (
203175 < PageHeader
204176 breadcrumbs = {
@@ -251,40 +223,20 @@ export const BlueprintConnectionDetailPage = () => {
251223 Manage Data Scope
252224 </ Button >
253225 </ Flex >
254- < Table
255- rowKey = "id"
256- size = "middle"
257- columns = { [
258- {
259- title : 'Data Scope' ,
260- dataIndex : 'name' ,
261- key : 'name' ,
262- } ,
263- {
264- title : 'Scope Config' ,
265- key : 'scopeConfig' ,
266- render : ( _ , { id, name, scopeConfigId, scopeConfigName } ) => (
267- < ScopeConfig
268- plugin = { plugin }
269- connectionId = { connectionId }
270- scopeId = { id }
271- scopeName = { name }
272- id = { scopeConfigId }
273- name = { scopeConfigName }
274- onSuccess = { handleChangeScopeConfig }
275- />
276- ) ,
277- } ,
278- ] }
279- dataSource = { scopes }
226+ < BlueprintConnectionDetailTable
227+ plugin = { plugin }
228+ connectionId = { connectionId }
229+ scopeIds = { scopeIds }
230+ operating = { operating }
231+ onRun = { handleRun }
280232 />
281233 </ Flex >
282234 < Modal open = { open } width = { 820 } centered title = "Manage Data Scope" footer = { null } onCancel = { handleHideDataScope } >
283235 < DataScopeSelect
284236 plugin = { connection . plugin }
285237 connectionId = { connection . id }
286238 showWarning
287- initialScope = { scopes }
239+ initialScope = { scopeIds . map ( ( id ) => ( { id } ) ) }
288240 onCancel = { handleHideDataScope }
289241 onSubmit = { handleChangeDataScope }
290242 />
0 commit comments