Close Preferences and Cluster Setting on Esc keypress (#804)

* Close Preferences on Esc key

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Close Cluster Settings on Esc

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev authored and GitHub committed 2020-09-04 11:27:08 +03:00
1 parent 7274658b51
commit 435baaea00
2 files changed
+37 -4

No files matched your search

@@ -28,6 +28,8 @@ export class Preferences extends React.Component {
{ value: "china", label: "China (Azure)" },
]
@observable httpProxy = userStore.preferences.httpsProxy || "";
@computed get themeOptions(): SelectOption<string>[] {
return themeStore.themes.map(theme => ({
label: theme.name,
@@ -43,9 +45,21 @@ export class Preferences extends React.Component {
}
async componentDidMount() {
window.addEventListener('keydown', this.onEscapeKey);
await this.loadHelmRepos();
}
componentWillUnmount() {
window.removeEventListener('keydown', this.onEscapeKey);
}
onEscapeKey = (evt: KeyboardEvent) => {
if (evt.code === "Escape") {
evt.stopPropagation();
history.goBack();
}
}
@action
async loadHelmRepos() {
this.helmLoading = true;
@@ -162,8 +176,9 @@ export class Preferences extends React.Component {
<Input
theme="round-black"
placeholder={_i18n._(t`Type HTTP proxy url (example: http://proxy.acme.org:8080)`)}
value={preferences.httpsProxy || ""}
onChange={v => preferences.httpsProxy = v}
value={this.httpProxy}
onChange={v => this.httpProxy = v}
onBlur={() => preferences.httpsProxy = this.httpProxy}
/>
<small className="hint">
<Trans>Proxy is used only for non-cluster communication.</Trans>