Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
24b475e4
Unverified
Commit
24b475e4
authored
Oct 14, 2019
by
Hugo Häggmark
Committed by
GitHub
Oct 14, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Panels: Fixes default tab for visualizations without Queries Tab (#19803)
Fixes #19762
parent
428ca600
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
104 additions
and
7 deletions
+104
-7
public/app/features/dashboard/panel_editor/PanelEditor.tsx
+5
-7
public/app/features/dashboard/panel_editor/state/selectors.test.ts
+88
-0
public/app/features/dashboard/panel_editor/state/selectors.ts
+11
-0
No files found.
public/app/features/dashboard/panel_editor/PanelEditor.tsx
View file @
24b475e4
...
...
@@ -2,7 +2,7 @@ import React, { PureComponent } from 'react';
import
classNames
from
'classnames'
;
import
{
hot
}
from
'react-hot-loader'
;
import
{
connect
}
from
'react-redux'
;
import
{
Tooltip
,
PanelPlugin
,
PanelPluginMeta
}
from
'@grafana/ui'
;
import
{
PanelPlugin
,
PanelPluginMeta
,
Tooltip
}
from
'@grafana/ui'
;
import
{
AngularComponent
,
config
}
from
'@grafana/runtime'
;
import
{
QueriesTab
}
from
'./QueriesTab'
;
...
...
@@ -12,8 +12,9 @@ import { AlertTab } from '../../alerting/AlertTab';
import
{
PanelModel
}
from
'../state/PanelModel'
;
import
{
DashboardModel
}
from
'../state/DashboardModel'
;
import
{
StoreState
}
from
'../../../types'
;
import
{
PanelEditorTabIds
,
PanelEditorTab
}
from
'./state/reducers'
;
import
{
refreshPanelEditor
,
changePanelEditorTab
,
panelEditorCleanUp
}
from
'./state/actions'
;
import
{
PanelEditorTab
,
PanelEditorTabIds
}
from
'./state/reducers'
;
import
{
changePanelEditorTab
,
panelEditorCleanUp
,
refreshPanelEditor
}
from
'./state/actions'
;
import
{
getActiveTabAndTabs
}
from
'./state/selectors'
;
interface
PanelEditorProps
{
panel
:
PanelModel
;
...
...
@@ -108,10 +109,7 @@ class UnConnectedPanelEditor extends PureComponent<PanelEditorProps> {
}
}
export
const
mapStateToProps
=
(
state
:
StoreState
)
=>
({
activeTab
:
state
.
location
.
query
.
tab
||
PanelEditorTabIds
.
Queries
,
tabs
:
state
.
panelEditor
.
tabs
,
});
export
const
mapStateToProps
=
(
state
:
StoreState
)
=>
getActiveTabAndTabs
(
state
.
location
,
state
.
panelEditor
);
const
mapDispatchToProps
=
{
refreshPanelEditor
,
panelEditorCleanUp
,
changePanelEditorTab
};
...
...
public/app/features/dashboard/panel_editor/state/selectors.test.ts
0 → 100644
View file @
24b475e4
import
{
getActiveTabAndTabs
}
from
'./selectors'
;
import
{
LocationState
}
from
'../../../../types'
;
import
{
getPanelEditorTab
,
PanelEditorState
,
PanelEditorTab
,
PanelEditorTabIds
}
from
'./reducers'
;
describe
(
'getActiveTabAndTabs'
,
()
=>
{
describe
(
'when called and location state contains tab'
,
()
=>
{
it
(
'then it should return location state'
,
()
=>
{
const
activeTabId
=
1337
;
const
location
:
LocationState
=
{
path
:
'a path'
,
lastUpdated
:
1
,
replace
:
false
,
routeParams
:
{},
query
:
{
tab
:
activeTabId
,
},
url
:
'an url'
,
};
const
panelEditor
:
PanelEditorState
=
{
activeTab
:
PanelEditorTabIds
.
Queries
,
tabs
:
[],
};
const
result
=
getActiveTabAndTabs
(
location
,
panelEditor
);
expect
(
result
).
toEqual
({
activeTab
:
activeTabId
,
tabs
:
[],
});
});
});
describe
(
'when called without location state and PanelEditor state contains tabs'
,
()
=>
{
it
(
'then it should return the id for the first tab in PanelEditor state'
,
()
=>
{
const
activeTabId
=
PanelEditorTabIds
.
Visualization
;
const
tabs
=
[
getPanelEditorTab
(
PanelEditorTabIds
.
Visualization
),
getPanelEditorTab
(
PanelEditorTabIds
.
Advanced
)];
const
location
:
LocationState
=
{
path
:
'a path'
,
lastUpdated
:
1
,
replace
:
false
,
routeParams
:
{},
query
:
{
tab
:
undefined
,
},
url
:
'an url'
,
};
const
panelEditor
:
PanelEditorState
=
{
activeTab
:
PanelEditorTabIds
.
Advanced
,
tabs
,
};
const
result
=
getActiveTabAndTabs
(
location
,
panelEditor
);
expect
(
result
).
toEqual
({
activeTab
:
activeTabId
,
tabs
,
});
});
});
describe
(
'when called without location state and PanelEditor state does not contain tabs'
,
()
=>
{
it
(
'then it should return PanelEditorTabIds.Queries'
,
()
=>
{
const
activeTabId
=
PanelEditorTabIds
.
Queries
;
const
tabs
:
PanelEditorTab
[]
=
[];
const
location
:
LocationState
=
{
path
:
'a path'
,
lastUpdated
:
1
,
replace
:
false
,
routeParams
:
{},
query
:
{
tab
:
undefined
,
},
url
:
'an url'
,
};
const
panelEditor
:
PanelEditorState
=
{
activeTab
:
PanelEditorTabIds
.
Advanced
,
tabs
,
};
const
result
=
getActiveTabAndTabs
(
location
,
panelEditor
);
expect
(
result
).
toEqual
({
activeTab
:
activeTabId
,
tabs
,
});
});
});
});
public/app/features/dashboard/panel_editor/state/selectors.ts
0 → 100644
View file @
24b475e4
import
memoizeOne
from
'memoize-one'
;
import
{
LocationState
}
from
'../../../../types'
;
import
{
PanelEditorState
,
PanelEditorTabIds
}
from
'./reducers'
;
export
const
getActiveTabAndTabs
=
memoizeOne
((
location
:
LocationState
,
panelEditor
:
PanelEditorState
)
=>
{
const
panelEditorTab
=
panelEditor
.
tabs
.
length
>
0
?
panelEditor
.
tabs
[
0
].
id
:
PanelEditorTabIds
.
Queries
;
return
{
activeTab
:
location
.
query
.
tab
||
panelEditorTab
,
tabs
:
panelEditor
.
tabs
,
};
});
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