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
0705bf57
Commit
0705bf57
authored
Sep 12, 2018
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: added loading nav states
parent
a83beac5
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
106 additions
and
51 deletions
+106
-51
public/app/core/selectors/navModel.ts
+7
-3
public/app/features/folders/FolderPermissions.tsx
+3
-2
public/app/features/folders/FolderSettingsPage.tsx
+3
-1
public/app/features/folders/state/navModel.ts
+19
-1
public/app/features/teams/TeamPages.tsx
+5
-3
public/app/features/teams/state/actions.ts
+2
-41
public/app/features/teams/state/navModel.ts
+67
-0
No files found.
public/app/core/selectors/navModel.ts
View file @
0705bf57
...
@@ -15,7 +15,7 @@ function getNotFoundModel(): NavModel {
...
@@ -15,7 +15,7 @@ function getNotFoundModel(): NavModel {
};
};
}
}
export
function
getNavModel
(
navIndex
:
NavIndex
,
id
:
string
):
NavModel
{
export
function
getNavModel
(
navIndex
:
NavIndex
,
id
:
string
,
fallback
?:
NavModel
):
NavModel
{
if
(
navIndex
[
id
])
{
if
(
navIndex
[
id
])
{
const
node
=
navIndex
[
id
];
const
node
=
navIndex
[
id
];
const
main
=
{
const
main
=
{
...
@@ -33,7 +33,11 @@ export function getNavModel(navIndex: NavIndex, id: string): NavModel {
...
@@ -33,7 +33,11 @@ export function getNavModel(navIndex: NavIndex, id: string): NavModel {
node
:
node
,
node
:
node
,
main
:
main
,
main
:
main
,
};
};
}
else
{
return
getNotFoundModel
();
}
}
if
(
fallback
)
{
return
fallback
;
}
return
getNotFoundModel
();
}
}
public/app/features/folders/FolderPermissions.tsx
View file @
0705bf57
...
@@ -12,6 +12,7 @@ import { getNavModel } from 'app/core/selectors/navModel';
...
@@ -12,6 +12,7 @@ import { getNavModel } from 'app/core/selectors/navModel';
import
{
NavModel
,
StoreState
,
FolderState
}
from
'app/types'
;
import
{
NavModel
,
StoreState
,
FolderState
}
from
'app/types'
;
import
{
getFolderByUid
}
from
'./state/actions'
;
import
{
getFolderByUid
}
from
'./state/actions'
;
import
{
PermissionsStore
}
from
'app/stores/PermissionsStore/PermissionsStore'
;
import
{
PermissionsStore
}
from
'app/stores/PermissionsStore/PermissionsStore'
;
import
{
getLoadingNav
}
from
'./state/navModel'
;
export
interface
Props
{
export
interface
Props
{
navModel
:
NavModel
;
navModel
:
NavModel
;
...
@@ -48,7 +49,7 @@ export class FolderPermissions extends Component<Props> {
...
@@ -48,7 +49,7 @@ export class FolderPermissions extends Component<Props> {
const
{
navModel
,
permissions
,
backendSrv
,
folder
}
=
this
.
props
;
const
{
navModel
,
permissions
,
backendSrv
,
folder
}
=
this
.
props
;
if
(
folder
.
id
===
0
)
{
if
(
folder
.
id
===
0
)
{
return
<
h2
>
Loading
</
h2
>;
return
<
PageHeader
model=
{
navModel
}
/
>;
}
}
const
dashboardId
=
folder
.
id
;
const
dashboardId
=
folder
.
id
;
...
@@ -84,7 +85,7 @@ export class FolderPermissions extends Component<Props> {
...
@@ -84,7 +85,7 @@ export class FolderPermissions extends Component<Props> {
const
mapStateToProps
=
(
state
:
StoreState
)
=>
{
const
mapStateToProps
=
(
state
:
StoreState
)
=>
{
const
uid
=
state
.
location
.
routeParams
.
uid
;
const
uid
=
state
.
location
.
routeParams
.
uid
;
return
{
return
{
navModel
:
getNavModel
(
state
.
navIndex
,
`folder-permissions-
${
uid
}
`
),
navModel
:
getNavModel
(
state
.
navIndex
,
`folder-permissions-
${
uid
}
`
,
getLoadingNav
(
1
)
),
folderUid
:
uid
,
folderUid
:
uid
,
folder
:
state
.
folder
,
folder
:
state
.
folder
,
};
};
...
...
public/app/features/folders/FolderSettingsPage.tsx
View file @
0705bf57
...
@@ -6,6 +6,7 @@ import appEvents from 'app/core/app_events';
...
@@ -6,6 +6,7 @@ import appEvents from 'app/core/app_events';
import
{
getNavModel
}
from
'app/core/selectors/navModel'
;
import
{
getNavModel
}
from
'app/core/selectors/navModel'
;
import
{
NavModel
,
StoreState
,
FolderState
}
from
'app/types'
;
import
{
NavModel
,
StoreState
,
FolderState
}
from
'app/types'
;
import
{
getFolderByUid
,
setFolderTitle
,
saveFolder
,
deleteFolder
}
from
'./state/actions'
;
import
{
getFolderByUid
,
setFolderTitle
,
saveFolder
,
deleteFolder
}
from
'./state/actions'
;
import
{
getLoadingNav
}
from
'./state/navModel'
;
export
interface
Props
{
export
interface
Props
{
navModel
:
NavModel
;
navModel
:
NavModel
;
...
@@ -86,8 +87,9 @@ export class FolderSettingsPage extends PureComponent<Props> {
...
@@ -86,8 +87,9 @@ export class FolderSettingsPage extends PureComponent<Props> {
const
mapStateToProps
=
(
state
:
StoreState
)
=>
{
const
mapStateToProps
=
(
state
:
StoreState
)
=>
{
const
uid
=
state
.
location
.
routeParams
.
uid
;
const
uid
=
state
.
location
.
routeParams
.
uid
;
return
{
return
{
navModel
:
getNavModel
(
state
.
navIndex
,
`folder-settings-
${
uid
}
`
),
navModel
:
getNavModel
(
state
.
navIndex
,
`folder-settings-
${
uid
}
`
,
getLoadingNav
(
2
)
),
folderUid
:
uid
,
folderUid
:
uid
,
folder
:
state
.
folder
,
folder
:
state
.
folder
,
};
};
...
...
public/app/features/folders/state/navModel.ts
View file @
0705bf57
import
{
FolderDTO
,
NavModelItem
}
from
'app/types'
;
import
{
FolderDTO
,
NavModelItem
,
NavModel
}
from
'app/types'
;
export
function
buildNavModel
(
folder
:
FolderDTO
):
NavModelItem
{
export
function
buildNavModel
(
folder
:
FolderDTO
):
NavModelItem
{
return
{
return
{
...
@@ -33,3 +33,21 @@ export function buildNavModel(folder: FolderDTO): NavModelItem {
...
@@ -33,3 +33,21 @@ export function buildNavModel(folder: FolderDTO): NavModelItem {
],
],
};
};
}
}
export
function
getLoadingNav
(
tabIndex
:
number
):
NavModel
{
const
main
=
buildNavModel
({
id
:
1
,
uid
:
'loading'
,
title
:
'Loading'
,
url
:
'url'
,
canSave
:
false
,
version
:
0
,
});
main
.
children
[
tabIndex
].
active
=
true
;
return
{
main
:
main
,
node
:
main
.
children
[
tabIndex
],
};
}
public/app/features/teams/TeamPages.tsx
View file @
0705bf57
...
@@ -7,10 +7,11 @@ import PageHeader from 'app/core/components/PageHeader/PageHeader';
...
@@ -7,10 +7,11 @@ import PageHeader from 'app/core/components/PageHeader/PageHeader';
import
TeamMembers
from
'./TeamMembers'
;
import
TeamMembers
from
'./TeamMembers'
;
import
TeamSettings
from
'./TeamSettings'
;
import
TeamSettings
from
'./TeamSettings'
;
import
TeamGroupSync
from
'./TeamGroupSync'
;
import
TeamGroupSync
from
'./TeamGroupSync'
;
import
{
NavModel
,
Team
}
from
'
../..
/types'
;
import
{
NavModel
,
Team
}
from
'
app
/types'
;
import
{
loadTeam
}
from
'./state/actions'
;
import
{
loadTeam
}
from
'./state/actions'
;
import
{
getTeam
}
from
'./state/selectors'
;
import
{
getTeam
}
from
'./state/selectors'
;
import
{
getNavModel
}
from
'../../core/selectors/navModel'
;
import
{
getTeamLoadingNav
}
from
'./state/navModel'
;
import
{
getNavModel
}
from
'app/core/selectors/navModel'
;
import
{
getRouteParamsId
,
getRouteParamsPage
}
from
'../../core/selectors/location'
;
import
{
getRouteParamsId
,
getRouteParamsPage
}
from
'../../core/selectors/location'
;
export
interface
Props
{
export
interface
Props
{
...
@@ -89,9 +90,10 @@ export class TeamPages extends PureComponent<Props, State> {
...
@@ -89,9 +90,10 @@ export class TeamPages extends PureComponent<Props, State> {
function
mapStateToProps
(
state
)
{
function
mapStateToProps
(
state
)
{
const
teamId
=
getRouteParamsId
(
state
.
location
);
const
teamId
=
getRouteParamsId
(
state
.
location
);
const
pageName
=
getRouteParamsPage
(
state
.
location
)
||
'members'
;
const
pageName
=
getRouteParamsPage
(
state
.
location
)
||
'members'
;
const
teamLoadingNav
=
getTeamLoadingNav
(
pageName
);
return
{
return
{
navModel
:
getNavModel
(
state
.
navIndex
,
`team-
${
pageName
}
-
${
teamId
}
`
),
navModel
:
getNavModel
(
state
.
navIndex
,
`team-
${
pageName
}
-
${
teamId
}
`
,
teamLoadingNav
),
teamId
:
teamId
,
teamId
:
teamId
,
pageName
:
pageName
,
pageName
:
pageName
,
team
:
getTeam
(
state
.
team
,
teamId
),
team
:
getTeam
(
state
.
team
,
teamId
),
...
...
public/app/features/teams/state/actions.ts
View file @
0705bf57
import
{
ThunkAction
}
from
'redux-thunk'
;
import
{
ThunkAction
}
from
'redux-thunk'
;
import
{
getBackendSrv
}
from
'app/core/services/backend_srv'
;
import
{
getBackendSrv
}
from
'app/core/services/backend_srv'
;
import
{
NavModelItem
,
StoreState
,
Team
,
TeamGroup
,
TeamMember
}
from
'app/types'
;
import
{
StoreState
,
Team
,
TeamGroup
,
TeamMember
}
from
'app/types'
;
import
{
updateNavIndex
,
UpdateNavIndexAction
}
from
'app/core/actions'
;
import
{
updateNavIndex
,
UpdateNavIndexAction
}
from
'app/core/actions'
;
import
config
from
'app/core/config
'
;
import
{
buildNavModel
}
from
'./navModel
'
;
export
enum
ActionTypes
{
export
enum
ActionTypes
{
LoadTeams
=
'LOAD_TEAMS'
,
LoadTeams
=
'LOAD_TEAMS'
,
...
@@ -90,45 +90,6 @@ export function loadTeams(): ThunkResult<void> {
...
@@ -90,45 +90,6 @@ export function loadTeams(): ThunkResult<void> {
};
};
}
}
function
buildNavModel
(
team
:
Team
):
NavModelItem
{
const
navModel
=
{
img
:
team
.
avatarUrl
,
id
:
'team-'
+
team
.
id
,
subTitle
:
'Manage members & settings'
,
url
:
''
,
text
:
team
.
name
,
breadcrumbs
:
[{
title
:
'Teams'
,
url
:
'org/teams'
}],
children
:
[
{
active
:
false
,
icon
:
'gicon gicon-team'
,
id
:
`team-members-
${
team
.
id
}
`
,
text
:
'Members'
,
url
:
`org/teams/edit/
${
team
.
id
}
/members`
,
},
{
active
:
false
,
icon
:
'fa fa-fw fa-sliders'
,
id
:
`team-settings-
${
team
.
id
}
`
,
text
:
'Settings'
,
url
:
`org/teams/edit/
${
team
.
id
}
/settings`
,
},
],
};
if
(
config
.
buildInfo
.
isEnterprise
)
{
navModel
.
children
.
push
({
active
:
false
,
icon
:
'fa fa-fw fa-refresh'
,
id
:
`team-groupsync-
${
team
.
id
}
`
,
text
:
'External group sync'
,
url
:
`org/teams/edit/
${
team
.
id
}
/groupsync`
,
});
}
return
navModel
;
}
export
function
loadTeam
(
id
:
number
):
ThunkResult
<
void
>
{
export
function
loadTeam
(
id
:
number
):
ThunkResult
<
void
>
{
return
async
dispatch
=>
{
return
async
dispatch
=>
{
const
response
=
await
getBackendSrv
().
get
(
`/api/teams/
${
id
}
`
);
const
response
=
await
getBackendSrv
().
get
(
`/api/teams/
${
id
}
`
);
...
...
public/app/features/teams/state/navModel.ts
0 → 100644
View file @
0705bf57
import
{
Team
,
NavModelItem
,
NavModel
}
from
'app/types'
;
import
config
from
'app/core/config'
;
export
function
buildNavModel
(
team
:
Team
):
NavModelItem
{
const
navModel
=
{
img
:
team
.
avatarUrl
,
id
:
'team-'
+
team
.
id
,
subTitle
:
'Manage members & settings'
,
url
:
''
,
text
:
team
.
name
,
breadcrumbs
:
[{
title
:
'Teams'
,
url
:
'org/teams'
}],
children
:
[
{
active
:
false
,
icon
:
'gicon gicon-team'
,
id
:
`team-members-
${
team
.
id
}
`
,
text
:
'Members'
,
url
:
`org/teams/edit/
${
team
.
id
}
/members`
,
},
{
active
:
false
,
icon
:
'fa fa-fw fa-sliders'
,
id
:
`team-settings-
${
team
.
id
}
`
,
text
:
'Settings'
,
url
:
`org/teams/edit/
${
team
.
id
}
/settings`
,
},
],
};
if
(
config
.
buildInfo
.
isEnterprise
)
{
navModel
.
children
.
push
({
active
:
false
,
icon
:
'fa fa-fw fa-refresh'
,
id
:
`team-groupsync-
${
team
.
id
}
`
,
text
:
'External group sync'
,
url
:
`org/teams/edit/
${
team
.
id
}
/groupsync`
,
});
}
return
navModel
;
}
export
function
getTeamLoadingNav
(
pageName
:
string
):
NavModel
{
const
main
=
buildNavModel
({
avatarUrl
:
'public/img/user_profile.png'
,
id
:
1
,
name
:
'Loading'
,
email
:
'loading'
,
memberCount
:
0
,
});
let
node
:
NavModelItem
;
// find active page
for
(
const
child
of
main
.
children
)
{
if
(
child
.
id
.
indexOf
(
pageName
)
>
0
)
{
child
.
active
=
true
;
node
=
child
;
break
;
}
}
return
{
main
:
main
,
node
:
node
,
};
}
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