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
78a6d39e
Unverified
Commit
78a6d39e
authored
Apr 22, 2020
by
Tobias Skarhed
Committed by
GitHub
Apr 22, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Forms migration: LayoutSelector (#23790)
parent
83608baf
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
17 additions
and
106 deletions
+17
-106
packages/grafana-ui/src/components/Forms/RadioButtonGroup/RadioButtonGroup.tsx
+4
-2
public/app/core/components/LayoutSelector/LayoutSelector.tsx
+9
-22
public/app/core/components/OrgActionBar/OrgActionBar.tsx
+2
-3
public/app/core/components/OrgActionBar/__snapshots__/OrgActionBar.test.tsx.snap
+2
-3
public/app/core/components/layout_selector/layout_selector.ts
+0
-74
public/app/core/core.ts
+0
-2
No files found.
packages/grafana-ui/src/components/Forms/RadioButtonGroup/RadioButtonGroup.tsx
View file @
78a6d39e
...
@@ -3,6 +3,7 @@ import { css } from 'emotion';
...
@@ -3,6 +3,7 @@ import { css } from 'emotion';
import
uniqueId
from
'lodash/uniqueId'
;
import
uniqueId
from
'lodash/uniqueId'
;
import
{
SelectableValue
}
from
'@grafana/data'
;
import
{
SelectableValue
}
from
'@grafana/data'
;
import
{
RadioButtonSize
,
RadioButton
}
from
'./RadioButton'
;
import
{
RadioButtonSize
,
RadioButton
}
from
'./RadioButton'
;
import
{
Icon
}
from
'../../Icon/Icon'
;
const
getRadioButtonGroupStyles
=
()
=>
{
const
getRadioButtonGroupStyles
=
()
=>
{
return
{
return
{
...
@@ -67,19 +68,20 @@ export function RadioButtonGroup<T>({
...
@@ -67,19 +68,20 @@ export function RadioButtonGroup<T>({
return
(
return
(
<
div
className=
{
styles
.
radioGroup
}
>
<
div
className=
{
styles
.
radioGroup
}
>
{
options
.
map
(
o
=>
{
{
options
.
map
(
(
o
,
i
)
=>
{
const
isItemDisabled
=
disabledOptions
&&
o
.
value
&&
disabledOptions
.
includes
(
o
.
value
);
const
isItemDisabled
=
disabledOptions
&&
o
.
value
&&
disabledOptions
.
includes
(
o
.
value
);
return
(
return
(
<
RadioButton
<
RadioButton
size=
{
size
}
size=
{
size
}
disabled=
{
isItemDisabled
||
disabled
}
disabled=
{
isItemDisabled
||
disabled
}
active=
{
value
===
o
.
value
}
active=
{
value
===
o
.
value
}
key=
{
o
.
label
}
key=
{
`o.label-${i}`
}
onChange=
{
handleOnChange
(
o
)
}
onChange=
{
handleOnChange
(
o
)
}
id=
{
`option-${o.value}-${id}`
}
id=
{
`option-${o.value}-${id}`
}
name=
{
groupName
.
current
}
name=
{
groupName
.
current
}
fullWidth=
{
fullWidth
}
fullWidth=
{
fullWidth
}
>
>
{
o
.
icon
&&
<
Icon
name=
{
o
.
icon
}
/>
}
{
o
.
label
}
{
o
.
label
}
</
RadioButton
>
</
RadioButton
>
);
);
...
...
public/app/core/components/LayoutSelector/LayoutSelector.tsx
View file @
78a6d39e
import
React
,
{
FC
}
from
'react'
;
import
React
,
{
FC
}
from
'react'
;
import
{
Icon
}
from
'@grafana/ui'
;
import
{
RadioButtonGroup
}
from
'@grafana/ui'
;
export
type
LayoutMode
=
LayoutModes
.
Grid
|
LayoutModes
.
List
;
export
type
LayoutMode
=
LayoutModes
.
Grid
|
LayoutModes
.
List
;
...
@@ -13,28 +13,15 @@ interface Props {
...
@@ -13,28 +13,15 @@ interface Props {
onLayoutModeChanged
:
(
mode
:
LayoutMode
)
=>
{};
onLayoutModeChanged
:
(
mode
:
LayoutMode
)
=>
{};
}
}
const
LayoutSelector
:
FC
<
Props
>
=
props
=>
{
const
options
=
[
const
{
mode
,
onLayoutModeChanged
}
=
props
;
{
icon
:
'table'
,
value
:
LayoutModes
.
Grid
},
return
(
{
icon
:
'list-ul'
,
value
:
LayoutModes
.
List
},
];
const
LayoutSelector
:
FC
<
Props
>
=
({
mode
,
onLayoutModeChanged
})
=>
(
<
div
className=
"layout-selector"
>
<
div
className=
"layout-selector"
>
<
button
<
RadioButtonGroup
value=
{
mode
}
options=
{
options
}
onChange=
{
onLayoutModeChanged
}
/>
onClick=
{
()
=>
{
onLayoutModeChanged
(
LayoutModes
.
List
);
}
}
className=
{
mode
===
LayoutModes
.
List
?
'active'
:
''
}
>
<
Icon
name=
"list-ul"
/>
</
button
>
<
button
onClick=
{
()
=>
{
onLayoutModeChanged
(
LayoutModes
.
Grid
);
}
}
className=
{
mode
===
LayoutModes
.
Grid
?
'active'
:
''
}
>
<
Icon
name=
"table"
/>
</
button
>
</
div
>
</
div
>
);
);
};
export
default
LayoutSelector
;
export
default
LayoutSelector
;
public/app/core/components/OrgActionBar/OrgActionBar.tsx
View file @
78a6d39e
import
React
,
{
PureComponent
}
from
'react'
;
import
React
,
{
PureComponent
}
from
'react'
;
import
LayoutSelector
,
{
LayoutMode
}
from
'../LayoutSelector/LayoutSelector'
;
import
LayoutSelector
,
{
LayoutMode
}
from
'../LayoutSelector/LayoutSelector'
;
import
{
FilterInput
}
from
'../FilterInput/FilterInput'
;
import
{
FilterInput
}
from
'../FilterInput/FilterInput'
;
import
{
LinkButton
}
from
'@grafana/ui'
;
export
interface
Props
{
export
interface
Props
{
searchQuery
:
string
;
searchQuery
:
string
;
...
@@ -33,9 +34,7 @@ export default class OrgActionBar extends PureComponent<Props> {
...
@@ -33,9 +34,7 @@ export default class OrgActionBar extends PureComponent<Props> {
<
LayoutSelector
mode=
{
layoutMode
}
onLayoutModeChanged=
{
(
mode
:
LayoutMode
)
=>
onSetLayoutMode
(
mode
)
}
/>
<
LayoutSelector
mode=
{
layoutMode
}
onLayoutModeChanged=
{
(
mode
:
LayoutMode
)
=>
onSetLayoutMode
(
mode
)
}
/>
</
div
>
</
div
>
<
div
className=
"page-action-bar__spacer"
/>
<
div
className=
"page-action-bar__spacer"
/>
<
a
className=
"btn btn-primary"
{
...
linkProps
}
>
<
LinkButton
{
...
linkProps
}
>
{
linkButton
.
title
}
</
LinkButton
>
{
linkButton
.
title
}
</
a
>
</
div
>
</
div
>
);
);
}
}
...
...
public/app/core/components/OrgActionBar/__snapshots__/OrgActionBar.test.tsx.snap
View file @
78a6d39e
...
@@ -21,12 +21,11 @@ exports[`Render should render component 1`] = `
...
@@ -21,12 +21,11 @@ exports[`Render should render component 1`] = `
<div
<div
className="page-action-bar__spacer"
className="page-action-bar__spacer"
/>
/>
<a
<LinkButton
className="btn btn-primary"
href="some/url"
href="some/url"
target="_blank"
target="_blank"
>
>
test
test
</
a
>
</
LinkButton
>
</div>
</div>
`;
`;
public/app/core/components/layout_selector/layout_selector.ts
deleted
100644 → 0
View file @
83608baf
import
store
from
'app/core/store'
;
import
coreModule
from
'app/core/core_module'
;
import
{
GrafanaRootScope
}
from
'app/routes/GrafanaCtrl'
;
import
{
CoreEvents
}
from
'app/types'
;
const
template
=
`
<div class="layout-selector">
<button ng-click="ctrl.listView()" ng-class="{active: ctrl.mode === 'list'}">
<i class="fa fa-list"></i>
</button>
<button ng-click="ctrl.gridView()" ng-class="{active: ctrl.mode === 'grid'}">
<icon name="table"></i>
</button>
</div>
`
;
export
class
LayoutSelectorCtrl
{
mode
:
string
;
/** @ngInject */
constructor
(
private
$rootScope
:
GrafanaRootScope
)
{
this
.
mode
=
store
.
get
(
'grafana.list.layout.mode'
)
||
'grid'
;
}
listView
()
{
this
.
mode
=
'list'
;
store
.
set
(
'grafana.list.layout.mode'
,
'list'
);
this
.
$rootScope
.
appEvent
(
CoreEvents
.
layoutModeChanged
,
'list'
);
}
gridView
()
{
this
.
mode
=
'grid'
;
store
.
set
(
'grafana.list.layout.mode'
,
'grid'
);
this
.
$rootScope
.
appEvent
(
CoreEvents
.
layoutModeChanged
,
'grid'
);
}
}
/** @ngInject */
export
function
layoutSelector
()
{
return
{
restrict
:
'E'
,
controller
:
LayoutSelectorCtrl
,
bindToController
:
true
,
controllerAs
:
'ctrl'
,
scope
:
{},
template
:
template
,
};
}
/** @ngInject */
export
function
layoutMode
(
$rootScope
:
GrafanaRootScope
)
{
return
{
restrict
:
'A'
,
scope
:
{},
link
:
(
scope
:
any
,
elem
:
any
)
=>
{
const
layout
=
store
.
get
(
'grafana.list.layout.mode'
)
||
'grid'
;
let
className
=
'card-list-layout-'
+
layout
;
elem
.
addClass
(
className
);
$rootScope
.
onAppEvent
(
CoreEvents
.
layoutModeChanged
,
(
evt
:
any
,
newLayout
:
any
)
=>
{
elem
.
removeClass
(
className
);
className
=
'card-list-layout-'
+
newLayout
;
elem
.
addClass
(
className
);
},
scope
);
},
};
}
coreModule
.
directive
(
'layoutSelector'
,
layoutSelector
);
coreModule
.
directive
(
'layoutMode'
,
layoutMode
);
public/app/core/core.ts
View file @
78a6d39e
...
@@ -23,7 +23,6 @@ import { infoPopover } from './components/info_popover';
...
@@ -23,7 +23,6 @@ import { infoPopover } from './components/info_popover';
import
{
arrayJoin
}
from
'./directives/array_join'
;
import
{
arrayJoin
}
from
'./directives/array_join'
;
import
{
liveSrv
}
from
'./live/live_srv'
;
import
{
liveSrv
}
from
'./live/live_srv'
;
import
{
Emitter
}
from
'./utils/emitter'
;
import
{
Emitter
}
from
'./utils/emitter'
;
import
{
layoutSelector
}
from
'./components/layout_selector/layout_selector'
;
import
{
switchDirective
}
from
'./components/switch'
;
import
{
switchDirective
}
from
'./components/switch'
;
import
{
dashboardSelector
}
from
'./components/dashboard_selector'
;
import
{
dashboardSelector
}
from
'./components/dashboard_selector'
;
import
{
queryPartEditorDirective
}
from
'./components/query_part/query_part_editor'
;
import
{
queryPartEditorDirective
}
from
'./components/query_part/query_part_editor'
;
...
@@ -54,7 +53,6 @@ export {
...
@@ -54,7 +53,6 @@ export {
coreModule
,
coreModule
,
searchDirective
,
searchDirective
,
liveSrv
,
liveSrv
,
layoutSelector
,
switchDirective
,
switchDirective
,
infoPopover
,
infoPopover
,
Emitter
,
Emitter
,
...
...
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