##// END OF EJS Templates
diffs: added handy quick file selector in diffs views.
ergo -
r3100:c6e45536 default
parent child Browse files
Show More
@@ -648,6 +648,7 b' pre.literal-block, .codehilite pre{'
648 648 @cb-text-padding: 5px;
649 649
650 650 @pill-padding: 2px 7px;
651 @pill-padding-small: 2px 2px 1px 2px;
651 652
652 653 input.filediff-collapse-state {
653 654 display: none;
@@ -725,11 +726,20 b' input.filediff-collapse-state {'
725 726 }
726 727 }
727 728
729 .filelist {
730 .pill {
731 display: block;
732 float: left;
733 padding: @pill-padding-small;
734 }
735 }
736
728 737 .pill {
729 738 display: block;
730 739 float: left;
731 740 padding: @pill-padding;
732 741 }
742
733 743 .pill-group {
734 744 .pill {
735 745 opacity: .8;
@@ -815,6 +825,56 b' input.filediff-collapse-state {'
815 825 }
816 826 }
817 827
828 .filediff-collapse-button, .filediff-expand-button {
829 cursor: pointer;
830 }
831 .filediff-collapse-button {
832 display: inline;
833 }
834 .filediff-expand-button {
835 display: none;
836 }
837 .filediff-collapsed .filediff-collapse-button {
838 display: none;
839 }
840 .filediff-collapsed .filediff-expand-button {
841 display: inline;
842 }
843
844 /**** COMMENTS ****/
845
846 .filediff-menu {
847 .show-comment-button {
848 display: none;
849 }
850 }
851 &.hide-comments {
852 .inline-comments {
853 display: none;
854 }
855 .filediff-menu {
856 .show-comment-button {
857 display: inline;
858 }
859 .hide-comment-button {
860 display: none;
861 }
862 }
863 }
864
865 .hide-line-comments {
866 .inline-comments {
867 display: none;
868 }
869 }
870
871 /**** END COMMENTS ****/
872
873 }
874
875
876
877 .filediff, .filelist {
818 878 .pill {
819 879 &[op="name"] {
820 880 background: none;
@@ -868,53 +928,8 b' input.filediff-collapse-state {'
868 928 color: white;
869 929 }
870 930 }
871
872 .filediff-collapse-button, .filediff-expand-button {
873 cursor: pointer;
874 }
875 .filediff-collapse-button {
876 display: inline;
877 }
878 .filediff-expand-button {
879 display: none;
880 }
881 .filediff-collapsed .filediff-collapse-button {
882 display: none;
883 }
884 .filediff-collapsed .filediff-expand-button {
885 display: inline;
886 931 }
887 932
888 /**** COMMENTS ****/
889
890 .filediff-menu {
891 .show-comment-button {
892 display: none;
893 }
894 }
895 &.hide-comments {
896 .inline-comments {
897 display: none;
898 }
899 .filediff-menu {
900 .show-comment-button {
901 display: inline;
902 }
903 .hide-comment-button {
904 display: none;
905 }
906 }
907 }
908
909 .hide-line-comments {
910 .inline-comments {
911 display: none;
912 }
913 }
914
915 /**** END COMMENTS ****/
916
917 }
918 933
919 934 .filediff-outdated {
920 935 padding: 8px 0;
@@ -211,7 +211,7 b''
211 211 </div> <!-- end summary -->
212 212 <div class="cs_files">
213 213 <%namespace name="cbdiffs" file="/codeblocks/diffs.mako"/>
214 ${cbdiffs.render_diffset_menu()}
214 ${cbdiffs.render_diffset_menu(c.changes[c.commit.raw_id])}
215 215 ${cbdiffs.render_diffset(
216 216 c.changes[c.commit.raw_id], commit=c.commit, use_comments=True,inline_comments=c.inline_comments )}
217 217 </div>
@@ -3,9 +3,9 b''
3 3
4 4 <%def name="title()">
5 5 ${_('%s Commits') % c.repo_name} -
6 r${c.commit_ranges[0].revision}:${h.short_id(c.commit_ranges[0].raw_id)}
6 r${c.commit_ranges[0].idx}:${h.short_id(c.commit_ranges[0].raw_id)}
7 7 ...
8 r${c.commit_ranges[-1].revision}:${h.short_id(c.commit_ranges[-1].raw_id)}
8 r${c.commit_ranges[-1].idx}:${h.short_id(c.commit_ranges[-1].raw_id)}
9 9 ${_ungettext('(%s commit)','(%s commits)', len(c.commit_ranges)) % len(c.commit_ranges)}
10 10 %if c.rhodecode_name:
11 11 &middot; ${h.branding(c.rhodecode_name)}
@@ -14,9 +14,9 b''
14 14
15 15 <%def name="breadcrumbs_links()">
16 16 ${_('Commits')} -
17 r${c.commit_ranges[0].revision}:${h.short_id(c.commit_ranges[0].raw_id)}
17 r${c.commit_ranges[0].idx}:${h.short_id(c.commit_ranges[0].raw_id)}
18 18 ...
19 r${c.commit_ranges[-1].revision}:${h.short_id(c.commit_ranges[-1].raw_id)}
19 r${c.commit_ranges[-1].idx}:${h.short_id(c.commit_ranges[-1].raw_id)}
20 20 ${_ungettext('(%s commit)','(%s commits)', len(c.commit_ranges)) % len(c.commit_ranges)}
21 21 </%def>
22 22
@@ -43,7 +43,7 b''
43 43 <h4>
44 44 ${_('Commit Range')}
45 45 <code>
46 r${c.commit_ranges[0].revision}:${h.short_id(c.commit_ranges[0].raw_id)}...r${c.commit_ranges[-1].revision}:${h.short_id(c.commit_ranges[-1].raw_id)}
46 r${c.commit_ranges[0].idx}:${h.short_id(c.commit_ranges[0].raw_id)}...r${c.commit_ranges[-1].idx}:${h.short_id(c.commit_ranges[-1].raw_id)}
47 47 </code>
48 48 </h4>
49 49 </span>
@@ -54,7 +54,7 b''
54 54 ${_('Diff option')}:
55 55 </div>
56 56 <div class="right-content">
57 <div class="header-buttons">
57 <div class="btn btn-primary">
58 58 <a href="${h.route_path('repo_compare',
59 59 repo_name=c.repo_name,
60 60 source_ref_type='rev',
@@ -116,19 +116,23 b' collapse_all = len(diffset.files) > coll'
116 116 </div>
117 117 %endif
118 118 <h2 class="clearinner">
119 ## invidual commit
119 120 %if commit:
120 <a class="tooltip revision" title="${h.tooltip(commit.message)}" href="${h.route_path('repo_commit',repo_name=c.repo_name,commit_id=commit.raw_id)}">${'r%s:%s' % (commit.revision,h.short_id(commit.raw_id))}</a> -
121 ${h.age_component(commit.date)} -
122 %endif
123
121 <a class="tooltip revision" title="${h.tooltip(commit.message)}" href="${h.route_path('repo_commit',repo_name=c.repo_name,commit_id=commit.raw_id)}">${('r%s:%s' % (commit.idx,h.short_id(commit.raw_id)))}</a> -
122 ${h.age_component(commit.date)}
124 123 %if diffset.limited_diff:
125 ${_('The requested commit is too big and content was truncated.')}
126
124 - ${_('The requested commit is too big and content was truncated.')}
127 125 ${_ungettext('%(num)s file changed.', '%(num)s files changed.', diffset.changed_files) % {'num': diffset.changed_files}}
128 126 <a href="${h.current_route_path(request, fulldiff=1)}" onclick="return confirm('${_("Showing a big diff might take some time and resources, continue?")}')">${_('Show full diff')}</a>
127 % elif hasattr(c, 'commit_ranges') and len(c.commit_ranges) > 1:
128 ## compare diff, has no file-selector and we want to show stats anyway
129 ${_ungettext('{num} file changed: {linesadd} inserted, ''{linesdel} deleted',
130 '{num} files changed: {linesadd} inserted, {linesdel} deleted', diffset.changed_files) \
131 .format(num=diffset.changed_files, linesadd=diffset.lines_added, linesdel=diffset.lines_deleted)}
132 % endif
129 133 %else:
130 ${_ungettext('%(num)s file changed: %(linesadd)s inserted, ''%(linesdel)s deleted',
131 '%(num)s files changed: %(linesadd)s inserted, %(linesdel)s deleted', diffset.changed_files) % {'num': diffset.changed_files, 'linesadd': diffset.lines_added, 'linesdel': diffset.lines_deleted}}
134 ## pull requests/compare
135 ${_('File Changes')}
132 136 %endif
133 137
134 138 </h2>
@@ -432,7 +436,7 b' from rhodecode.lib.diffs import NEW_FILE'
432 436 </%def>
433 437
434 438 <%def name="nice_mode(filemode)">
435 ${filemode.startswith('100') and filemode[3:] or filemode}
439 ${(filemode.startswith('100') and filemode[3:] or filemode)}
436 440 </%def>
437 441
438 442 <%def name="diff_menu(filediff, use_comments=False)">
@@ -693,7 +697,7 b' def get_comments_for(diff_type, comments'
693 697 %endif
694 698 </td>
695 699 <td class="cb-content ${action_class(action)}"
696 data-line-no="${new_line_no and 'n' or 'o'}${new_line_no or old_line_no}"
700 data-line-no="${(new_line_no and 'n' or 'o')}${(new_line_no or old_line_no)}"
697 701 >
698 702 %if use_comments:
699 703 ${render_add_comment_button()}
@@ -727,7 +731,7 b' def get_comments_for(diff_type, comments'
727 731 </button>
728 732 </%def>
729 733
730 <%def name="render_diffset_menu()">
734 <%def name="render_diffset_menu(diffset=None)">
731 735
732 736 <div class="diffset-menu clearinner">
733 737 <div class="pull-right">
@@ -749,6 +753,9 b' def get_comments_for(diff_type, comments'
749 753
750 754 <div class="pull-left">
751 755 <div class="btn-group">
756 <div class="pull-left">
757 ${h.hidden('file_filter')}
758 </div>
752 759 <a
753 760 class="btn"
754 761 href="#"
@@ -761,7 +768,103 b' def get_comments_for(diff_type, comments'
761 768 class="btn"
762 769 href="#"
763 770 onclick="return Rhodecode.comments.toggleWideMode(this)">${_('Wide Mode Diff')}</a>
771
764 772 </div>
765 773 </div>
766 774 </div>
775
776 % if diffset:
777
778 %if diffset.limited_diff:
779 <% file_placeholder = _ungettext('%(num)s file changed', '%(num)s files changed', diffset.changed_files) % {'num': diffset.changed_files}%>
780 %else:
781 <% file_placeholder = _ungettext('%(num)s file changed: %(linesadd)s inserted, ''%(linesdel)s deleted', '%(num)s files changed: %(linesadd)s inserted, %(linesdel)s deleted', diffset.changed_files) % {'num': diffset.changed_files, 'linesadd': diffset.lines_added, 'linesdel': diffset.lines_deleted}%>
782 %endif
783
784 <script>
785
786 var feedFilesOptions = function (query, initialData) {
787 var data = {results: []};
788 var isQuery = typeof query.term !== 'undefined';
789
790 var section = _gettext('Changed files');
791 var filteredData = [];
792
793 //filter results
794 $.each(initialData.results, function (idx, value) {
795
796 if (!isQuery || query.term.length === 0 || value.text.toUpperCase().indexOf(query.term.toUpperCase()) >= 0) {
797 filteredData.push({
798 'id': this.id,
799 'text': this.text,
800 "ops": this.ops,
801 })
802 }
803
804 });
805
806 data.results = filteredData;
807
808 query.callback(data);
809 };
810
811 var formatFileResult = function(result, container, query, escapeMarkup) {
812 return function(data, escapeMarkup) {
813 var container = '<div class="filelist" style="padding-right:100px">{0}</div>';
814 var tmpl = '<span style="margin-right:-50px"><strong>{0}</strong></span>'.format(escapeMarkup(data['text']));
815 var pill = '<span class="pill-group" style="float: right;margin-right: -100px">' +
816 '<span class="pill" op="added">{0}</span>' +
817 '<span class="pill" op="deleted">{1}</span>' +
818 '</span>'
819 ;
820 var added = data['ops']['added'];
821 if (added === 0) {
822 // don't show +0
823 added = 0;
824 } else {
825 added = '+' + added;
826 }
827
828 var deleted = -1*data['ops']['deleted'];
829
830 tmpl += pill.format(added, deleted);
831 return container.format(tmpl);
832
833 }(result, escapeMarkup);
834 };
835 var preloadData = {
836 results: [
837 % for filediff in diffset.files:
838 {id:"a_${h.FID('', filediff.patch['filename'])}",
839 text:"${filediff.patch['filename']}",
840 ops:${h.json.dumps(filediff.patch['stats'])|n}}${('' if loop.last else ',')}
841 % endfor
842 ]
843 };
844
845 $("#file_filter").select2({
846 'dropdownAutoWidth': true,
847 'width': 'auto',
848 'placeholder': "${file_placeholder}",
849 containerCssClass: "drop-menu",
850 dropdownCssClass: "drop-menu-dropdown",
851 data: preloadData,
852 query: function(query) {
853 feedFilesOptions(query, preloadData);
854 },
855 formatResult: formatFileResult
856 });
857
858 $("#file_filter").on('click', function (e) {
859 e.preventDefault();
860 var selected = $('#file_filter').select2('data');
861 var idSelector = "#"+selected.id;
862 window.location.hash = idSelector;
863 // expand the container if we quick-select the field
864 $(idSelector).prev().prop('checked', false);
865 })
866
867 </script>
868 % endif
869
767 870 </%def>
@@ -40,7 +40,7 b''
40 40 <td class="td-hash">
41 41 <code>
42 42 <a href="${h.route_path('repo_commit', repo_name=c.target_repo.repo_name, commit_id=commit.raw_id)}">
43 r${commit.revision}:${h.short_id(commit.raw_id)}
43 r${commit.idx}:${h.short_id(commit.raw_id)}
44 44 </a>
45 45 ${h.hidden('revisions',commit.raw_id)}
46 46 </code>
@@ -322,7 +322,7 b''
322 322 <div style="padding:0 10px 10px 0px" class="pull-left"></div>
323 323 ## commit compare generated below
324 324 <%include file="compare_commits.mako"/>
325 ${cbdiffs.render_diffset_menu()}
325 ${cbdiffs.render_diffset_menu(c.diffset)}
326 326 ${cbdiffs.render_diffset(c.diffset)}
327 327 </div>
328 328 % endif
@@ -330,4 +330,4 b''
330 330 </div>
331 331 </div>
332 332
333 </%def> No newline at end of file
333 </%def>
@@ -568,7 +568,7 b''
568 568
569 569 <div class="cs_files">
570 570 <%namespace name="cbdiffs" file="/codeblocks/diffs.mako"/>
571 ${cbdiffs.render_diffset_menu()}
571 ${cbdiffs.render_diffset_menu(c.diffset)}
572 572 ${cbdiffs.render_diffset(
573 573 c.diffset, use_comments=True,
574 574 collapse_when_files_over=30,
General Comments 0
You need to be logged in to leave comments. Login now