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
679ffbfd
Commit
679ffbfd
authored
Sep 10, 2018
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wip: progress on redux folder store
parent
9caa0301
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
75 additions
and
7 deletions
+75
-7
public/app/core/actions/index.ts
+2
-2
public/app/features/manage-dashboards/state/actions.ts
+37
-2
public/app/features/manage-dashboards/state/reducers.ts
+20
-0
public/app/stores/configureStore.ts
+2
-0
public/app/types/dashboard.ts
+11
-1
public/app/types/index.ts
+3
-2
No files found.
public/app/core/actions/index.ts
View file @
679ffbfd
import
{
updateLocation
}
from
'./location'
;
import
{
updateLocation
}
from
'./location'
;
import
{
updateNavIndex
}
from
'./navModel'
;
import
{
updateNavIndex
,
UpdateNavIndexAction
}
from
'./navModel'
;
export
{
updateLocation
,
updateNavIndex
};
export
{
updateLocation
,
updateNavIndex
,
UpdateNavIndexAction
};
public/app/features/manage-dashboards/state/actions.ts
View file @
679ffbfd
import
{
getBackendSrv
}
from
'app/core/services/backend_srv'
;
import
{
getBackendSrv
}
from
'app/core/services/backend_srv'
;
import
{
StoreState
}
from
'app/types'
;
import
{
StoreState
}
from
'app/types'
;
import
{
ThunkAction
}
from
'redux-thunk'
;
import
{
ThunkAction
}
from
'redux-thunk'
;
import
{
FolderDTO
}
from
'app/types'
;
import
{
FolderDTO
,
NavModelItem
}
from
'app/types'
;
import
{
updateNavIndex
,
UpdateNavIndexAction
}
from
'app/core/actions'
;
export
enum
ActionTypes
{
export
enum
ActionTypes
{
LoadFolder
=
'LOAD_FOLDER'
,
LoadFolder
=
'LOAD_FOLDER'
,
...
@@ -19,11 +20,45 @@ export const loadFolder = (folder: FolderDTO): LoadFolderAction => ({
...
@@ -19,11 +20,45 @@ export const loadFolder = (folder: FolderDTO): LoadFolderAction => ({
export
type
Action
=
LoadFolderAction
;
export
type
Action
=
LoadFolderAction
;
type
ThunkResult
<
R
>
=
ThunkAction
<
R
,
StoreState
,
undefined
,
Action
>
;
type
ThunkResult
<
R
>
=
ThunkAction
<
R
,
StoreState
,
undefined
,
Action
|
UpdateNavIndexAction
>
;
function
buildNavModel
(
folder
:
FolderDTO
):
NavModelItem
{
return
{
icon
:
'fa fa-folder-open'
,
id
:
'manage-folder'
,
subTitle
:
'Manage folder dashboards & permissions'
,
url
:
''
,
text
:
folder
.
title
,
breadcrumbs
:
[{
title
:
'Dashboards'
,
url
:
'dashboards'
}],
children
:
[
{
active
:
false
,
icon
:
'fa fa-fw fa-th-large'
,
id
:
`folder-dashboards-
${
folder
.
uid
}
`
,
text
:
'Dashboards'
,
url
:
folder
.
url
,
},
{
active
:
false
,
icon
:
'fa fa-fw fa-lock'
,
id
:
`folder-permissions-
${
folder
.
uid
}
`
,
text
:
'Permissions'
,
url
:
`
${
folder
.
url
}
/permissions`
,
},
{
active
:
false
,
icon
:
'fa fa-fw fa-cog'
,
id
:
`folder-settings-
${
folder
.
uid
}
`
,
text
:
'Settings'
,
url
:
`
${
folder
.
url
}
/settings`
,
},
],
};
}
export
function
getFolderByUid
(
uid
:
string
):
ThunkResult
<
void
>
{
export
function
getFolderByUid
(
uid
:
string
):
ThunkResult
<
void
>
{
return
async
dispatch
=>
{
return
async
dispatch
=>
{
const
folder
=
await
getBackendSrv
().
getFolderByUid
(
uid
);
const
folder
=
await
getBackendSrv
().
getFolderByUid
(
uid
);
dispatch
(
loadFolder
(
folder
));
dispatch
(
loadFolder
(
folder
));
dispatch
(
updateNavIndex
(
buildNavModel
(
folder
)));
};
};
}
}
public/app/features/manage-dashboards/state/reducers.ts
View file @
679ffbfd
import
{
FolderState
}
from
'app/types'
;
import
{
Action
,
ActionTypes
}
from
'./actions'
;
export
const
inititalState
:
FolderState
=
null
;
export
const
folderReducer
=
(
state
=
inititalState
,
action
:
Action
):
FolderState
=>
{
switch
(
action
.
type
)
{
case
ActionTypes
.
LoadFolder
:
return
{
...
action
.
payload
,
canSave
:
false
,
hasChanged
:
false
,
};
}
return
state
;
};
export
default
{
folder
:
folderReducer
,
};
public/app/stores/configureStore.ts
View file @
679ffbfd
...
@@ -4,11 +4,13 @@ import { createLogger } from 'redux-logger';
...
@@ -4,11 +4,13 @@ import { createLogger } from 'redux-logger';
import
sharedReducers
from
'app/core/reducers'
;
import
sharedReducers
from
'app/core/reducers'
;
import
alertingReducers
from
'app/features/alerting/state/reducers'
;
import
alertingReducers
from
'app/features/alerting/state/reducers'
;
import
teamsReducers
from
'app/features/teams/state/reducers'
;
import
teamsReducers
from
'app/features/teams/state/reducers'
;
import
manageDashboardsReducers
from
'app/features/manage-dashboards/state/reducers'
;
const
rootReducer
=
combineReducers
({
const
rootReducer
=
combineReducers
({
...
sharedReducers
,
...
sharedReducers
,
...
alertingReducers
,
...
alertingReducers
,
...
teamsReducers
,
...
teamsReducers
,
...
manageDashboardsReducers
,
});
});
export
let
store
;
export
let
store
;
...
...
public/app/types/dashboard.ts
View file @
679ffbfd
export
interface
FolderDTO
{
export
interface
FolderDTO
{
id
:
number
;
id
:
number
;
uid
:
string
;
title
:
string
;
title
:
string
;
url
:
string
;
url
:
string
;
version
:
number
;
version
:
number
;
hasAcl
:
boolean
;
}
export
interface
FolderState
{
id
:
number
;
uid
:
string
;
title
:
string
;
url
:
string
;
version
:
number
;
canSave
:
boolean
;
hasChanged
:
boolean
;
}
}
public/app/types/index.ts
View file @
679ffbfd
import
{
FolderDTO
}
from
'./dashboard'
;
import
{
FolderDTO
,
FolderState
}
from
'./dashboard'
;
export
{
FolderDTO
};
export
{
FolderDTO
,
FolderState
};
//
//
// Location
// Location
...
@@ -136,4 +136,5 @@ export interface StoreState {
...
@@ -136,4 +136,5 @@ export interface StoreState {
alertRules
:
AlertRulesState
;
alertRules
:
AlertRulesState
;
teams
:
TeamsState
;
teams
:
TeamsState
;
team
:
TeamState
;
team
:
TeamState
;
folder
:
FolderState
;
}
}
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