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