mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-04-18 20:47:17 +02:00
bind cmd-w to delete a screen (with a confirm message). also fix 'esc' so it closes the alert modal with a 'cancel' (#215)
This commit is contained in:
parent
8ac1943d56
commit
fad48b0d09
@ -235,10 +235,10 @@ class AlertModal extends React.Component<{}, {}> {
|
||||
<Button theme="secondary" onClick={this.closeModal}>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button onClick={this.handleOK}>Ok</Button>
|
||||
<Button autoFocus={true} onClick={this.handleOK}>Ok</Button>
|
||||
</If>
|
||||
<If condition={!isConfirm}>
|
||||
<Button onClick={this.handleOK}>Ok</Button>
|
||||
<Button autoFocus={true} onClick={this.handleOK}>Ok</Button>
|
||||
</If>
|
||||
</div>
|
||||
</Modal>
|
||||
|
@ -228,7 +228,7 @@ class ScreenSettingsModal extends React.Component<{}, {}> {
|
||||
return;
|
||||
}
|
||||
if (this.screen.getScreenLines().lines.length == 0) {
|
||||
GlobalCommandRunner.screenDelete(this.screenId);
|
||||
GlobalCommandRunner.screenDelete(this.screenId, false);
|
||||
GlobalModel.modalsModel.popModal();
|
||||
return;
|
||||
}
|
||||
@ -238,7 +238,7 @@ class ScreenSettingsModal extends React.Component<{}, {}> {
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
let prtn = GlobalCommandRunner.screenDelete(this.screenId);
|
||||
let prtn = GlobalCommandRunner.screenDelete(this.screenId, false);
|
||||
commandRtnHandler(prtn, this.errorMessage);
|
||||
GlobalModel.modalsModel.popModal();
|
||||
});
|
||||
|
@ -200,6 +200,7 @@ type ElectronApi = {
|
||||
onLCmd: (callback: (mods: KeyModsType) => void) => void;
|
||||
onHCmd: (callback: (mods: KeyModsType) => void) => void;
|
||||
onPCmd: (callback: (mods: KeyModsType) => void) => void;
|
||||
onWCmd: (callback: (mods: KeyModsType) => void) => void;
|
||||
onMenuItemAbout: (callback: () => void) => void;
|
||||
onMetaArrowUp: (callback: () => void) => void;
|
||||
onMetaArrowDown: (callback: () => void) => void;
|
||||
@ -3216,6 +3217,7 @@ class Model {
|
||||
getApi().onLCmd(this.onLCmd.bind(this));
|
||||
getApi().onHCmd(this.onHCmd.bind(this));
|
||||
getApi().onPCmd(this.onPCmd.bind(this));
|
||||
getApi().onWCmd(this.onWCmd.bind(this));
|
||||
getApi().onMenuItemAbout(this.onMenuItemAbout.bind(this));
|
||||
getApi().onMetaArrowUp(this.onMetaArrowUp.bind(this));
|
||||
getApi().onMetaArrowDown(this.onMetaArrowDown.bind(this));
|
||||
@ -3460,6 +3462,23 @@ class Model {
|
||||
return true;
|
||||
}
|
||||
|
||||
onWCmd(e: any, mods: KeyModsType) {
|
||||
let activeScreen = this.getActiveScreen();
|
||||
if (activeScreen == null) {
|
||||
return;
|
||||
}
|
||||
let rtnp = this.showAlert({
|
||||
message: "Are you sure you want to delete this screen?",
|
||||
confirm: true,
|
||||
});
|
||||
rtnp.then((result) => {
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
GlobalCommandRunner.screenDelete(activeScreen.screenId, true);
|
||||
});
|
||||
}
|
||||
|
||||
clearModals(): boolean {
|
||||
let didSomething = false;
|
||||
mobx.action(() => {
|
||||
@ -4395,8 +4414,8 @@ class CommandRunner {
|
||||
);
|
||||
}
|
||||
|
||||
screenDelete(screenId: string): Promise<CommandRtnType> {
|
||||
return GlobalModel.submitCommand("screen", "delete", [screenId], { nohist: "1" }, false);
|
||||
screenDelete(screenId: string, interactive: boolean): Promise<CommandRtnType> {
|
||||
return GlobalModel.submitCommand("screen", "delete", [screenId], { nohist: "1" }, interactive);
|
||||
}
|
||||
|
||||
screenWebShare(screenId: string, shouldShare: boolean): Promise<CommandRtnType> {
|
||||
|
Loading…
Reference in New Issue
Block a user