@@ -22,11 +22,9 @@ import {
22
22
getPersistedThemeChoice ,
23
23
i18n ,
24
24
pexecInCurrentTab ,
25
- uiThemes ,
26
- Theme
25
+ uiThemes
27
26
} from '@kui-shell/core'
28
27
29
- import { Loading } from '../../..'
30
28
import DropdownWidget , { Props as DropdownWidgetProps } from './DropdownWidget'
31
29
32
30
const strings = i18n ( 'plugin-client-common' )
@@ -35,7 +33,7 @@ type Props = Pick<DropdownWidgetProps, 'position'>
35
33
36
34
interface State {
37
35
currentTheme : string
38
- themes : Theme [ ]
36
+ actions : DropdownWidgetProps [ 'actions' ]
39
37
}
40
38
41
39
export default class Settings extends React . PureComponent < Props , State > {
@@ -44,7 +42,7 @@ export default class Settings extends React.PureComponent<Props, State> {
44
42
45
43
this . state = {
46
44
currentTheme : undefined ,
47
- themes : [ ]
45
+ actions : [ ]
48
46
}
49
47
50
48
this . recomputeThemeList ( )
@@ -64,46 +62,15 @@ export default class Settings extends React.PureComponent<Props, State> {
64
62
65
63
this . setState ( {
66
64
currentTheme,
67
- themes : themes
65
+ actions : themes . map ( _ => ( {
66
+ label : _ . name ,
67
+ isSelected : _ . name === currentTheme ,
68
+ handler : ( ) => pexecInCurrentTab ( `theme set ${ encodeComponent ( _ . name ) } ` , undefined , true )
69
+ } ) )
68
70
} )
69
71
}
70
72
71
- private header ( ) {
72
- if ( ! this . state . currentTheme ) {
73
- return < Loading />
74
- } else {
75
- return (
76
- < React . Fragment >
77
- < div > { strings ( 'Current Theme' ) } </ div >
78
- < div >
79
- < strong > { this . state . currentTheme } </ strong >
80
- </ div >
81
- < div className = "sub-text even-smaller-text" > { this . changeTheme ( ) } </ div >
82
- </ React . Fragment >
83
- )
84
- }
85
- }
86
-
87
- private body ( ) {
88
- if ( ! this . state . currentTheme ) {
89
- return < Loading />
90
- } else {
91
- return < React . Fragment />
92
- }
93
- }
94
-
95
- /** @return UI for changing themes */
96
- private changeTheme ( ) {
97
- return (
98
- < a href = "#" onClick = { ( ) => pexecInCurrentTab ( 'themes' ) } >
99
- { strings ( 'Switch theme' ) }
100
- </ a >
101
- )
102
- }
103
-
104
73
public render ( ) {
105
- // aria-label="Settings"
106
- // tabIndex={0}
107
74
if ( ! this . state || ! this . state . currentTheme ) {
108
75
return < React . Fragment />
109
76
}
@@ -113,11 +80,7 @@ export default class Settings extends React.PureComponent<Props, State> {
113
80
noPadding
114
81
id = "kui--settings-widget"
115
82
title = { strings ( 'Switch theme' ) }
116
- actions = { this . state . themes . map ( _ => ( {
117
- label : _ . name ,
118
- isSelected : _ . name === this . state . currentTheme ,
119
- handler : ( ) => pexecInCurrentTab ( `theme set ${ encodeComponent ( _ . name ) } ` )
120
- } ) ) }
83
+ actions = { this . state . actions }
121
84
/>
122
85
)
123
86
}
0 commit comments