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
5f6838ab
Unverified
Commit
5f6838ab
authored
Mar 11, 2019
by
Torkel Ödegaard
Committed by
GitHub
Mar 11, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #15847 from grafana/15482-go-home-with-logo
Logo takes you Home instead of toggling side menu #15482
parents
26779e07
0736b8a1
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
42 additions
and
120 deletions
+42
-120
public/app/core/components/sidemenu/SideMenu.test.tsx
+0
-16
public/app/core/components/sidemenu/SideMenu.tsx
+5
-15
public/app/core/components/sidemenu/__snapshots__/SideMenu.test.tsx.snap
+3
-3
public/app/core/services/context_srv.ts
+0
-9
public/app/routes/GrafanaCtrl.ts
+3
-19
public/sass/components/_navbar.scss
+1
-7
public/sass/components/_sidemenu.scss
+14
-16
public/sass/components/_view_states.scss
+15
-0
public/sass/pages/_explore.scss
+1
-35
No files found.
public/app/core/components/sidemenu/SideMenu.test.tsx
View file @
5f6838ab
...
...
@@ -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 @
5f6838ab
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/components/sidemenu/__snapshots__/SideMenu.test.tsx.snap
View file @
5f6838ab
...
...
@@ -2,16 +2,16 @@
exports[`Render should render component 1`] = `
Array [
<
div
<
a
className="sidemenu__logo"
href="/"
key="logo"
onClick={[Function]}
>
<img
alt="Grafana"
src="public/img/grafana_icon.svg"
/>
</
div
>,
</
a
>,
<div
className="sidemenu__logo_small_breakpoint"
key="hamburger"
...
...
public/app/core/services/context_srv.ts
View file @
5f6838ab
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,10 @@ export class ContextSrv {
isSignedIn
:
any
;
isGrafanaAdmin
:
any
;
isEditor
:
any
;
sidemenu
:
any
;
sidemenuSmallBreakpoint
=
false
;
hasEditPermissionInFolders
:
boolean
;
constructor
()
{
this
.
sidemenu
=
store
.
getBool
(
'grafana.sidemenu'
,
true
);
if
(
!
config
.
bootData
)
{
config
.
bootData
=
{
user
:
{},
settings
:
{}
};
}
...
...
@@ -55,11 +51,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 @
5f6838ab
...
...
@@ -75,27 +75,22 @@ export class GrafanaCtrl {
}
}
function
setViewModeBodyClass
(
body
:
JQuery
,
mode
:
KioskUrlValue
,
sidemenuOpen
:
boolean
)
{
function
setViewModeBodyClass
(
body
:
JQuery
,
mode
:
KioskUrlValue
)
{
body
.
removeClass
(
'view-mode--tv'
);
body
.
removeClass
(
'view-mode--kiosk'
);
body
.
removeClass
(
'view-mode--inactive'
);
switch
(
mode
)
{
case
'tv'
:
{
body
.
removeClass
(
'sidemenu-open'
);
body
.
addClass
(
'view-mode--tv'
);
break
;
}
// 1 & true for legacy states
case
'1'
:
case
true
:
{
body
.
removeClass
(
'sidemenu-open'
);
body
.
addClass
(
'view-mode--kiosk'
);
break
;
}
default
:
{
body
.
toggleClass
(
'sidemenu-open'
,
sidemenuOpen
);
}
}
}
...
...
@@ -105,7 +100,6 @@ export function grafanaAppDirective(playlistSrv, contextSrv, $timeout, $rootScop
restrict
:
'E'
,
controller
:
GrafanaCtrl
,
link
:
(
scope
,
elem
)
=>
{
let
sidemenuOpen
;
const
body
=
$
(
'body'
);
// see https://github.com/zenorocha/clipboard.js/issues/155
...
...
@@ -113,14 +107,6 @@ export function grafanaAppDirective(playlistSrv, contextSrv, $timeout, $rootScop
$
(
'.preloader'
).
remove
();
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'
);
});
...
...
@@ -163,7 +149,7 @@ export function grafanaAppDirective(playlistSrv, contextSrv, $timeout, $rootScop
$
(
'#tooltip, .tooltip'
).
remove
();
// check for kiosk url param
setViewModeBodyClass
(
body
,
data
.
params
.
kiosk
,
sidemenuOpen
);
setViewModeBodyClass
(
body
,
data
.
params
.
kiosk
);
// close all drops
for
(
const
drop
of
Drop
.
drops
)
{
...
...
@@ -198,7 +184,7 @@ export function grafanaAppDirective(playlistSrv, contextSrv, $timeout, $rootScop
}
$timeout
(()
=>
$location
.
search
(
search
));
setViewModeBodyClass
(
body
,
search
.
kiosk
,
sidemenuOpen
);
setViewModeBodyClass
(
body
,
search
.
kiosk
);
});
// handle in active view state class
...
...
@@ -218,7 +204,6 @@ export function grafanaAppDirective(playlistSrv, contextSrv, $timeout, $rootScop
if
(
new
Date
().
getTime
()
-
lastActivity
>
inActiveTimeLimit
)
{
activeUser
=
false
;
body
.
addClass
(
'view-mode--inactive'
);
body
.
removeClass
(
'sidemenu-open'
);
}
}
...
...
@@ -227,7 +212,6 @@ export function grafanaAppDirective(playlistSrv, contextSrv, $timeout, $rootScop
if
(
!
activeUser
)
{
activeUser
=
true
;
body
.
removeClass
(
'view-mode--inactive'
);
body
.
toggleClass
(
'sidemenu-open'
,
sidemenuOpen
);
}
}
...
...
public/sass/components/_navbar.scss
View file @
5f6838ab
...
...
@@ -157,15 +157,9 @@
@include
media-breakpoint-up
(
sm
)
{
.navbar
{
padding-left
:
60px
;
}
.sidemenu-open
{
.navbar
{
padding-left
:
25px
;
padding-left
:
20px
;
margin-left
:
0
;
}
}
.navbar-page-btn
{
.gicon
{
...
...
public/sass/components/_sidemenu.scss
View file @
5f6838ab
...
...
@@ -16,41 +16,39 @@
.sidemenu__close
{
display
:
none
;
}
}
// body class that hides sidemenu
.sidemenu-hidden
{
.sidemenu
{
display
:
none
;
}
}
@include
media-breakpoint-up
(
sm
)
{
.sidemenu-open
{
.sidemenu
{
@include
media-breakpoint-up
(
sm
)
{
background
:
$side-menu-bg
;
height
:
auto
;
box-shadow
:
$side-menu-shadow
;
position
:
relative
;
z-index
:
$zindex-sidemenu
;
}
}
.sidemenu__top
,
.sidemenu__bottom
{
display
:
block
;
}
// body class that hides sidemenu
.sidemenu-hidden
{
.sidemenu
{
display
:
none
;
}
}
.sidemenu__top
{
padding-top
:
3rem
;
flex-grow
:
1
;
display
:
none
;
}
.sidemenu__bottom
{
padding-bottom
:
$spacer
;
}
.sidemenu__top
,
.sidemenu__bottom
{
display
:
none
;
@include
media-breakpoint-up
(
sm
)
{
display
:
block
;
}
}
.sidemenu-item
{
...
...
public/sass/components/_view_states.scss
View file @
5f6838ab
...
...
@@ -29,6 +29,21 @@
.view-mode--tv
{
@extend
.view-mode--inactive
;
.sidemenu
{
position
:
fixed
;
background-color
:
transparent
;
box-shadow
:
none
;
.sidemenu__top
,
.sidemenu__bottom
{
display
:
none
;
}
}
.navbar
{
padding-left
:
$side-menu-width
;
}
.submenu-controls
{
display
:
none
;
}
...
...
public/sass/pages/_explore.scss
View file @
5f6838ab
...
...
@@ -25,20 +25,13 @@
}
}
.sidemenu-open
{
.explore-toolbar-header
{
padding
:
0
;
margin-left
:
0
;
}
}
.explore-toolbar
{
background
:
inherit
;
display
:
flex
;
flex-flow
:
row
wrap
;
justify-content
:
flex-start
;
height
:
auto
;
padding
:
0
px
$dashboard-padding
0
25px
;
padding
:
0
$dashboard-padding
;
border-bottom
:
1px
solid
#0000
;
transition-duration
:
0
.35s
;
transition-timing-function
:
ease-in-out
;
...
...
@@ -73,11 +66,6 @@
min-height
:
55px
;
line-height
:
55px
;
justify-content
:
space-between
;
margin-left
:
$panel-margin
*
3
;
}
.explore-toolbar-header
{
justify-content
:
space-between
;
align-items
:
center
;
}
...
...
@@ -134,20 +122,6 @@
}
@media
only
screen
and
(
max-width
:
803px
)
{
.sidemenu-open
{
.explore-toolbar-header-title
{
.navbar-page-btn
{
margin-left
:
0
;
}
}
}
.explore-toolbar-header-title
{
.navbar-page-btn
{
margin-left
:
$dashboard-padding
;
}
}
.btn-title
{
display
:
none
;
}
...
...
@@ -161,14 +135,6 @@
}
@media
only
screen
and
(
max-width
:
544px
)
{
.sidemenu-open
{
.explore-toolbar-header-title
{
.navbar-page-btn
{
margin-left
:
$dashboard-padding
;
}
}
}
.explore-toolbar-header-title
{
.navbar-page-btn
{
margin-left
:
$dashboard-padding
;
...
...
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