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
1e2c0608
Commit
1e2c0608
authored
Sep 27, 2018
by
Peter Holmberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rewrote to use react.sfc
parent
70c3e1f3
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
66 additions
and
26 deletions
+66
-26
public/app/core/components/LayoutSelector/LayoutSelector.tsx
+22
-7
public/app/features/plugins/PluginActionBar.test.tsx
+2
-1
public/app/features/plugins/PluginActionBar.tsx
+3
-3
public/app/features/plugins/PluginList.test.tsx
+2
-1
public/app/features/plugins/PluginList.tsx
+16
-5
public/app/features/plugins/PluginListItem.tsx
+12
-3
public/app/features/plugins/PluginListPage.tsx
+3
-2
public/app/features/plugins/__snapshots__/PluginListPage.test.tsx.snap
+1
-1
public/app/features/plugins/state/actions.ts
+3
-2
public/app/features/plugins/state/reducers.ts
+2
-1
No files found.
public/app/core/components/LayoutSelector/LayoutSelector.tsx
View file @
1e2c0608
import
React
from
'react'
;
import
React
,
{
SFC
}
from
'react'
;
export
default
function
LayoutSelector
({
mode
,
onLayoutModeChanged
})
{
export
type
LayoutMode
=
LayoutModes
.
Grid
|
LayoutModes
.
List
;
export
enum
LayoutModes
{
Grid
=
'grid'
,
List
=
'list'
,
}
interface
Props
{
mode
:
LayoutMode
;
onLayoutModeChanged
:
(
mode
:
LayoutMode
)
=>
{};
}
const
LayoutSelector
:
SFC
<
Props
>
=
props
=>
{
const
{
mode
,
onLayoutModeChanged
}
=
props
;
return
(
<
div
className=
"layout-selector"
>
<
button
onClick=
{
()
=>
{
onLayoutModeChanged
(
'list'
);
onLayoutModeChanged
(
LayoutModes
.
List
);
}
}
className=
{
mode
===
'list'
?
'active'
:
''
}
className=
{
mode
===
LayoutModes
.
List
?
'active'
:
''
}
>
<
i
className=
"fa fa-list"
/>
</
button
>
<
button
onClick=
{
()
=>
{
onLayoutModeChanged
(
'grid'
);
onLayoutModeChanged
(
LayoutModes
.
Grid
);
}
}
className=
{
mode
===
'grid'
?
'active'
:
''
}
className=
{
mode
===
LayoutModes
.
Grid
?
'active'
:
''
}
>
<
i
className=
"fa fa-th"
/>
</
button
>
</
div
>
);
}
};
export
default
LayoutSelector
;
public/app/features/plugins/PluginActionBar.test.tsx
View file @
1e2c0608
import
React
from
'react'
;
import
{
shallow
}
from
'enzyme'
;
import
{
PluginActionBar
,
Props
}
from
'./PluginActionBar'
;
import
{
LayoutModes
}
from
'../../core/components/LayoutSelector/LayoutSelector'
;
const
setup
=
(
propOverrides
?:
object
)
=>
{
const
props
:
Props
=
{
searchQuery
:
''
,
layoutMode
:
'grid'
,
layoutMode
:
LayoutModes
.
Grid
,
setLayoutMode
:
jest
.
fn
(),
setPluginsSearchQuery
:
jest
.
fn
(),
};
...
...
public/app/features/plugins/PluginActionBar.tsx
View file @
1e2c0608
import
React
,
{
PureComponent
}
from
'react'
;
import
{
connect
}
from
'react-redux'
;
import
LayoutSelector
from
'../../core/components/LayoutSelector/LayoutSelector'
;
import
LayoutSelector
,
{
LayoutMode
}
from
'../../core/components/LayoutSelector/LayoutSelector'
;
import
{
setLayoutMode
,
setPluginsSearchQuery
}
from
'./state/actions'
;
import
{
getPluginsSearchQuery
,
getLayoutMode
}
from
'./state/selectors'
;
export
interface
Props
{
searchQuery
:
string
;
layoutMode
:
string
;
layoutMode
:
LayoutMode
;
setLayoutMode
:
typeof
setLayoutMode
;
setPluginsSearchQuery
:
typeof
setPluginsSearchQuery
;
}
...
...
@@ -32,7 +32,7 @@ export class PluginActionBar extends PureComponent<Props> {
/>
<
i
className=
"gf-form-input-icon fa fa-search"
/>
</
label
>
<
LayoutSelector
mode=
{
layoutMode
}
onLayoutModeChanged=
{
mode
=>
setLayoutMode
(
mode
)
}
/>
<
LayoutSelector
mode=
{
layoutMode
}
onLayoutModeChanged=
{
(
mode
:
LayoutMode
)
=>
setLayoutMode
(
mode
)
}
/>
</
div
>
<
div
className=
"page-action-bar__spacer"
/>
<
a
...
...
public/app/features/plugins/PluginList.test.tsx
View file @
1e2c0608
...
...
@@ -2,12 +2,13 @@ import React from 'react';
import
{
shallow
}
from
'enzyme'
;
import
PluginList
from
'./PluginList'
;
import
{
getMockPlugins
}
from
'./__mocks__/pluginMocks'
;
import
{
LayoutModes
}
from
'../../core/components/LayoutSelector/LayoutSelector'
;
const
setup
=
(
propOverrides
?:
object
)
=>
{
const
props
=
Object
.
assign
(
{
plugins
:
getMockPlugins
(
5
),
layout
:
'grid'
,
layout
Mode
:
LayoutModes
.
Grid
,
},
propOverrides
);
...
...
public/app/features/plugins/PluginList.tsx
View file @
1e2c0608
import
React
from
'react'
;
import
React
,
{
SFC
}
from
'react'
;
import
classNames
from
'classnames/bind'
;
import
PluginListItem
from
'./PluginListItem'
;
import
{
Plugin
}
from
'app/types'
;
import
{
LayoutMode
,
LayoutModes
}
from
'../../core/components/LayoutSelector/LayoutSelector'
;
interface
Props
{
plugins
:
Plugin
[];
layoutMode
:
LayoutMode
;
}
const
PluginList
:
SFC
<
Props
>
=
props
=>
{
const
{
plugins
,
layoutMode
}
=
props
;
export
default
function
PluginList
({
plugins
,
layout
})
{
const
listStyle
=
classNames
({
'card-section'
:
true
,
'card-list-layout-grid'
:
layout
===
'grid'
,
'card-list-layout-list'
:
layout
===
'list'
,
'card-list-layout-grid'
:
layout
Mode
===
LayoutModes
.
Grid
,
'card-list-layout-list'
:
layout
Mode
===
LayoutModes
.
List
,
});
return
(
...
...
@@ -18,4 +27,6 @@ export default function PluginList({ plugins, layout }) {
</
ol
>
</
section
>
);
}
};
export
default
PluginList
;
public/app/features/plugins/PluginListItem.tsx
View file @
1e2c0608
import
React
from
'react'
;
import
React
,
{
SFC
}
from
'react'
;
import
{
Plugin
}
from
'app/types'
;
interface
Props
{
plugin
:
Plugin
;
}
const
PluginListItem
:
SFC
<
Props
>
=
props
=>
{
const
{
plugin
}
=
props
;
export
default
function
PluginListItem
({
plugin
})
{
return
(
<
li
className=
"card-item-wrapper"
>
<
a
className=
"card-item"
href=
{
`plugins/${plugin.id}/edit`
}
>
...
...
@@ -27,4 +34,6 @@ export default function PluginListItem({ plugin }) {
</
a
>
</
li
>
);
}
};
export
default
PluginListItem
;
public/app/features/plugins/PluginListPage.tsx
View file @
1e2c0608
...
...
@@ -8,11 +8,12 @@ import { NavModel, Plugin } from '../../types';
import
{
loadPlugins
}
from
'./state/actions'
;
import
{
getNavModel
}
from
'../../core/selectors/navModel'
;
import
{
getLayoutMode
,
getPlugins
}
from
'./state/selectors'
;
import
{
LayoutMode
}
from
'../../core/components/LayoutSelector/LayoutSelector'
;
export
interface
Props
{
navModel
:
NavModel
;
plugins
:
Plugin
[];
layoutMode
:
string
;
layoutMode
:
LayoutMode
;
loadPlugins
:
typeof
loadPlugins
;
}
...
...
@@ -33,7 +34,7 @@ export class PluginListPage extends PureComponent<Props> {
<
PageHeader
model=
{
navModel
}
/>
<
div
className=
"page-container page-body"
>
<
PluginActionBar
/>
{
plugins
&&
<
PluginList
plugins=
{
plugins
}
layout=
{
layoutMode
}
/>
}
{
plugins
&&
<
PluginList
plugins=
{
plugins
}
layout
Mode
=
{
layoutMode
}
/>
}
</
div
>
</
div
>
);
...
...
public/app/features/plugins/__snapshots__/PluginListPage.test.tsx.snap
View file @
1e2c0608
...
...
@@ -10,7 +10,7 @@ exports[`Render should render component 1`] = `
>
<Connect(PluginActionBar) />
<PluginList
layout="grid"
layout
Mode
="grid"
plugins={Array []}
/>
</div>
...
...
public/app/features/plugins/state/actions.ts
View file @
1e2c0608
import
{
Plugin
,
StoreState
}
from
'app/types'
;
import
{
ThunkAction
}
from
'redux-thunk'
;
import
{
getBackendSrv
}
from
'../../../core/services/backend_srv'
;
import
{
LayoutMode
}
from
'../../../core/components/LayoutSelector/LayoutSelector'
;
export
enum
ActionTypes
{
LoadPlugins
=
'LOAD_PLUGINS'
,
...
...
@@ -20,10 +21,10 @@ export interface SetPluginsSearchQueryAction {
export
interface
SetLayoutModeAction
{
type
:
ActionTypes
.
SetLayoutMode
;
payload
:
string
;
payload
:
LayoutMode
;
}
export
const
setLayoutMode
=
(
mode
:
string
):
SetLayoutModeAction
=>
({
export
const
setLayoutMode
=
(
mode
:
LayoutMode
):
SetLayoutModeAction
=>
({
type
:
ActionTypes
.
SetLayoutMode
,
payload
:
mode
,
});
...
...
public/app/features/plugins/state/reducers.ts
View file @
1e2c0608
import
{
Action
,
ActionTypes
}
from
'./actions'
;
import
{
Plugin
,
PluginsState
}
from
'app/types'
;
import
{
LayoutModes
}
from
'../../../core/components/LayoutSelector/LayoutSelector'
;
export
const
initialState
:
PluginsState
=
{
plugins
:
[]
as
Plugin
[],
searchQuery
:
''
,
layoutMode
:
'grid'
};
export
const
initialState
:
PluginsState
=
{
plugins
:
[]
as
Plugin
[],
searchQuery
:
''
,
layoutMode
:
LayoutModes
.
Grid
};
export
const
pluginsReducer
=
(
state
=
initialState
,
action
:
Action
):
PluginsState
=>
{
switch
(
action
.
type
)
{
...
...
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