Skip to content

Commit

Permalink
fix(plugins/plugin-client-common): Theme switching from StatusStripe …
Browse files Browse the repository at this point in the history
…widget should be quiet

part of kubernetes-sigs#7961
  • Loading branch information
starpit committed Sep 12, 2021
1 parent 5cf5062 commit be0b1fe
Showing 1 changed file with 9 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ import {
getPersistedThemeChoice,
i18n,
pexecInCurrentTab,
uiThemes,
Theme
uiThemes
} from '@kui-shell/core'

import { Loading } from '../../..'
import DropdownWidget, { Props as DropdownWidgetProps } from './DropdownWidget'

const strings = i18n('plugin-client-common')
Expand All @@ -35,7 +33,7 @@ type Props = Pick<DropdownWidgetProps, 'position'>

interface State {
currentTheme: string
themes: Theme[]
actions: DropdownWidgetProps['actions']
}

export default class Settings extends React.PureComponent<Props, State> {
Expand All @@ -44,7 +42,7 @@ export default class Settings extends React.PureComponent<Props, State> {

this.state = {
currentTheme: undefined,
themes: []
actions: []
}

this.recomputeThemeList()
Expand All @@ -64,46 +62,15 @@ export default class Settings extends React.PureComponent<Props, State> {

this.setState({
currentTheme,
themes: themes
actions: themes.map(_ => ({
label: _.name,
isSelected: _.name === currentTheme,
handler: () => pexecInCurrentTab(`theme set ${encodeComponent(_.name)}`, undefined, true)
}))
})
}

private header() {
if (!this.state.currentTheme) {
return <Loading />
} else {
return (
<React.Fragment>
<div>{strings('Current Theme')}</div>
<div>
<strong>{this.state.currentTheme}</strong>
</div>
<div className="sub-text even-smaller-text">{this.changeTheme()}</div>
</React.Fragment>
)
}
}

private body() {
if (!this.state.currentTheme) {
return <Loading />
} else {
return <React.Fragment />
}
}

/** @return UI for changing themes */
private changeTheme() {
return (
<a href="#" onClick={() => pexecInCurrentTab('themes')}>
{strings('Switch theme')}
</a>
)
}

public render() {
// aria-label="Settings"
// tabIndex={0}
if (!this.state || !this.state.currentTheme) {
return <React.Fragment />
}
Expand All @@ -113,11 +80,7 @@ export default class Settings extends React.PureComponent<Props, State> {
noPadding
id="kui--settings-widget"
title={strings('Switch theme')}
actions={this.state.themes.map(_ => ({
label: _.name,
isSelected: _.name === this.state.currentTheme,
handler: () => pexecInCurrentTab(`theme set ${encodeComponent(_.name)}`)
}))}
actions={this.state.actions}
/>
)
}
Expand Down

0 comments on commit be0b1fe

Please sign in to comment.