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
d6449ee6
Commit
d6449ee6
authored
Mar 07, 2019
by
Johannes Schill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: Logo goes Home instead of toggling side menu #15482
parent
bc2a7981
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
6 additions
and
45 deletions
+6
-45
public/app/core/components/sidemenu/SideMenu.test.tsx
+0
-16
public/app/core/components/sidemenu/SideMenu.tsx
+5
-15
public/app/core/services/context_srv.ts
+1
-9
public/app/routes/GrafanaCtrl.ts
+0
-5
No files found.
public/app/core/components/sidemenu/SideMenu.test.tsx
View file @
d6449ee6
...
...
@@ -2,7 +2,6 @@ import React from 'react';
import
{
shallow
}
from
'enzyme'
;
import
{
SideMenu
}
from
'./SideMenu'
;
import
appEvents
from
'../../app_events'
;
import
{
contextSrv
}
from
'app/core/services/context_srv'
;
jest
.
mock
(
'../../app_events'
,
()
=>
({
emit
:
jest
.
fn
(),
...
...
@@ -26,7 +25,6 @@ jest.mock('app/core/services/context_srv', () => ({
isGrafanaAdmin
:
false
,
isEditor
:
false
,
hasEditPermissionFolders
:
false
,
toggleSideMenu
:
jest
.
fn
(),
},
}));
...
...
@@ -54,20 +52,6 @@ describe('Render', () => {
});
describe
(
'Functions'
,
()
=>
{
describe
(
'toggle side menu'
,
()
=>
{
const
wrapper
=
setup
();
const
instance
=
wrapper
.
instance
()
as
SideMenu
;
instance
.
toggleSideMenu
();
it
(
'should call contextSrv.toggleSideMenu'
,
()
=>
{
expect
(
contextSrv
.
toggleSideMenu
).
toHaveBeenCalled
();
});
it
(
'should emit toggle sidemenu event'
,
()
=>
{
expect
(
appEvents
.
emit
).
toHaveBeenCalledWith
(
'toggle-sidemenu'
);
});
});
describe
(
'toggle side menu on mobile'
,
()
=>
{
const
wrapper
=
setup
();
const
instance
=
wrapper
.
instance
()
as
SideMenu
;
...
...
public/app/core/components/sidemenu/SideMenu.tsx
View file @
d6449ee6
import
React
,
{
PureComponent
}
from
'react'
;
import
appEvents
from
'../../app_events'
;
import
{
contextSrv
}
from
'app/core/services/context_srv'
;
import
TopSection
from
'./TopSection'
;
import
BottomSection
from
'./BottomSection'
;
import
{
store
}
from
'app/store/store
'
;
import
config
from
'app/core/config
'
;
export
class
SideMenu
extends
PureComponent
{
toggleSideMenu
=
()
=>
{
// ignore if we just made a location change, stops hiding sidemenu on double clicks of back button
const
timeSinceLocationChanged
=
new
Date
().
getTime
()
-
store
.
getState
().
location
.
lastUpdated
;
if
(
timeSinceLocationChanged
<
1000
)
{
return
;
}
contextSrv
.
toggleSideMenu
();
appEvents
.
emit
(
'toggle-sidemenu'
);
};
const
homeUrl
=
config
.
appSubUrl
||
'/'
;
export
class
SideMenu
extends
PureComponent
{
toggleSideMenuSmallBreakpoint
=
()
=>
{
appEvents
.
emit
(
'toggle-sidemenu-mobile'
);
};
render
()
{
return
[
<
div
className=
"sidemenu__logo"
onClick=
{
this
.
toggleSideMenu
}
key=
"logo"
>
<
a
href=
{
homeUrl
}
className=
"sidemenu__logo"
key=
"logo"
>
<
img
src=
"public/img/grafana_icon.svg"
alt=
"Grafana"
/>
</
div
>,
</
a
>,
<
div
className=
"sidemenu__logo_small_breakpoint"
onClick=
{
this
.
toggleSideMenuSmallBreakpoint
}
key=
"hamburger"
>
<
i
className=
"fa fa-bars"
/>
<
span
className=
"sidemenu__close"
>
...
...
public/app/core/services/context_srv.ts
View file @
d6449ee6
import
config
from
'app/core/config'
;
import
_
from
'lodash'
;
import
coreModule
from
'app/core/core_module'
;
import
store
from
'app/core/store'
;
export
class
User
{
isGrafanaAdmin
:
any
;
...
...
@@ -29,13 +28,11 @@ export class ContextSrv {
isSignedIn
:
any
;
isGrafanaAdmin
:
any
;
isEditor
:
any
;
sidemenu
:
any
;
sidemenu
=
true
;
sidemenuSmallBreakpoint
=
false
;
hasEditPermissionInFolders
:
boolean
;
constructor
()
{
this
.
sidemenu
=
store
.
getBool
(
'grafana.sidemenu'
,
true
);
if
(
!
config
.
bootData
)
{
config
.
bootData
=
{
user
:
{},
settings
:
{}
};
}
...
...
@@ -55,11 +52,6 @@ export class ContextSrv {
return
!!
(
document
.
visibilityState
===
undefined
||
document
.
visibilityState
===
'visible'
);
}
toggleSideMenu
()
{
this
.
sidemenu
=
!
this
.
sidemenu
;
store
.
set
(
'grafana.sidemenu'
,
this
.
sidemenu
);
}
hasAccessToExplore
()
{
return
(
this
.
isEditor
||
config
.
viewersCanEdit
)
&&
config
.
exploreEnabled
;
}
...
...
public/app/routes/GrafanaCtrl.ts
View file @
d6449ee6
...
...
@@ -116,11 +116,6 @@ export function grafanaAppDirective(playlistSrv, contextSrv, $timeout, $rootScop
sidemenuOpen
=
scope
.
contextSrv
.
sidemenu
;
body
.
toggleClass
(
'sidemenu-open'
,
sidemenuOpen
);
appEvents
.
on
(
'toggle-sidemenu'
,
()
=>
{
sidemenuOpen
=
scope
.
contextSrv
.
sidemenu
;
body
.
toggleClass
(
'sidemenu-open'
);
});
appEvents
.
on
(
'toggle-sidemenu-mobile'
,
()
=>
{
body
.
toggleClass
(
'sidemenu-open--xs'
);
});
...
...
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