Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dinky
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangpeng
dinky
Commits
5fbaeab2
Unverified
Commit
5fbaeab2
authored
Aug 18, 2023
by
Licho
Committed by
GitHub
Aug 18, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: tab type and update method (#2244)
parent
2c644be3
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
77 deletions
+40
-77
index.tsx
...web/src/pages/DataStudio/BottomContainer/Result/index.tsx
+2
-0
index.tsx
dinky-web/src/pages/DataStudio/FooterContainer/index.tsx
+0
-2
index.tsx
dinky-web/src/pages/DataStudio/MiddleContainer/index.tsx
+21
-57
model.ts
dinky-web/src/pages/DataStudio/model.ts
+11
-12
route.tsx
dinky-web/src/pages/DataStudio/route.tsx
+6
-6
No files found.
dinky-web/src/pages/DataStudio/BottomContainer/Result/index.tsx
View file @
5fbaeab2
...
@@ -121,9 +121,11 @@ const Result = (props: any) => {
...
@@ -121,9 +121,11 @@ const Result = (props: any) => {
if
(
!
currentTabs
)
{
if
(
!
currentTabs
)
{
return
;
return
;
}
}
if
(
currentTabs
.
type
!==
TabsPageType
.
project
)
{
if
(
currentTabs
.
type
!==
TabsPageType
.
project
)
{
return
;
return
;
}
}
if
((
currentTabs
?.
params
as
DataStudioParams
).
resultData
&&
!
isRefresh
)
{
if
((
currentTabs
?.
params
as
DataStudioParams
).
resultData
&&
!
isRefresh
)
{
setData
((
currentTabs
?.
params
as
DataStudioParams
).
resultData
);
setData
((
currentTabs
?.
params
as
DataStudioParams
).
resultData
);
}
else
{
}
else
{
...
...
dinky-web/src/pages/DataStudio/FooterContainer/index.tsx
View file @
5fbaeab2
...
@@ -111,8 +111,6 @@ const FooterContainer: React.FC<FooterContainerProps & StateType> = (props) => {
...
@@ -111,8 +111,6 @@ const FooterContainer: React.FC<FooterContainerProps & StateType> = (props) => {
/**
/**
* render footer right info
* render footer right info
* @param {ButtonRoute[]} routes
* @returns {JSX.Element[]}
*/
*/
const
renderFooterRightInfo
=
(
routes
:
ButtonRoute
[])
=>
{
const
renderFooterRightInfo
=
(
routes
:
ButtonRoute
[])
=>
{
return
routes
return
routes
...
...
dinky-web/src/pages/DataStudio/MiddleContainer/index.tsx
View file @
5fbaeab2
...
@@ -52,32 +52,24 @@ const MiddleContainer = (props: any) => {
...
@@ -52,32 +52,24 @@ const MiddleContainer = (props: any) => {
const
[
includeTab
,
setIncludeTab
]
=
useState
({});
const
[
includeTab
,
setIncludeTab
]
=
useState
({});
const
updateRightKey
=
(
key
:
string
)
=>
{
const
updateRightKey
=
(
key
:
string
)
=>
{
let
oldPane
:
TabsItemType
;
const
oldPane
=
panes
.
find
((
pane
:
TabsItemType
)
=>
pane
.
key
===
activeKey
);
let
newPane
:
TabsItemType
;
const
newPane
=
panes
.
find
((
pane
:
TabsItemType
)
=>
pane
.
key
===
key
);
panes
.
forEach
((
pane
:
TabsItemType
)
=>
{
if
(
pane
.
key
===
key
)
{
newPane
=
pane
;
}
if
(
pane
.
key
===
activeKey
)
{
oldPane
=
pane
;
}
});
let
oldRightSideAvailableKey
:
string
[]
=
[];
let
oldRightSideAvailableKey
:
string
[]
=
[];
let
newRightSideAvailableKey
:
string
[]
=
[];
let
newRightSideAvailableKey
:
string
[]
=
[];
RightSide
.
forEach
((
x
)
=>
{
RightSide
.
forEach
((
x
)
=>
{
if
(
x
.
isShow
)
{
if
(
!
x
.
isShow
)
{
if
(
x
.
isShow
(
oldPane
.
type
,
oldPane
.
subType
))
{
oldRightSideAvailableKey
.
push
(
x
.
key
);
oldRightSideAvailableKey
.
push
(
x
.
key
);
}
if
(
x
.
isShow
(
newPane
.
type
,
newPane
.
subType
))
{
newRightSideAvailableKey
.
push
(
x
.
key
);
newRightSideAvailableKey
.
push
(
x
.
key
);
return
;
}
}
}
else
{
if
(
x
.
isShow
(
oldPane
.
type
,
oldPane
.
subType
))
{
oldRightSideAvailableKey
.
push
(
x
.
key
);
oldRightSideAvailableKey
.
push
(
x
.
key
);
}
if
(
x
.
isShow
(
newPane
.
type
,
newPane
.
subType
))
{
newRightSideAvailableKey
.
push
(
x
.
key
);
newRightSideAvailableKey
.
push
(
x
.
key
);
}
}
});
});
...
@@ -109,20 +101,9 @@ const MiddleContainer = (props: any) => {
...
@@ -109,20 +101,9 @@ const MiddleContainer = (props: any) => {
payload
:
selectKey
,
payload
:
selectKey
,
});
});
};
};
/**
* 更新当前激活的tab
* @param {string} key
* @param eInfo
*/
const
updateActiveKey
=
(
key
:
string
,
eInfo
:
any
)
=>
{
if
(
key
===
activeKey
)
{
return
;
}
const
{
const
updateActiveKey
=
(
key
:
string
,
value
:
string
)
=>
{
target
:
{
innerText
},
if
(
key
===
activeKey
)
{
}
=
eInfo
;
if
(
!
innerText
)
{
return
;
return
;
}
}
...
@@ -135,12 +116,12 @@ const MiddleContainer = (props: any) => {
...
@@ -135,12 +116,12 @@ const MiddleContainer = (props: any) => {
});
});
// 替换掉 . 为 /, 因为再 tree 里选中的 key 是 / 分割的
// 替换掉 . 为 /, 因为再 tree 里选中的 key 是 / 分割的
const
replaceLabel
=
innerText
.
toString
().
replace
(
'.'
,
'/'
);
const
name
=
value
.
toString
().
replace
(
'.'
,
'/'
);
dispatch
({
dispatch
({
type
:
STUDIO_MODEL
.
updateDatabaseSelectKey
,
type
:
STUDIO_MODEL
.
updateDatabaseSelectKey
,
payload
:
[
replaceLabel
],
payload
:
[
name
],
});
});
}
;
}
/**
/**
* 关闭所有标签
* 关闭所有标签
...
@@ -165,20 +146,11 @@ const MiddleContainer = (props: any) => {
...
@@ -165,20 +146,11 @@ const MiddleContainer = (props: any) => {
/**
/**
* the right click event
* the right click event
* @param info
* @param item
*/
*/
const
handleRightClick
=
(
info
:
any
,
item
:
any
)
=>
{
const
handleRightClick
=
(
info
:
React
.
MouseEvent
<
HTMLDivElement
>
,
item
:
TabsItemType
)
=>
{
// 阻止默认右键事件
// 阻止默认右键事件
info
.
preventDefault
();
info
.
preventDefault
();
updateActiveKey
(
item
.
key
,
info
);
updateActiveKey
(
item
.
key
,
item
.
label
);
// 替换掉 . 为 /, 因为再 tree 里选中的 key 是 / 分割的
const
replaceLabel
=
item
.
label
.
toString
().
replace
(
'.'
,
'/'
);
dispatch
({
type
:
STUDIO_MODEL
.
updateDatabaseSelectKey
,
payload
:
[
replaceLabel
],
});
// 设置选中的值
// 设置选中的值
setIncludeTab
(
item
);
setIncludeTab
(
item
);
...
@@ -212,7 +184,6 @@ const MiddleContainer = (props: any) => {
...
@@ -212,7 +184,6 @@ const MiddleContainer = (props: any) => {
/**
/**
* 右键菜单
* 右键菜单
* @returns {JSX.Element}
*/
*/
const
renderRightClickMenu
=
()
=>
{
const
renderRightClickMenu
=
()
=>
{
return
(
return
(
...
@@ -262,9 +233,7 @@ const MiddleContainer = (props: any) => {
...
@@ -262,9 +233,7 @@ const MiddleContainer = (props: any) => {
key
:
item
.
key
,
key
:
item
.
key
,
label
:
(
label
:
(
<
Space
<
Space
onClick=
{
()
=>
onClick=
{
(
e
)
=>
updateActiveKey
(
item
.
key
,
item
.
label
)
}
updateActiveKey
(
item
.
key
,
{
target
:
{
innerText
:
item
.
label
}
})
}
size=
{
0
}
size=
{
0
}
onContextMenu=
{
(
e
)
=>
handleRightClick
(
e
,
item
)
}
onContextMenu=
{
(
e
)
=>
handleRightClick
(
e
,
item
)
}
key=
{
item
.
key
}
key=
{
item
.
key
}
...
@@ -303,7 +272,6 @@ const MiddleContainer = (props: any) => {
...
@@ -303,7 +272,6 @@ const MiddleContainer = (props: any) => {
/**
/**
* render middle content
* render middle content
* @returns {JSX.Element}
*/
*/
const
renderMiddleContent
=
()
=>
{
const
renderMiddleContent
=
()
=>
{
if
(
tabItems
?.
length
===
0
)
{
if
(
tabItems
?.
length
===
0
)
{
...
@@ -320,7 +288,6 @@ const MiddleContainer = (props: any) => {
...
@@ -320,7 +288,6 @@ const MiddleContainer = (props: any) => {
}
}
return
(
return
(
<>
<
ConfigProvider
<
ConfigProvider
theme=
{
{
theme=
{
{
components
:
{
components
:
{
...
@@ -329,21 +296,18 @@ const MiddleContainer = (props: any) => {
...
@@ -329,21 +296,18 @@ const MiddleContainer = (props: any) => {
borderRadiusLG
:
0
,
borderRadiusLG
:
0
,
},
},
},
},
}
}
}
}
>
>
<
Tabs
<
Tabs
className=
{
'data-studio-tabs'
}
className=
{
'data-studio-tabs'
}
tabBarStyle=
{
{
borderBlock
:
`1px solid ${themeValue.borderColor}`
}
}
tabBarStyle=
{
{
borderBlock
:
`1px solid ${themeValue.borderColor}`
}
}
hideAdd
hideAdd
onTabClick=
{
(
active
,
e
)
=>
updateActiveKey
(
active
,
e
)
}
// onTabClick={(active, e) => {updateActiveKey(active, tabItems[active].label)}
}
activeKey=
{
activeKey
}
activeKey=
{
activeKey
}
type=
"editable-card"
type=
"editable-card"
onEdit=
{
closeTab
}
onEdit=
{
closeTab
}
items=
{
tabItems
}
items=
{
tabItems
}
/>
/>
{
renderRightClickMenu
()
}
{
renderRightClickMenu
()
}
</
ConfigProvider
>
</
ConfigProvider
>
</>
);
);
};
};
...
...
dinky-web/src/pages/DataStudio/model.ts
View file @
5fbaeab2
...
@@ -105,6 +105,9 @@ export enum TabsPageType {
...
@@ -105,6 +105,9 @@ export enum TabsPageType {
None
=
''
,
None
=
''
,
metadata
=
'metadata'
,
metadata
=
'metadata'
,
project
=
'project'
,
project
=
'project'
,
}
export
enum
TabsPageSubType
{
flinkSql
=
'flinksql'
,
flinkSql
=
'flinksql'
,
}
}
...
@@ -112,9 +115,9 @@ export type TabsItemType = {
...
@@ -112,9 +115,9 @@ export type TabsItemType = {
id
:
string
;
id
:
string
;
label
:
string
;
label
:
string
;
breadcrumbLabel
:
string
;
breadcrumbLabel
:
string
;
params
:
number
|
string
|
object
|
MetadataParams
|
DataStudioParams
;
params
:
MetadataParams
|
DataStudioParams
;
type
:
TabsPageType
;
type
:
TabsPageType
;
subType
?:
TabsPageType
;
subType
?:
TabsPage
Sub
Type
;
key
:
string
;
key
:
string
;
value
:
string
;
value
:
string
;
icon
:
any
;
icon
:
any
;
...
@@ -442,25 +445,21 @@ const Model: ModelType = {
...
@@ -442,25 +445,21 @@ const Model: ModelType = {
let
toolContentHeight
=
0
;
let
toolContentHeight
=
0
;
if
(
payload
===
''
)
{
if
(
payload
===
''
)
{
centerContentHeight
=
centerContentHeight
=
(
state
.
centerContentHeight
as
number
)
+
state
.
centerContentHeight
+
(
state
.
bottomContainer
.
height
as
number
);
(
state
.
bottomContainer
.
height
as
number
);
toolContentHeight
=
toolContentHeight
=
(
state
.
toolContentHeight
as
number
)
+
state
.
toolContentHeight
+
(
state
.
bottomContainer
.
height
as
number
);
(
state
.
bottomContainer
.
height
as
number
);
console
.
log
(
2
);
console
.
log
(
2
);
}
else
if
(
}
else
if
(
state
.
bottomContainer
.
selectKey
!==
''
&&
state
.
bottomContainer
.
selectKey
!==
''
&&
payload
!==
state
.
bottomContainer
.
selectKey
payload
!==
state
.
bottomContainer
.
selectKey
)
{
)
{
centerContentHeight
=
state
.
centerContentHeight
as
number
;
centerContentHeight
=
state
.
centerContentHeight
;
toolContentHeight
=
state
.
toolContentHeight
as
number
;
toolContentHeight
=
state
.
toolContentHeight
;
}
else
{
}
else
{
centerContentHeight
=
centerContentHeight
=
(
state
.
centerContentHeight
as
number
)
-
state
.
centerContentHeight
-
(
state
.
bottomContainer
.
height
as
number
);
(
state
.
bottomContainer
.
height
as
number
);
toolContentHeight
=
toolContentHeight
=
(
state
.
toolContentHeight
as
number
)
-
state
.
toolContentHeight
-
(
state
.
bottomContainer
.
height
as
number
);
(
state
.
bottomContainer
.
height
as
number
);
console
.
log
(
3
);
console
.
log
(
3
);
}
}
...
...
dinky-web/src/pages/DataStudio/route.tsx
View file @
5fbaeab2
...
@@ -22,7 +22,7 @@ import Console from '@/pages/DataStudio/BottomContainer/Console';
...
@@ -22,7 +22,7 @@ import Console from '@/pages/DataStudio/BottomContainer/Console';
import
Result
from
'@/pages/DataStudio/BottomContainer/Result'
;
import
Result
from
'@/pages/DataStudio/BottomContainer/Result'
;
import
MetaData
from
'@/pages/DataStudio/LeftContainer/MetaData'
;
import
MetaData
from
'@/pages/DataStudio/LeftContainer/MetaData'
;
import
Project
from
'@/pages/DataStudio/LeftContainer/Project'
;
import
Project
from
'@/pages/DataStudio/LeftContainer/Project'
;
import
{
TabsPageType
}
from
'@/pages/DataStudio/model'
;
import
{
TabsPageSubType
,
TabsPageType
}
from
'@/pages/DataStudio/model'
;
import
ExecuteConfig
from
'@/pages/DataStudio/RightContainer/ExecuteConfig'
;
import
ExecuteConfig
from
'@/pages/DataStudio/RightContainer/ExecuteConfig'
;
import
HistoryVersion
from
'@/pages/DataStudio/RightContainer/HistoryVersion'
;
import
HistoryVersion
from
'@/pages/DataStudio/RightContainer/HistoryVersion'
;
import
JobConfig
from
'@/pages/DataStudio/RightContainer/JobConfig'
;
import
JobConfig
from
'@/pages/DataStudio/RightContainer/JobConfig'
;
...
@@ -81,7 +81,7 @@ export const RightSide: TabProp[] = [
...
@@ -81,7 +81,7 @@ export const RightSide: TabProp[] = [
label
:
l
(
'menu.datastudio.jobConfig'
),
label
:
l
(
'menu.datastudio.jobConfig'
),
children
:
<
JobConfig
/>,
children
:
<
JobConfig
/>,
isShow
:
(
type
,
subType
)
=>
isShow
:
(
type
,
subType
)
=>
type
===
TabsPageType
.
project
&&
TabsPageType
.
flinkSql
===
subType
,
type
===
TabsPageType
.
project
&&
TabsPage
Sub
Type
.
flinkSql
===
subType
,
},
},
{
{
key
:
'menu.datastudio.executeConfig'
,
key
:
'menu.datastudio.executeConfig'
,
...
@@ -89,7 +89,7 @@ export const RightSide: TabProp[] = [
...
@@ -89,7 +89,7 @@ export const RightSide: TabProp[] = [
label
:
l
(
'menu.datastudio.executeConfig'
),
label
:
l
(
'menu.datastudio.executeConfig'
),
children
:
<
ExecuteConfig
/>,
children
:
<
ExecuteConfig
/>,
isShow
:
(
type
,
subType
)
=>
isShow
:
(
type
,
subType
)
=>
type
===
TabsPageType
.
project
&&
TabsPageType
.
flinkSql
===
subType
,
type
===
TabsPageType
.
project
&&
TabsPage
Sub
Type
.
flinkSql
===
subType
,
},
},
{
{
key
:
'menu.datastudio.savePoint'
,
key
:
'menu.datastudio.savePoint'
,
...
@@ -97,7 +97,7 @@ export const RightSide: TabProp[] = [
...
@@ -97,7 +97,7 @@ export const RightSide: TabProp[] = [
label
:
l
(
'menu.datastudio.savePoint'
),
label
:
l
(
'menu.datastudio.savePoint'
),
children
:
<
SavePoints
/>,
children
:
<
SavePoints
/>,
isShow
:
(
type
,
subType
)
=>
isShow
:
(
type
,
subType
)
=>
type
===
TabsPageType
.
project
&&
TabsPageType
.
flinkSql
===
subType
,
type
===
TabsPageType
.
project
&&
TabsPage
Sub
Type
.
flinkSql
===
subType
,
},
},
{
{
key
:
'menu.datastudio.historyVision'
,
key
:
'menu.datastudio.historyVision'
,
...
@@ -105,7 +105,7 @@ export const RightSide: TabProp[] = [
...
@@ -105,7 +105,7 @@ export const RightSide: TabProp[] = [
label
:
l
(
'menu.datastudio.historyVision'
),
label
:
l
(
'menu.datastudio.historyVision'
),
children
:
<
HistoryVersion
/>,
children
:
<
HistoryVersion
/>,
isShow
:
(
type
,
subType
)
=>
isShow
:
(
type
,
subType
)
=>
type
===
TabsPageType
.
project
&&
TabsPageType
.
flinkSql
===
subType
,
type
===
TabsPageType
.
project
&&
TabsPage
Sub
Type
.
flinkSql
===
subType
,
},
},
{
{
key
:
'menu.datastudio.jobInfo'
,
key
:
'menu.datastudio.jobInfo'
,
...
@@ -262,5 +262,5 @@ export type TabProp = {
...
@@ -262,5 +262,5 @@ export type TabProp = {
icon
:
ReactNode
;
icon
:
ReactNode
;
label
:
string
;
label
:
string
;
children
:
ReactNode
;
children
:
ReactNode
;
isShow
?:
(
type
:
TabsPageType
,
subType
?:
string
)
=>
boolean
;
isShow
?:
(
type
:
TabsPageType
,
subType
?:
TabsPageSubType
)
=>
boolean
;
};
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment