mirror of
https://github.com/45Drives/cockpit-navigator.git
synced 2025-07-29 00:24:52 +02:00
improve pasting
This commit is contained in:
parent
78b9d7bf4a
commit
765fdff846
@ -676,6 +676,25 @@ export class NavWindow {
|
|||||||
keepers.push(response)
|
keepers.push(response)
|
||||||
}
|
}
|
||||||
proc.input(JSON.stringify(keepers) + "\n", true);
|
proc.input(JSON.stringify(keepers) + "\n", true);
|
||||||
|
} else if (payload.hasOwnProperty("choices")) {
|
||||||
|
let choices = {};
|
||||||
|
for (let choice of payload["choices"]) {
|
||||||
|
choices[choice[0]] = {
|
||||||
|
label: choice[1],
|
||||||
|
internal_name: choice[0],
|
||||||
|
type: "radio",
|
||||||
|
default: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
choices[payload["choices"][0][0]].default = true;
|
||||||
|
this.stop_load();
|
||||||
|
let response = await this.modal_prompt.prompt(payload["message"], choices);
|
||||||
|
this.start_load();
|
||||||
|
if (response === null) {
|
||||||
|
proc.input(JSON.stringify("abort") + "\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
proc.input(JSON.stringify(response) + "\n", true);
|
||||||
} else {
|
} else {
|
||||||
var user_response = await this.modal_prompt.confirm(payload["message"]);
|
var user_response = await this.modal_prompt.confirm(payload["message"]);
|
||||||
proc.input(JSON.stringify(user_response) + "\n", true);
|
proc.input(JSON.stringify(user_response) + "\n", true);
|
||||||
|
@ -28,13 +28,15 @@ from optparse import OptionParser
|
|||||||
import json
|
import json
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
def prompt_user(message, wants_response, conflicts = None):
|
def prompt_user(message, wants_response, conflicts = None, choices = None):
|
||||||
payload = {
|
payload = {
|
||||||
"wants-response": wants_response,
|
"wants-response": wants_response,
|
||||||
"message": message
|
"message": message
|
||||||
}
|
}
|
||||||
if conflicts != None:
|
if conflicts != None:
|
||||||
payload["conflicts"] = conflicts
|
payload["conflicts"] = conflicts
|
||||||
|
if choices != None:
|
||||||
|
payload["choices"] = choices
|
||||||
print(json.dumps(payload) + "\n")
|
print(json.dumps(payload) + "\n")
|
||||||
if wants_response:
|
if wants_response:
|
||||||
response = json.loads(input())
|
response = json.loads(input())
|
||||||
@ -74,8 +76,16 @@ def filter_existing(args, cwd):
|
|||||||
dest = args[-1]
|
dest = args[-1]
|
||||||
(conflicts, non_conflicts) = recursive_get_conflicts(sources, cwd, dest)
|
(conflicts, non_conflicts) = recursive_get_conflicts(sources, cwd, dest)
|
||||||
if len(conflicts):
|
if len(conflicts):
|
||||||
|
choice = prompt_user("Conflicts Found", True, choices=[("skip-conflicts", "Skip Conflicts"), ("select", "Overwrite Selectively"), ("overwrite", "Overwrite All")])
|
||||||
|
if choice == "overwrite":
|
||||||
|
non_conflicts.extend(map(lambda x: x[0], conflicts))
|
||||||
|
elif choice == "select":
|
||||||
conflicts = prompt_user("Overwrite?", True, conflicts)
|
conflicts = prompt_user("Overwrite?", True, conflicts)
|
||||||
non_conflicts.extend(conflicts)
|
non_conflicts.extend(conflicts)
|
||||||
|
elif choice == "skip-conflicts":
|
||||||
|
pass
|
||||||
|
else: # cancelled
|
||||||
|
sys.exit(0)
|
||||||
if not len(non_conflicts):
|
if not len(non_conflicts):
|
||||||
sys.exit(0) # exit if nothing to copy
|
sys.exit(0) # exit if nothing to copy
|
||||||
filtered_args = [*split_paths_at_cwd(non_conflicts, cwd), dest]
|
filtered_args = [*split_paths_at_cwd(non_conflicts, cwd), dest]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user