mirror of
https://github.com/wavetermdev/waveterm.git
synced 2024-12-21 16:38:23 +01:00
close modals on ECS
This commit is contained in:
parent
f850e3b728
commit
4c33d24a7b
@ -44,7 +44,7 @@ class AlertModal extends React.Component<{}, {}> {
|
|||||||
<Markdown text={message?.message ?? ""} extraClassName="bottom-margin" />
|
<Markdown text={message?.message ?? ""} extraClassName="bottom-margin" />
|
||||||
</If>
|
</If>
|
||||||
<If condition={!message?.markdown}>{message?.message}</If>
|
<If condition={!message?.markdown}>{message?.message}</If>
|
||||||
<If condition={message.confirmflag}>
|
<If condition={message?.confirmflag}>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
onChange={this.handleDontShowAgain}
|
onChange={this.handleDontShowAgain}
|
||||||
label={"Don't show me this again"}
|
label={"Don't show me this again"}
|
||||||
|
@ -206,7 +206,7 @@ class BookmarksModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleDocKeyDown(e: any): void {
|
handleDocKeyDown(e: any): void {
|
||||||
let waveEvent = adaptFromReactOrNativeKeyEvent(e);
|
const waveEvent = adaptFromReactOrNativeKeyEvent(e);
|
||||||
if (checkKeyPressed(waveEvent, "Escape")) {
|
if (checkKeyPressed(waveEvent, "Escape")) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (this.editingBookmark.get() != null) {
|
if (this.editingBookmark.get() != null) {
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
import * as mobx from "mobx";
|
import * as mobx from "mobx";
|
||||||
import { Model } from "./model";
|
import { Model } from "./model";
|
||||||
|
import { checkKeyPressed, adaptFromReactOrNativeKeyEvent } from "@/util/keyutil";
|
||||||
|
|
||||||
class ClientSettingsViewModel {
|
class ClientSettingsViewModel {
|
||||||
globalModel: Model;
|
globalModel: Model;
|
||||||
@ -21,6 +22,15 @@ class ClientSettingsViewModel {
|
|||||||
this.globalModel.activeMainView.set("clientsettings");
|
this.globalModel.activeMainView.set("clientsettings");
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleDocKeyDown(e: any): void {
|
||||||
|
const waveEvent = adaptFromReactOrNativeKeyEvent(e);
|
||||||
|
if (checkKeyPressed(waveEvent, "Escape")) {
|
||||||
|
e.preventDefault();
|
||||||
|
this.closeView();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { ClientSettingsViewModel };
|
export { ClientSettingsViewModel };
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
import * as mobx from "mobx";
|
import * as mobx from "mobx";
|
||||||
import { Model } from "./model";
|
import { Model } from "./model";
|
||||||
|
import { checkKeyPressed, adaptFromReactOrNativeKeyEvent } from "@/util/keyutil";
|
||||||
|
|
||||||
class ConnectionsViewModel {
|
class ConnectionsViewModel {
|
||||||
globalModel: Model;
|
globalModel: Model;
|
||||||
@ -21,6 +22,15 @@ class ConnectionsViewModel {
|
|||||||
this.globalModel.activeMainView.set("connections");
|
this.globalModel.activeMainView.set("connections");
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleDocKeyDown(e: any): void {
|
||||||
|
const waveEvent = adaptFromReactOrNativeKeyEvent(e);
|
||||||
|
if (checkKeyPressed(waveEvent, "Escape")) {
|
||||||
|
e.preventDefault();
|
||||||
|
this.closeView();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { ConnectionsViewModel };
|
export { ConnectionsViewModel };
|
||||||
|
@ -291,7 +291,7 @@ class HistoryViewModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleDocKeyDown(e: any): void {
|
handleDocKeyDown(e: any): void {
|
||||||
let waveEvent = adaptFromReactOrNativeKeyEvent(e);
|
const waveEvent = adaptFromReactOrNativeKeyEvent(e);
|
||||||
if (checkKeyPressed(waveEvent, "Escape")) {
|
if (checkKeyPressed(waveEvent, "Escape")) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
this.closeView();
|
this.closeView();
|
||||||
|
@ -18,10 +18,11 @@ class ModalsModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
popModal() {
|
popModal(callback?: () => void) {
|
||||||
mobx.action(() => {
|
mobx.action(() => {
|
||||||
this.store.pop();
|
this.store.pop();
|
||||||
})();
|
})();
|
||||||
|
callback && callback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -457,7 +457,7 @@ class Model {
|
|||||||
if (this.alertMessage.get() != null) {
|
if (this.alertMessage.get() != null) {
|
||||||
if (checkKeyPressed(waveEvent, "Escape")) {
|
if (checkKeyPressed(waveEvent, "Escape")) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
this.cancelAlert();
|
this.modalsModel.popModal(() => this.cancelAlert());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (checkKeyPressed(waveEvent, "Enter")) {
|
if (checkKeyPressed(waveEvent, "Enter")) {
|
||||||
@ -467,6 +467,10 @@ class Model {
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (checkKeyPressed(waveEvent, "Escape") && this.modalsModel.store.length > 0) {
|
||||||
|
this.modalsModel.popModal();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (this.activeMainView.get() == "bookmarks") {
|
if (this.activeMainView.get() == "bookmarks") {
|
||||||
this.bookmarksModel.handleDocKeyDown(e);
|
this.bookmarksModel.handleDocKeyDown(e);
|
||||||
return;
|
return;
|
||||||
@ -476,14 +480,13 @@ class Model {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.activeMainView.get() == "connections") {
|
if (this.activeMainView.get() == "connections") {
|
||||||
this.historyViewModel.handleDocKeyDown(e);
|
this.connectionViewModel.handleDocKeyDown(e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.activeMainView.get() == "clientsettings") {
|
if (this.activeMainView.get() == "clientsettings") {
|
||||||
this.historyViewModel.handleDocKeyDown(e);
|
this.clientSettingsViewModel.handleDocKeyDown(e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (checkKeyPressed(waveEvent, "Escape")) {
|
if (checkKeyPressed(waveEvent, "Escape")) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (this.activeMainView.get() == "webshare") {
|
if (this.activeMainView.get() == "webshare") {
|
||||||
|
Loading…
Reference in New Issue
Block a user