Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_22812535
incubator-superset
提交
4d179622
I
incubator-superset
项目概览
qq_22812535
/
incubator-superset
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
incubator-superset
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
4d179622
编写于
7月 10, 2020
作者:
J
Jesse Yang
提交者:
GitHub
7月 10, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(explore): edit datasource does not update control states (#10284)
上级
4e4ccd48
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
86 addition
and
15 deletion
+86
-15
superset-frontend/cypress-base/cypress/integration/explore/control.test.ts
.../cypress-base/cypress/integration/explore/control.test.ts
+53
-2
superset-frontend/spec/javascripts/explore/components/DatasourceControl_spec.jsx
...javascripts/explore/components/DatasourceControl_spec.jsx
+6
-3
superset-frontend/spec/javascripts/explore/controlUtils_spec.jsx
...t-frontend/spec/javascripts/explore/controlUtils_spec.jsx
+0
-1
superset-frontend/src/components/TooltipWrapper.jsx
superset-frontend/src/components/TooltipWrapper.jsx
+6
-0
superset-frontend/src/explore/components/ExploreViewContainer.jsx
...-frontend/src/explore/components/ExploreViewContainer.jsx
+1
-0
superset-frontend/src/explore/components/controls/DatasourceControl.jsx
...end/src/explore/components/controls/DatasourceControl.jsx
+16
-4
superset-frontend/src/explore/controlUtils.js
superset-frontend/src/explore/controlUtils.js
+1
-2
superset-frontend/src/explore/controls.jsx
superset-frontend/src/explore/controls.jsx
+3
-3
未找到文件。
superset-frontend/cypress-base/cypress/integration/explore/control.test.
j
s
→
superset-frontend/cypress-base/cypress/integration/explore/control.test.
t
s
浏览文件 @
4d179622
...
@@ -21,11 +21,60 @@
...
@@ -21,11 +21,60 @@
// ***********************************************
// ***********************************************
import
{
FORM_DATA_DEFAULTS
,
NUM_METRIC
}
from
'
./visualizations/shared.helper
'
;
import
{
FORM_DATA_DEFAULTS
,
NUM_METRIC
}
from
'
./visualizations/shared.helper
'
;
describe
(
'
Groupby
'
,
()
=>
{
describe
(
'
Datasource control
'
,
()
=>
{
it
(
'
Set groupby
'
,
()
=>
{
const
newMetricName
=
`abc
${
Date
.
now
()}
`
;
before
(()
=>
{
cy
.
server
();
cy
.
server
();
cy
.
login
();
cy
.
login
();
cy
.
route
(
'
GET
'
,
'
/superset/explore_json/**
'
).
as
(
'
getJson
'
);
cy
.
route
(
'
POST
'
,
'
/superset/explore_json/**
'
).
as
(
'
postJson
'
);
});
it
(
'
should allow edit datasource
'
,
()
=>
{
cy
.
visitChartByName
(
'
Num Births Trend
'
);
cy
.
verifySliceSuccess
({
waitAlias
:
'
@postJson
'
});
cy
.
get
(
'
#datasource_menu
'
).
click
();
cy
.
get
(
'
a
'
).
contains
(
'
Edit Datasource
'
).
click
();
// create new metric
cy
.
get
(
'
button
'
).
contains
(
'
Add Item
'
).
click
();
cy
.
get
(
'
input[value="<new metric>"]
'
).
click
();
cy
.
get
(
'
input[value="<new metric>"]
'
)
.
focus
()
.
clear
()
.
type
(
`
${
newMetricName
}
{enter}`
);
cy
.
get
(
'
.modal-footer button
'
).
contains
(
'
Save
'
).
click
();
cy
.
get
(
'
.modal-footer button
'
).
contains
(
'
OK
'
).
click
();
// select new metric
cy
.
get
(
'
.metrics-select:eq(0)
'
).
click
();
cy
.
get
(
'
.metrics-select:eq(0) input[type="text"]
'
)
.
focus
()
.
type
(
newMetricName
);
cy
.
get
(
'
.metrics-select:eq(0) .Select__menu .Select__option
'
)
.
contains
(
newMetricName
)
.
click
();
cy
.
get
(
'
.metrics-select:eq(0) .Select__multi-value__label
'
)
.
contains
(
newMetricName
)
.
click
();
// delete metric
cy
.
get
(
'
#datasource_menu
'
).
click
();
cy
.
get
(
'
a
'
).
contains
(
'
Edit Datasource
'
).
click
();
cy
.
get
(
`input[value="
${
newMetricName
}
"]`
)
.
closest
(
'
tr
'
)
.
find
(
'
.fa-close
'
)
.
click
();
cy
.
get
(
'
.modal-footer button
'
).
contains
(
'
Save
'
).
click
();
cy
.
get
(
'
.modal-footer button
'
).
contains
(
'
OK
'
).
click
();
cy
.
get
(
'
.Select__multi-value__label
'
)
.
contains
(
newMetricName
)
.
should
(
'
not.exist
'
);
});
});
describe
(
'
Groupby control
'
,
()
=>
{
it
(
'
Set groupby
'
,
()
=>
{
cy
.
server
();
cy
.
login
();
cy
.
route
(
'
GET
'
,
'
/superset/explore_json/**
'
).
as
(
'
getJson
'
);
cy
.
route
(
'
GET
'
,
'
/superset/explore_json/**
'
).
as
(
'
getJson
'
);
cy
.
route
(
'
POST
'
,
'
/superset/explore_json/**
'
).
as
(
'
postJson
'
);
cy
.
route
(
'
POST
'
,
'
/superset/explore_json/**
'
).
as
(
'
postJson
'
);
cy
.
visitChartByName
(
'
Num Births Trend
'
);
cy
.
visitChartByName
(
'
Num Births Trend
'
);
...
@@ -71,5 +120,7 @@ describe('Time range filter', () => {
...
@@ -71,5 +120,7 @@ describe('Time range filter', () => {
});
});
});
});
});
});
cy
.
get
(
'
#filter-popover button
'
).
contains
(
'
Ok
'
).
click
();
cy
.
get
(
'
#filter-popover
'
).
should
(
'
not.exist
'
);
});
});
});
});
superset-frontend/spec/javascripts/explore/components/DatasourceControl_spec.jsx
浏览文件 @
4d179622
...
@@ -41,6 +41,9 @@ const defaultProps = {
...
@@ -41,6 +41,9 @@ const defaultProps = {
name
:
'
main
'
,
name
:
'
main
'
,
},
},
},
},
actions
:
{
setDatasource
:
sinon
.
spy
(),
},
onChange
:
sinon
.
spy
(),
onChange
:
sinon
.
spy
(),
};
};
...
@@ -71,15 +74,15 @@ describe('DatasourceControl', () => {
...
@@ -71,15 +74,15 @@ describe('DatasourceControl', () => {
let
wrapper
=
setup
();
let
wrapper
=
setup
();
expect
(
wrapper
.
find
(
'
#datasource_menu
'
)).
toHaveLength
(
1
);
expect
(
wrapper
.
find
(
'
#datasource_menu
'
)).
toHaveLength
(
1
);
expect
(
wrapper
.
find
(
'
#datasource_menu
'
).
dive
().
find
(
MenuItem
)).
toHaveLength
(
expect
(
wrapper
.
find
(
'
#datasource_menu
'
).
dive
().
find
(
MenuItem
)).
toHaveLength
(
2
,
3
,
);
);
wrapper
=
setup
({
wrapper
=
setup
({
onDatasourceSave
:
()
=>
{}
,
isEditable
:
false
,
});
});
expect
(
wrapper
.
find
(
'
#datasource_menu
'
)).
toHaveLength
(
1
);
expect
(
wrapper
.
find
(
'
#datasource_menu
'
)).
toHaveLength
(
1
);
expect
(
wrapper
.
find
(
'
#datasource_menu
'
).
dive
().
find
(
MenuItem
)).
toHaveLength
(
expect
(
wrapper
.
find
(
'
#datasource_menu
'
).
dive
().
find
(
MenuItem
)).
toHaveLength
(
3
,
2
,
);
);
});
});
});
});
superset-frontend/spec/javascripts/explore/controlUtils_spec.jsx
浏览文件 @
4d179622
...
@@ -27,7 +27,6 @@ import {
...
@@ -27,7 +27,6 @@ import {
getFormDataFromControls
,
getFormDataFromControls
,
applyMapStateToPropsToControl
,
applyMapStateToPropsToControl
,
getAllControlsState
,
getAllControlsState
,
getControlsState
,
}
from
'
src/explore/controlUtils
'
;
}
from
'
src/explore/controlUtils
'
;
describe
(
'
controlUtils
'
,
()
=>
{
describe
(
'
controlUtils
'
,
()
=>
{
...
...
superset-frontend/src/components/TooltipWrapper.jsx
浏览文件 @
4d179622
...
@@ -26,6 +26,10 @@ const propTypes = {
...
@@ -26,6 +26,10 @@ const propTypes = {
tooltip
:
PropTypes
.
node
.
isRequired
,
tooltip
:
PropTypes
.
node
.
isRequired
,
children
:
PropTypes
.
node
.
isRequired
,
children
:
PropTypes
.
node
.
isRequired
,
placement
:
PropTypes
.
string
,
placement
:
PropTypes
.
string
,
trigger
:
PropTypes
.
oneOfType
([
PropTypes
.
string
,
PropTypes
.
arrayOf
(
PropTypes
.
string
),
]),
};
};
const
defaultProps
=
{
const
defaultProps
=
{
...
@@ -37,11 +41,13 @@ export default function TooltipWrapper({
...
@@ -37,11 +41,13 @@ export default function TooltipWrapper({
tooltip
,
tooltip
,
children
,
children
,
placement
,
placement
,
trigger
,
})
{
})
{
return
(
return
(
<
OverlayTrigger
<
OverlayTrigger
placement
=
{
placement
}
placement
=
{
placement
}
overlay
=
{
<
Tooltip
id
=
{
`
${
kebabCase
(
label
)}
-tooltip`
}
>
{
tooltip
}
</
Tooltip
>
}
overlay
=
{
<
Tooltip
id
=
{
`
${
kebabCase
(
label
)}
-tooltip`
}
>
{
tooltip
}
</
Tooltip
>
}
trigger
=
{
trigger
}
>
>
{
children
}
{
children
}
</
OverlayTrigger
>
</
OverlayTrigger
>
...
...
superset-frontend/src/explore/components/ExploreViewContainer.jsx
浏览文件 @
4d179622
...
@@ -389,6 +389,7 @@ function mapStateToProps(state) {
...
@@ -389,6 +389,7 @@ function mapStateToProps(state) {
const
form_data
=
getFormDataFromControls
(
explore
.
controls
);
const
form_data
=
getFormDataFromControls
(
explore
.
controls
);
const
chartKey
=
Object
.
keys
(
charts
)[
0
];
const
chartKey
=
Object
.
keys
(
charts
)[
0
];
const
chart
=
charts
[
chartKey
];
const
chart
=
charts
[
chartKey
];
return
{
return
{
isDatasourceMetaLoading
:
explore
.
isDatasourceMetaLoading
,
isDatasourceMetaLoading
:
explore
.
isDatasourceMetaLoading
,
datasource
:
explore
.
datasource
,
datasource
:
explore
.
datasource
,
...
...
superset-frontend/src/explore/components/controls/DatasourceControl.jsx
浏览文件 @
4d179622
...
@@ -38,9 +38,11 @@ import TooltipWrapper from '../../../components/TooltipWrapper';
...
@@ -38,9 +38,11 @@ import TooltipWrapper from '../../../components/TooltipWrapper';
import
'
./DatasourceControl.less
'
;
import
'
./DatasourceControl.less
'
;
const
propTypes
=
{
const
propTypes
=
{
actions
:
PropTypes
.
object
.
isRequired
,
onChange
:
PropTypes
.
func
,
onChange
:
PropTypes
.
func
,
value
:
PropTypes
.
string
,
value
:
PropTypes
.
string
,
datasource
:
PropTypes
.
object
.
isRequired
,
datasource
:
PropTypes
.
object
.
isRequired
,
isEditable
:
PropTypes
.
bool
,
onDatasourceSave
:
PropTypes
.
func
,
onDatasourceSave
:
PropTypes
.
func
,
};
};
...
@@ -48,6 +50,7 @@ const defaultProps = {
...
@@ -48,6 +50,7 @@ const defaultProps = {
onChange
:
()
=>
{},
onChange
:
()
=>
{},
onDatasourceSave
:
null
,
onDatasourceSave
:
null
,
value
:
null
,
value
:
null
,
isEditable
:
true
,
};
};
class
DatasourceControl
extends
React
.
PureComponent
{
class
DatasourceControl
extends
React
.
PureComponent
{
...
@@ -58,6 +61,7 @@ class DatasourceControl extends React.PureComponent {
...
@@ -58,6 +61,7 @@ class DatasourceControl extends React.PureComponent {
showChangeDatasourceModal
:
false
,
showChangeDatasourceModal
:
false
,
menuExpanded
:
false
,
menuExpanded
:
false
,
};
};
this
.
onDatasourceSave
=
this
.
onDatasourceSave
.
bind
(
this
);
this
.
toggleChangeDatasourceModal
=
this
.
toggleChangeDatasourceModal
.
bind
(
this
.
toggleChangeDatasourceModal
=
this
.
toggleChangeDatasourceModal
.
bind
(
this
,
this
,
);
);
...
@@ -66,6 +70,13 @@ class DatasourceControl extends React.PureComponent {
...
@@ -66,6 +70,13 @@ class DatasourceControl extends React.PureComponent {
this
.
renderDatasource
=
this
.
renderDatasource
.
bind
(
this
);
this
.
renderDatasource
=
this
.
renderDatasource
.
bind
(
this
);
}
}
onDatasourceSave
(
datasource
)
{
this
.
props
.
actions
.
setDatasource
(
datasource
);
if
(
this
.
props
.
onDatasourceSave
)
{
this
.
props
.
onDatasourceSave
(
datasource
);
}
}
toggleShowDatasource
()
{
toggleShowDatasource
()
{
this
.
setState
(({
showDatasource
})
=>
({
this
.
setState
(({
showDatasource
})
=>
({
showDatasource
:
!
showDatasource
,
showDatasource
:
!
showDatasource
,
...
@@ -120,7 +131,7 @@ class DatasourceControl extends React.PureComponent {
...
@@ -120,7 +131,7 @@ class DatasourceControl extends React.PureComponent {
render
()
{
render
()
{
const
{
showChangeDatasourceModal
,
showEditDatasourceModal
}
=
this
.
state
;
const
{
showChangeDatasourceModal
,
showEditDatasourceModal
}
=
this
.
state
;
const
{
datasource
,
onChange
,
onDatasourceSave
,
value
}
=
this
.
props
;
const
{
datasource
,
onChange
,
value
}
=
this
.
props
;
return
(
return
(
<
div
>
<
div
>
<
ControlHeader
{
...
this
.
props
}
/>
<
ControlHeader
{
...
this
.
props
}
/>
...
@@ -128,6 +139,7 @@ class DatasourceControl extends React.PureComponent {
...
@@ -128,6 +139,7 @@ class DatasourceControl extends React.PureComponent {
<
TooltipWrapper
<
TooltipWrapper
label
=
"change-datasource"
label
=
"change-datasource"
tooltip
=
{
t
(
'
Click to change the datasource
'
)
}
tooltip
=
{
t
(
'
Click to change the datasource
'
)
}
trigger
=
{
[
'
hover
'
]
}
>
>
<
DropdownButton
<
DropdownButton
title
=
{
datasource
.
name
}
title
=
{
datasource
.
name
}
...
@@ -148,7 +160,7 @@ class DatasourceControl extends React.PureComponent {
...
@@ -148,7 +160,7 @@ class DatasourceControl extends React.PureComponent {
{
t
(
'
Explore in SQL Lab
'
)
}
{
t
(
'
Explore in SQL Lab
'
)
}
</
MenuItem
>
</
MenuItem
>
)
}
)
}
{
!!
this
.
props
.
onDatasourceSav
e
&&
(
{
this
.
props
.
isEditabl
e
&&
(
<
MenuItem
eventKey
=
"3"
onClick
=
{
this
.
toggleEditDatasourceModal
}
>
<
MenuItem
eventKey
=
"3"
onClick
=
{
this
.
toggleEditDatasourceModal
}
>
{
t
(
'
Edit Datasource
'
)
}
{
t
(
'
Edit Datasource
'
)
}
</
MenuItem
>
</
MenuItem
>
...
@@ -179,11 +191,11 @@ class DatasourceControl extends React.PureComponent {
...
@@ -179,11 +191,11 @@ class DatasourceControl extends React.PureComponent {
<
DatasourceModal
<
DatasourceModal
datasource
=
{
datasource
}
datasource
=
{
datasource
}
show
=
{
showEditDatasourceModal
}
show
=
{
showEditDatasourceModal
}
onDatasourceSave
=
{
onDatasourceSave
}
onDatasourceSave
=
{
this
.
onDatasourceSave
}
onHide
=
{
this
.
toggleEditDatasourceModal
}
onHide
=
{
this
.
toggleEditDatasourceModal
}
/>
/>
<
ChangeDatasourceModal
<
ChangeDatasourceModal
onDatasourceSave
=
{
onDatasourceSave
}
onDatasourceSave
=
{
this
.
onDatasourceSave
}
onHide
=
{
this
.
toggleChangeDatasourceModal
}
onHide
=
{
this
.
toggleChangeDatasourceModal
}
show
=
{
showChangeDatasourceModal
}
show
=
{
showChangeDatasourceModal
}
onChange
=
{
onChange
}
onChange
=
{
onChange
}
...
...
superset-frontend/src/explore/controlUtils.js
浏览文件 @
4d179622
...
@@ -20,7 +20,6 @@ import memoizeOne from 'memoize-one';
...
@@ -20,7 +20,6 @@ import memoizeOne from 'memoize-one';
import
{
getChartControlPanelRegistry
}
from
'
@superset-ui/chart
'
;
import
{
getChartControlPanelRegistry
}
from
'
@superset-ui/chart
'
;
import
{
expandControlConfig
}
from
'
@superset-ui/chart-controls
'
;
import
{
expandControlConfig
}
from
'
@superset-ui/chart-controls
'
;
import
{
controls
as
SHARED_CONTROLS
}
from
'
./controls
'
;
import
{
controls
as
SHARED_CONTROLS
}
from
'
./controls
'
;
import
*
as
exploreActions
from
'
./actions/exploreActions
'
;
import
*
as
SECTIONS
from
'
./controlPanels/sections
'
;
import
*
as
SECTIONS
from
'
./controlPanels/sections
'
;
export
function
getFormDataFromControls
(
controlsState
)
{
export
function
getFormDataFromControls
(
controlsState
)
{
...
@@ -94,7 +93,7 @@ export function applyMapStateToPropsToControl(controlState, controlPanelState) {
...
@@ -94,7 +93,7 @@ export function applyMapStateToPropsToControl(controlState, controlPanelState) {
if
(
mapStateToProps
&&
controlPanelState
)
{
if
(
mapStateToProps
&&
controlPanelState
)
{
return
{
return
{
...
controlState
,
...
controlState
,
...
mapStateToProps
(
controlPanelState
,
controlState
,
exploreActions
),
...
mapStateToProps
(
controlPanelState
,
controlState
),
};
};
}
}
return
controlState
;
return
controlState
;
...
...
superset-frontend/src/explore/controls.jsx
浏览文件 @
4d179622
...
@@ -204,9 +204,9 @@ export const controls = {
...
@@ -204,9 +204,9 @@ export const controls = {
label
:
t
(
'
Datasource
'
),
label
:
t
(
'
Datasource
'
),
default
:
null
,
default
:
null
,
description
:
null
,
description
:
null
,
mapStateToProps
:
(
state
,
control
,
actions
)
=>
({
mapStateToProps
:
(
{
datasource
}
)
=>
({
datasource
:
state
.
datasource
,
datasource
,
onDatasourceSave
:
actions
?
actions
.
setDatasource
:
()
=>
{}
,
isEditable
:
!!
datasource
,
}),
}),
},
},
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录