##// END OF EJS Templates
hide add new file button if user has no permission for it
marcink -
r1486:92f0065b beta
parent child Browse files
Show More
@@ -1,221 +1,223
1 1 <%def name="file_class(node)">
2 2 %if node.is_file():
3 3 <%return "browser-file" %>
4 4 %else:
5 5 <%return "browser-dir"%>
6 6 %endif
7 7 </%def>
8 8 <div id="body" class="browserblock">
9 9 <div class="browser-header">
10 10 <div class="browser-nav">
11 11 ${h.form(h.url.current())}
12 12 <div class="info_box">
13 13 <span class="rev">${_('view')}@rev</span>
14 14 <a class="rev" href="${c.url_prev}" title="${_('previous revision')}">&laquo;</a>
15 15 ${h.text('at_rev',value=c.changeset.revision,size=5)}
16 16 <a class="rev" href="${c.url_next}" title="${_('next revision')}">&raquo;</a>
17 17 ## ${h.submit('view',_('view'),class_="ui-button-small")}
18 18 </div>
19 19 ${h.end_form()}
20 20 </div>
21 21 <div class="browser-branch">
22 22 ${h.checkbox('stay_at_branch',c.changeset.branch,c.changeset.branch==c.branch)}
23 23 <label>${_('follow current branch')}</label>
24 24 </div>
25 25 <div class="browser-search">
26 26 <div id="search_activate_id" class="search_activate">
27 27 <a id="filter_activate" href="#">${_('search file list')}</a>
28 28 </div>
29 <div id="add_node_id" class="add_node">
30 <a href="${h.url('files_add_home',repo_name=c.repo_name,revision=c.changeset.raw_id,f_path=c.f_path)}">${_('add new file')}</a>
31 </div>
29 % if h.HasRepoPermissionAny('repository.write','repository.admin')(c.repo_name):
30 <div id="add_node_id" class="add_node">
31 <a href="${h.url('files_add_home',repo_name=c.repo_name,revision=c.changeset.raw_id,f_path=c.f_path)}">${_('add new file')}</a>
32 </div>
33 % endif
32 34 <div>
33 35 <div id="node_filter_box_loading" style="display:none">${_('Loading file list...')}</div>
34 36 <div id="node_filter_box" style="display:none">
35 37 ${h.files_breadcrumbs(c.repo_name,c.changeset.raw_id,c.files_list.path)}/<input type="text" value="type to search..." name="filter" size="25" id="node_filter" autocomplete="off">
36 38
37 39 <script type="text/javascript">
38 40
39 41 YUE.on('stay_at_branch','click',function(e){
40 42 if(e.target.checked){
41 43 var uri = "${h.url.current(branch='__BRANCH__')}"
42 44 uri = uri.replace('__BRANCH__',e.target.value);
43 45 window.location = uri;
44 46 }
45 47 else{
46 48 window.location = "${h.url.current()}";
47 49 }
48 50
49 51 })
50 52
51 53 var n_filter = YUD.get('node_filter');
52 54 var F = YAHOO.namespace('node_filter');
53 55
54 56 var url = '${h.url("files_nodelist_home",repo_name="__REPO__",revision="__REVISION__",f_path="__FPATH__")}';
55 57 var node_url = '${h.url("files_home",repo_name="__REPO__",revision="__REVISION__",f_path="__FPATH__")}';
56 58
57 59 url = url.replace('__REPO__','${c.repo_name}');
58 60 url = url.replace('__REVISION__','${c.changeset.raw_id}');
59 61 url = url.replace('__FPATH__','${c.files_list.path}');
60 62
61 63 node_url = node_url.replace('__REPO__','${c.repo_name}');
62 64 node_url = node_url.replace('__REVISION__','${c.changeset.raw_id}');
63 65
64 66
65 67 F.filterTimeout = null;
66 68 var nodes = null;
67 69
68 70
69 71 F.initFilter = function(){
70 72 YUD.setStyle('node_filter_box_loading','display','');
71 73 YUD.setStyle('search_activate_id','display','none');
72 74 YUD.setStyle('add_node_id','display','none');
73 75 YUC.initHeader('X-PARTIAL-XHR',true);
74 76 YUC.asyncRequest('GET',url,{
75 77 success:function(o){
76 78 nodes = JSON.parse(o.responseText);
77 79 YUD.setStyle('node_filter_box_loading','display','none');
78 80 YUD.setStyle('node_filter_box','display','');
79 81 },
80 82 failure:function(o){
81 83 console.log('failed to load');
82 84 }
83 85 },null);
84 86 }
85 87
86 88 F.updateFilter = function(e) {
87 89
88 90 return function(){
89 91 // Reset timeout
90 92 F.filterTimeout = null;
91 93 var query = e.target.value;
92 94 var match = [];
93 95 var matches = 0;
94 96 var matches_max = 20;
95 97 if (query != ""){
96 98 for(var i=0;i<nodes.length;i++){
97 99 var pos = nodes[i].toLowerCase().indexOf(query)
98 100 if(query && pos != -1){
99 101
100 102 matches++
101 103 //show only certain amount to not kill browser
102 104 if (matches > matches_max){
103 105 break;
104 106 }
105 107
106 108 var n = nodes[i];
107 109 var n_hl = n.substring(0,pos)
108 110 +"<b>{0}</b>".format(n.substring(pos,pos+query.length))
109 111 +n.substring(pos+query.length)
110 112 match.push('<tr><td><a class="browser-file" href="{0}">{1}</a></td><td colspan="5"></td></tr>'.format(node_url.replace('__FPATH__',n),n_hl));
111 113 }
112 114 if(match.length >= matches_max){
113 115 match.push('<tr><td>{0}</td><td colspan="5"></td></tr>'.format("${_('search truncated')}"));
114 116 }
115 117
116 118 }
117 119 }
118 120
119 121 if(query != ""){
120 122 YUD.setStyle('tbody','display','none');
121 123 YUD.setStyle('tbody_filtered','display','');
122 124
123 125 if (match.length==0){
124 126 match.push('<tr><td>{0}</td><td colspan="5"></td></tr>'.format("${_('no matching files')}"));
125 127 }
126 128
127 129 YUD.get('tbody_filtered').innerHTML = match.join("");
128 130 }
129 131 else{
130 132 YUD.setStyle('tbody','display','');
131 133 YUD.setStyle('tbody_filtered','display','none');
132 134 }
133 135
134 136 }
135 137 }
136 138
137 139
138 140 YUE.on(YUD.get('filter_activate'),'click',function(){
139 141 F.initFilter();
140 142 })
141 143 YUE.on(n_filter,'click',function(){
142 144 n_filter.value = '';
143 145 });
144 146 YUE.on(n_filter,'keyup',function(e){
145 147 clearTimeout(F.filterTimeout);
146 148 F.filterTimeout = setTimeout(F.updateFilter(e),600);
147 149 });
148 150 </script>
149 151
150 152 </div>
151 153 </div>
152 154 </div>
153 155 </div>
154 156
155 157 <div class="browser-body">
156 158 <table class="code-browser">
157 159 <thead>
158 160 <tr>
159 161 <th>${_('Name')}</th>
160 162 <th>${_('Size')}</th>
161 163 <th>${_('Mimetype')}</th>
162 164 <th>${_('Revision')}</th>
163 165 <th>${_('Last modified')}</th>
164 166 <th>${_('Last commiter')}</th>
165 167 </tr>
166 168 </thead>
167 169
168 170 <tbody id="tbody">
169 171 %if c.files_list.parent:
170 172 <tr class="parity0">
171 173 <td>
172 174 ${h.link_to('..',h.url('files_home',repo_name=c.repo_name,revision=c.changeset.raw_id,f_path=c.files_list.parent.path),class_="browser-dir")}
173 175 </td>
174 176 <td></td>
175 177 <td></td>
176 178 <td></td>
177 179 <td></td>
178 180 <td></td>
179 181 </tr>
180 182 %endif
181 183
182 184 %for cnt,node in enumerate(c.files_list):
183 185 <tr class="parity${cnt%2}">
184 186 <td>
185 187 ${h.link_to(node.name,h.url('files_home',repo_name=c.repo_name,revision=c.changeset.raw_id,f_path=h.safe_unicode(node.path)),class_=file_class(node))}
186 188 </td>
187 189 <td>
188 190 %if node.is_file():
189 191 ${h.format_byte_size(node.size,binary=True)}
190 192 %endif
191 193 </td>
192 194 <td>
193 195 %if node.is_file():
194 196 ${node.mimetype}
195 197 %endif
196 198 </td>
197 199 <td>
198 200 %if node.is_file():
199 201 <span class="tooltip" title="${node.last_changeset.raw_id}">
200 202 ${'r%s:%s' % (node.last_changeset.revision,node.last_changeset.short_id)}</span>
201 203 %endif
202 204 </td>
203 205 <td>
204 206 %if node.is_file():
205 207 <span class="tooltip" title="${node.last_changeset.date}">
206 208 ${h.age(node.last_changeset.date)}</span>
207 209 %endif
208 210 </td>
209 211 <td>
210 212 %if node.is_file():
211 213 ${node.last_changeset.author}
212 214 %endif
213 215 </td>
214 216 </tr>
215 217 %endfor
216 218 </tbody>
217 219 <tbody id="tbody_filtered" style="display:none">
218 220 </tbody>
219 221 </table>
220 222 </div>
221 223 </div> No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now