Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 1 | [define category_css]css/ph_detail.css[end] |
| 2 | [include "../framework/header.ezt" "showtabs"] |
| 3 | |
| 4 | [if-any read_only][include "../framework/read-only-rejection.ezt"] |
| 5 | [else] |
| 6 | |
| 7 | <form action="adminComponents.do" id="adminComponents" method="POST"> |
Adrià Vilanova Martínez | f19ea43 | 2024-01-23 20:20:52 +0100 | [diff] [blame] | 8 | <input type="hidden" name="token" value="[form_token]"> |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 9 | |
| 10 | <h4>Issue components</h4> |
Adrià Vilanova Martínez | f19ea43 | 2024-01-23 20:20:52 +0100 | [diff] [blame] | 11 | [if-any can_edit_project] |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 12 | <span style="margin:0 .7em">Show: |
| 13 | <select id="rowfilter"> |
| 14 | <option label="All components" value="all"> |
| 15 | <option label="Active components" value="active" selected=true> |
| 16 | <option label="Top-level components" value="toplevel"> |
| 17 | <option label="Components I administer" value="myadmin"> |
| 18 | <option label="Components I am CC'd on" value="mycc"> |
| 19 | <option label="Deprecated components" value="deprecated"> |
| 20 | </select> |
| 21 | </span> |
| 22 | <span style="margin:0 .7em">Select: |
| 23 | <a id="selectall" href="#">All</a> |
| 24 | <a id="selectnone" href="#">None</a> |
| 25 | </span> |
| 26 | [end] |
| 27 | |
| 28 | <div class="list-foot"></div> |
Adrià Vilanova Martínez | f19ea43 | 2024-01-23 20:20:52 +0100 | [diff] [blame] | 29 | [if-any can_edit_project] |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 30 | <form action="adminComponents.do" method="POST"> |
| 31 | <a href="/p/[projectname]/components/create" class="buttonify primary">Create component</a> |
| 32 | <input type="hidden" name="delete_components"> |
| 33 | <input type="hidden" name="token" value="[form_token]"> |
| 34 | <input type="submit" class="secondary" name="deletebtn" value="Delete Component(s)" disabled> |
| 35 | </form> |
| 36 | <div id="deletebtnsfeedback" class="fielderror" style="margin-left:1em"> |
| 37 | [if-any failed_perm] |
| 38 | You do not have permission to delete the components: |
| 39 | [failed_perm]<br/> |
| 40 | [end] |
| 41 | [if-any failed_subcomp] |
| 42 | Can not delete the following components because they have subcomponents: |
| 43 | [failed_subcomp]<br/> |
| 44 | [end] |
| 45 | [if-any failed_templ] |
| 46 | Can not delete the following components because they are listed in templates: |
| 47 | [failed_templ]<br/> |
| 48 | [end] |
| 49 | </div> |
| 50 | [end] |
| 51 | |
| 52 | <div class="section"> |
| 53 | <table cellspacing="0" cellpadding="2" border="0" class="comptable results striped vt active" id="resultstable" width="100%"> |
| 54 | <tbody> |
| 55 | <tr> |
Adrià Vilanova Martínez | f19ea43 | 2024-01-23 20:20:52 +0100 | [diff] [blame] | 56 | [if-any can_edit_project]<th></th>[end] |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 57 | <th>ID</th> |
| 58 | <th>Name</th> |
| 59 | <th>Administrators</th> |
| 60 | <th>Auto Cc</th> |
| 61 | <th>Add Labels</th> |
| 62 | <th>Description</th> |
| 63 | </tr> |
| 64 | [if-any component_defs][else] |
| 65 | <tr> |
| 66 | <td colspan="5"> |
| 67 | <div style="padding: 3em; text-align: center"> |
| 68 | This project has not defined any components. |
| 69 | </div> |
| 70 | </td> |
| 71 | </tr> |
| 72 | [end] |
| 73 | [for component_defs] |
| 74 | [define detail_url]/p/[projectname]/components/detail?component=[format "url"][component_defs.path][end][end] |
| 75 | <tr data-url="[detail_url]" class="comprow [component_defs.classes]"> |
Adrià Vilanova Martínez | f19ea43 | 2024-01-23 20:20:52 +0100 | [diff] [blame] | 76 | [if-any can_edit_project] |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 77 | <td class="cb rowwidgets"> |
| 78 | <input type="checkbox" data-path="[component_defs.path]" class="checkRangeSelect"> |
| 79 | </td> |
| 80 | [end] |
| 81 | <td> |
| 82 | [component_defs.component_id] |
| 83 | </td> |
| 84 | <td class="id"> |
| 85 | <a style="white-space:nowrap" href="[detail_url]">[component_defs.path]</a> |
| 86 | </td> |
| 87 | <td> |
| 88 | [for component_defs.admins] |
| 89 | [include "../framework/user-link.ezt" component_defs.admins][if-index component_defs.admins last][else],[end] |
| 90 | [end] |
| 91 | </td> |
| 92 | <td> |
| 93 | [for component_defs.cc] |
| 94 | [include "../framework/user-link.ezt" component_defs.cc][if-index component_defs.cc last][else],[end] |
| 95 | [end] |
| 96 | </td> |
| 97 | <td> |
| 98 | [for component_defs.labels] |
| 99 | [component_defs.labels][if-index component_defs.labels last][else],[end] |
| 100 | [end] |
| 101 | </td> |
| 102 | <td> |
| 103 | [component_defs.docstring_short] |
| 104 | </td> |
| 105 | </tr> |
| 106 | [end] |
| 107 | </tbody> |
| 108 | </table> |
| 109 | </div>[# section] |
| 110 | |
| 111 | <div class="list-foot"></div> |
Adrià Vilanova Martínez | f19ea43 | 2024-01-23 20:20:52 +0100 | [diff] [blame] | 112 | [if-any can_edit_project] |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 113 | <form action="adminComponents.do" method="POST"> |
| 114 | <a href="/p/[projectname]/components/create" class="buttonify primary">Create component</a> |
| 115 | <input type="hidden" name="delete_components"> |
| 116 | <input type="hidden" name="token" value="[form_token]"> |
| 117 | <input type="submit" class="secondary" name="deletebtn" value="Delete Component(s)" disabled> |
| 118 | </form> |
| 119 | [end] |
| 120 | |
| 121 | </form> |
| 122 | |
| 123 | [end] |
| 124 | |
| 125 | <script type="text/javascript" nonce="[nonce]"> |
| 126 | runOnLoad(function() { |
| 127 | if ($("selectall")) { |
| 128 | $("selectall").addEventListener("click", function() { |
| 129 | _selectAllIssues(); |
| 130 | setDisabled(false); |
| 131 | }); |
| 132 | } |
| 133 | if ($("selectnone")) { |
| 134 | $("selectnone").addEventListener("click", function() { |
| 135 | _selectNoneIssues(); |
| 136 | setDisabled(true); |
| 137 | }); |
| 138 | } |
| 139 | |
| 140 | var checkboxNodes = document.getElementsByClassName("checkRangeSelect"); |
| 141 | var checkboxes = Array(); |
| 142 | for (var i = 0; i < checkboxNodes.length; ++i) { |
| 143 | var checkbox = checkboxNodes.item(i); |
| 144 | checkboxes.push(checkbox); |
| 145 | checkbox.addEventListener("click", function (event) { |
| 146 | _checkRangeSelect(event, event.target); |
| 147 | _highlightRow(event.target); |
| 148 | updateEnabled(); |
| 149 | }); |
| 150 | } |
| 151 | |
| 152 | function updateEnabled() { |
| 153 | var anySelected = checkboxes.some(function(checkbox) { |
| 154 | return checkbox.checked; |
| 155 | }); |
| 156 | setDisabled(!anySelected); |
| 157 | } |
| 158 | |
| 159 | var deleteButtons = document.getElementsByName("deletebtn"); |
| 160 | function setDisabled(disabled) { |
| 161 | for (var i = 0; i < deleteButtons.length; ++i) { |
| 162 | deleteButtons.item(i).disabled = disabled; |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | for (var i = 0; i < deleteButtons.length; ++i) { |
| 167 | deleteButtons.item(i).addEventListener("click", function(event) { |
| 168 | var componentsToDelete = []; |
| 169 | for (var i = 0; i< checkboxes.length; ++i) { |
| 170 | var checkbox = checkboxes[[]i]; |
| 171 | if (checkbox.checked) |
| 172 | componentsToDelete.push(checkbox.getAttribute("data-path")); |
| 173 | } |
| 174 | var fields = document.getElementsByName("delete_components"); |
| 175 | for (var i = 0; i< fields.length; ++i) { |
| 176 | fields.item(i).value = componentsToDelete.join(); |
| 177 | } |
| 178 | if (!confirm("Are you sure you want to delete the selected components ?\nThis operation cannot be undone.")) |
| 179 | event.preventDefault(); |
| 180 | }); |
| 181 | } |
| 182 | |
| 183 | function _handleResultsClick(event) { |
| 184 | var target = event.target; |
| 185 | if (target.tagName == "A" || target.type == "checkbox" || target.className == "cb") |
| 186 | return; |
| 187 | while (target && target.tagName != "TR") target = target.parentNode; |
| 188 | _go(target.attributes[[]"data-url"].value, |
| 189 | (event.metaKey || event.ctrlKey || event.button == 1)); |
| 190 | }; |
| 191 | _addClickListener($("resultstable"), _handleResultsClick); |
| 192 | |
| 193 | |
| 194 | function _handleRowFilterChange(event) { |
| 195 | $("resultstable").classList.remove('all', 'active', 'toplevel', 'myadmin', 'mycc', 'deprecated'); |
| 196 | $("resultstable").classList.add(event.target.value); |
| 197 | }; |
| 198 | $("rowfilter").addEventListener("change", _handleRowFilterChange); |
| 199 | }); |
| 200 | </script> |
| 201 | |
| 202 | |
| 203 | [include "../framework/footer.ezt"] |