new.tmpl 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. {{template "base/head" .}}
  2. <div class="repository new release">
  3. {{template "repo/header" .}}
  4. <div class="ui container">
  5. <h2 class="ui dividing header">
  6. {{if .PageIsEditRelease}}
  7. {{.i18n.Tr "repo.release.edit_release"}}
  8. <div class="sub header">{{.i18n.Tr "repo.release.edit_subheader"}}</div>
  9. {{else}}
  10. {{.i18n.Tr "repo.release.new_release"}}
  11. <div class="sub header">{{.i18n.Tr "repo.release.new_subheader"}}</div>
  12. {{end}}
  13. </h2>
  14. {{template "base/alert" .}}
  15. <form class="ui form grid" action="{{.Link}}" method="post">
  16. {{.CSRFTokenHTML}}
  17. <div class="ui seven wide column target">
  18. <div class="inline field {{if .Err_TagName}}error{{end}}">
  19. {{if .PageIsEditRelease}}
  20. <b>{{.tag_name}}</b><span class="at">@</span><strong>{{.tag_target}}</strong>
  21. {{else}}
  22. <input id="tag-name" name="tag_name" value="{{.tag_name}}" placeholder="{{.i18n.Tr "repo.release.tag_name"}}" autofocus required>
  23. <span class="at">@</span>
  24. <div class="ui selection dropdown">
  25. <input type="hidden" name="tag_target" value="{{.tag_target}}"/>
  26. <i class="octicon octicon-git-branch"></i>
  27. <div class="text">
  28. {{.i18n.Tr "repo.release.target"}} :
  29. <strong id="repo-branch-current">{{.Repository.DefaultBranch}}</strong>
  30. </div>
  31. <i class="dropdown icon"></i>
  32. <div class="menu">
  33. {{range .Branches}}
  34. <div class="item" data-value="{{.}}">{{.}}</div>
  35. {{end}}
  36. </div>
  37. </div>
  38. <span class="help">{{.i18n.Tr "repo.release.tag_helper"}}</span>
  39. {{end}}
  40. </div>
  41. </div>
  42. <div class="eleven wide column">
  43. <div class="field {{if .Err_Title}}error{{end}}">
  44. <label>{{.i18n.Tr "repo.release.title"}}</label>
  45. <input name="title" placeholder="{{.i18n.Tr "repo.release.title"}}" value="{{.title}}" autofocus required>
  46. </div>
  47. <div class="field">
  48. <label>{{.i18n.Tr "repo.release.content"}}</label>
  49. <textarea name="content">{{.content}}</textarea>
  50. </div>
  51. <div class="field">
  52. {{if .attachments}}
  53. <table class="ui table">
  54. <tbody>
  55. {{range .attachments}}
  56. <tr>
  57. <td>
  58. <a target="_blank" rel="noopener noreferrer" href="{{AppSubURL}}/attachments/{{.UUID}}" rel="nofollow">{{.Name}}</a>
  59. <a class="ui text red right delete-attachment-button" href="#"><i class="octicon octicon-x" data-uuid="{{.UUID}}"></i></a>
  60. <input name="files" type="hidden" value="{{.UUID}}">
  61. </td>
  62. </tr>
  63. {{end}}
  64. </tbody>
  65. </table>
  66. {{end}}
  67. </div>
  68. {{if .IsAttachmentEnabled}}
  69. <div class="files"></div>
  70. <div class="ui basic button dropzone" id="dropzone" data-upload-url="{{AppSubURL}}/releases/attachments" data-accepts="{{.AttachmentAllowedTypes}}" data-max-file="{{.AttachmentMaxFiles}}" data-max-size="{{.AttachmentMaxSize}}" data-default-message="{{.i18n.Tr "dropzone.default_message"}}" data-invalid-input-type="{{.i18n.Tr "dropzone.invalid_input_type"}}" data-file-too-big="{{.i18n.Tr "dropzone.file_too_big"}}" data-remove-file="{{.i18n.Tr "dropzone.remove_file"}}"></div>
  71. {{end}}
  72. </div>
  73. <div class="ui container">
  74. <div class="prerelease field">
  75. <div class="ui checkbox">
  76. <input type="checkbox" name="prerelease" {{if .prerelease}}checked{{end}}>
  77. <label><strong>{{.i18n.Tr "repo.release.prerelease_desc"}}</strong></label>
  78. </div>
  79. </div>
  80. <span class="help">{{.i18n.Tr "repo.release.prerelease_helper"}}</span>
  81. <div class="ui divider"></div>
  82. <div class="field">
  83. {{if .PageIsEditRelease}}
  84. <button class="ui green button">
  85. {{if .IsDraft}}
  86. {{.i18n.Tr "repo.release.publish"}}
  87. {{else}}
  88. {{.i18n.Tr "repo.release.edit_release"}}
  89. {{end}}
  90. </button>
  91. <a class="ui red button delete-button" data-url="{{$.RepoLink}}/releases/delete" data-id="{{.ID}}">
  92. {{$.i18n.Tr "repo.release.delete_release"}}
  93. </a>
  94. {{else}}
  95. <button class="ui green button">
  96. {{.i18n.Tr "repo.release.publish"}}
  97. </button>
  98. {{end}}
  99. {{/* Release didn't save as draft at first time is not possible to be draft again because the Git tag had been created. */}}
  100. {{if or (not .PageIsEditRelease) .IsDraft}}
  101. <input class="ui grey button" type="submit" name="draft" value="{{.i18n.Tr "repo.release.save_draft"}}"/>
  102. {{end}}
  103. <a class="ui basic button" href="{{.RepoLink}}/releases">
  104. {{.i18n.Tr "repo.release.cancel"}}
  105. </a>
  106. </div>
  107. </div>
  108. </form>
  109. </div>
  110. </div>
  111. {{if .PageIsEditRelease}}
  112. <div class="ui small basic delete modal">
  113. <div class="ui icon header">
  114. <i class="trash icon"></i>
  115. {{.i18n.Tr "repo.release.deletion"}}
  116. </div>
  117. <div class="content">
  118. <p>{{.i18n.Tr "repo.release.deletion_desc"}}</p>
  119. </div>
  120. {{template "base/delete_modal_actions" .}}
  121. </div>
  122. {{end}}
  123. <script>
  124. // Delete attachment row
  125. $('.delete-attachment-button').click(function (e) {
  126. var $row = $(this).parentsUntil('tbody');
  127. var $tbody = $row.parentsUntil('table');
  128. $row.remove();
  129. // Remove the entire table if this was the last row
  130. if ($tbody.children().length == 0) {
  131. $tbody.parentsUntil('.field').remove();
  132. }
  133. e.preventDefault();
  134. })
  135. </script>
  136. {{template "base/footer" .}}