Skip to content

Commit a5ee7c2

Browse files
disable import button until file is uploaded, unmask invalid uploaded file error (#324)
* disable import button until file is uploaded * Update webroot/panel/modal/new_key.php Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * use badRequest instead of alert --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent cab0467 commit a5ee7c2

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

webroot/panel/account.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,13 @@
3232
$validKeys = array_filter($keys, "testValidSSHKey");
3333
$USER->setSSHKeys(array_merge($USER->getSSHKeys(), $validKeys));
3434
if (count($keys) != count($validKeys)) {
35-
UnityHTTPD::alert("invalid SSH key");
35+
UnityHTTPD::badRequest(
36+
"one more more invalid SSH keys were not added",
37+
data: [
38+
"keys_valid_added" => $validKeys,
39+
"keys_invalid_not_added" => array_diff($keys, $validKeys),
40+
],
41+
);
3642
}
3743
}
3844
break;

webroot/panel/modal/new_key.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737

3838
<div style="display: none;" id="key_import">
3939
<label for="keyfile">Select local file:</label>
40-
<input type="file" id="keyfile" name="keyfile">
41-
<input type="submit" value="Import Key">
40+
<input type="file" id="keyfile" name="keyfile" />
41+
<input type="submit" id="submit-keyfile" value="Import Key" disabled />
4242
</div>
4343

4444
<div style="display: none;" id="key_generate">
@@ -116,4 +116,7 @@ function generateKey(type) {
116116
});
117117
});
118118

119+
$("#keyfile").on("change", function() {
120+
$("#submit-keyfile")[0].disabled = !this.files.length;
121+
});
119122
</script>

0 commit comments

Comments
 (0)