-
Notifications
You must be signed in to change notification settings - Fork 7.5k
Implement multiple file exclusion sets #7836
Changes from 17 commits
240f3a9
0e73ef8
e6ef41a
0c0c44d
47cacb6
72e2c2d
ed0c537
748efac
4915301
99f3ede
f347c7f
171d73a
42930a3
aedbcba
1954e31
ff6f068
5665631
ba8bd1b
1b957c4
7d32194
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| <div class="file-filter-dialog modal"> | ||
| <div class="modal-header"> | ||
| <h1 class="dialog-title">{{Strings.FILE_FILTER_DIALOG}}</h1> | ||
| </div> | ||
| <div class="modal-body"> | ||
| <div class="dialog-message"> | ||
| {{{instruction}}} | ||
| <textarea class="exclusions-editor"></textarea> | ||
| <input type="text" class="exclusions-name" placeholder="{{Strings.FILTER_NAME_PLACEHOLDER}}"> | ||
| <div class="exclusions-filecount">{{Strings.FILTER_COUNTING_FILES}}</div> | ||
| </div> | ||
| </div> | ||
| <div class="modal-footer"> | ||
| <button class="dialog-button btn" data-button-id="cancel">{{Strings.CANCEL}}</button> | ||
| <button class="dialog-button btn primary" data-button-id="ok">{{Strings.OK}}</button> | ||
| </div> | ||
| </div> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| <div class='filter-trash-icon'>×</div><!-- | ||
| --><span class='recent-filter-name'>{{{filter-name}}}</span><!-- | ||
| --><span class='recent-filter-patterns'>{{{filter-patterns}}}</span><!-- | ||
| --><span class='filter-edit-icon'></span> |
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -112,13 +112,58 @@ define(function (require, exports, module) { | |
| DropdownButton.prototype._renderList = function () { | ||
| var html = ""; | ||
| this.items.forEach(function (item, i) { | ||
| html += "<li><a class='stylesheet-link' data-index='" + i + "'>"; | ||
| html += this.itemRenderer(item, i); | ||
| html += "</a></li>"; | ||
| if (item === "---") { | ||
| html += "<li class='divider'></li>"; | ||
| } else { | ||
| html += "<li><a class='stylesheet-link' data-index='" + i + "'>"; | ||
| html += this.itemRenderer(item, i); | ||
| html += "</a></li>"; | ||
| } | ||
| }.bind(this)); | ||
| return html; | ||
| }; | ||
|
|
||
| /** | ||
| * Refresh the dropdown list by removing and re-creating all list items. | ||
| * Call this after deleting/adding any item in the dropdown list. | ||
| */ | ||
| DropdownButton.prototype.refresh = function () { | ||
| if (!this.$dropdown) { | ||
| return; | ||
| } | ||
|
|
||
| // Remove all list items and then re-create them from this.items. | ||
| $("li", this.$dropdown).remove(); | ||
| this.$dropdown.append(this._renderList()); | ||
|
|
||
| // Also trigger openDropdown handler so that custom event handlers can be | ||
| // set up for any custom UI in the list. | ||
| $(this).triggerHandler("openDropdown", [this.$dropdown]); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a little funny to re-trigger
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It will work for all refresh cases if we move this call into There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah. Then maybe we should just make this a separate |
||
| }; | ||
|
|
||
| /** | ||
| * Check/Uncheck the list item of the given index. | ||
| * @param {number} index The index of the list item to be checked or unchecked | ||
| * @param {boolean} checked True if the list item is to be checked, false to get check | ||
| * mark removed. | ||
| */ | ||
| DropdownButton.prototype.setChecked = function (index, checked) { | ||
| if (!this.$dropdown) { | ||
| return; | ||
| } | ||
|
|
||
| var listItems = $("li", this.$dropdown), | ||
| count = listItems.length; | ||
|
|
||
| if (index > -1 && index < count) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the contents of this could just be
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
| if (checked) { | ||
| $("a", listItems[index]).addClass("checked"); | ||
| } else if ($(listItems[index]).hasClass("checked")) { | ||
| $("a", listItems[index]).removeClass("checked"); | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| /** Pops open the dropdown if currently closed. Does nothing if items.length == 0 */ | ||
| DropdownButton.prototype.showDropdown = function () { | ||
| // Act like a plain old button if no items to show | ||
|
|
@@ -178,6 +223,8 @@ define(function (require, exports, module) { | |
| $dropdown.focus(); | ||
|
|
||
| this.$dropdown = $dropdown; | ||
|
|
||
| $(this).triggerHandler("openDropdown", [$dropdown]); | ||
| }; | ||
|
|
||
| /** | ||
|
|
@@ -188,12 +235,12 @@ define(function (require, exports, module) { | |
| DropdownButton.prototype._onDropdownClose = function () { | ||
| window.document.body.removeEventListener("click", this._onClickOutside, true); | ||
| $(PanelManager).off("editorAreaResize", this.closeDropdown); | ||
|
|
||
| // Restore focus to old pos, unless "select" handler changed it | ||
| if (window.document.activeElement === this.$dropdown[0]) { | ||
| this._lastFocus.focus(); | ||
| } | ||
|
|
||
| this._dropdownEventHandler = null; | ||
| this.$dropdown = null; // already remvoed from DOM automatically by PopUpManager | ||
| }; | ||
|
|
@@ -209,8 +256,9 @@ define(function (require, exports, module) { | |
| DropdownButton.prototype._onClickOutside = function (event) { | ||
| var $container = $(event.target).closest(".dropdownbutton-popup"); | ||
|
|
||
| // If click is outside dropdown list, then close dropdown list | ||
| if ($container.length === 0 || $container[0] !== this.$dropdown[0]) { | ||
| // If click is outside dropdown list or dropdown button, then close dropdown list | ||
| if (!$(event.target).hasClass("btn btn-dropdown") && | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This selector will find any item that has these classes, and there could be another one on the screen. Can we compare the target to the specific DOM elements we care about?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I switched it to compare the event target with |
||
| ($container.length === 0 || $container[0] !== this.$dropdown[0])) { | ||
| this.closeDropdown(); | ||
| } | ||
| }; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This selector is very general - it could find some dropdown on the screen that wasn't associated with the file picker. Can we be more specific here?
Also, it would be best to add a specific API to FileFilters that just tells you whether its picker or dialog is open, and encapsulate the knowledge of how to determine that within FileFilters itself, rather than having FindInFiles know the details of how it's implemented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The additional code here is no longer needed since we've found a solution for clicking outside of the dropdown to keep the Find bar open with focus restored to the Search text field.