Browse Source

fix: fill in ssh key title on setting of repo (#950)

* fix: fill in ssh key title on setting of repo

* fix: Don't overwrite ssh key title if exist.
Bo-Yi Wu 3 years ago
parent
commit
4c12e2a4b9
2 changed files with 6 additions and 6 deletions
  1. 4 4
      public/js/index.js
  2. 2 2
      templates/repo/settings/deploy_keys.tmpl

+ 4 - 4
public/js/index.js

@@ -1491,10 +1491,10 @@ $(function () {
1491 1491
 
1492 1492
     // Parse SSH Key
1493 1493
     $("#ssh-key-content").on('change paste keyup',function(){
1494
-        var value = $(this).val();
1495
-        var arrays = value.split(" ");
1496
-        if (arrays.length === 3 && arrays[2] !== "") {
1497
-            $("#ssh-key-title").val(arrays[2]);
1494
+        var arrays = $(this).val().split(" ");
1495
+        var $title = $("#ssh-key-title")
1496
+        if ($title.val() === "" && arrays.length === 3 && arrays[2] !== "") {
1497
+            $title.val(arrays[2]);
1498 1498
         }
1499 1499
     });
1500 1500
 });

+ 2 - 2
templates/repo/settings/deploy_keys.tmpl

@@ -57,11 +57,11 @@
57 57
 							</div>
58 58
 							<div class="field {{if .Err_Title}}error{{end}}">
59 59
 								<label for="title">{{.i18n.Tr "repo.settings.title"}}</label>
60
-								<input id="title" name="title" value="{{.title}}" autofocus required>
60
+								<input id="ssh-key-title" name="title" value="{{.title}}" autofocus required>
61 61
 							</div>
62 62
 							<div class="field {{if .Err_Content}}error{{end}}">
63 63
 								<label for="content">{{.i18n.Tr "repo.settings.deploy_key_content"}}</label>
64
-								<textarea id="content" name="content" required>{{.content}}</textarea>
64
+								<textarea id="ssh-key-content" name="content" required>{{.content}}</textarea>
65 65
 							</div>
66 66
 							<button class="ui green button">
67 67
 								{{.i18n.Tr "repo.settings.add_deploy_key"}}