Skip to content

Added searchbar #639

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Production Decomposition mode allows controlling interoperability productions as individual files for each host (#469)
- Added saving settings as system default for new namespaces (#535)
- Added filtering through branch names in UI (#615)

## [2.7.1] - 2024-11-13

Expand Down
24 changes: 23 additions & 1 deletion git-webui/release/share/git-webui/webui/js/git-webui.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,28 @@ webui.SideBarView = function(mainView, noEventHandlers) {
}
});

// Search bar to filter the results
if (idPostfix =='popup') {
var searchBar = $('<input type="text" id="search-input" placeholder="Filter..." style="width:100%">').appendTo(accordionDiv)[0];
searchBar.onkeyup = function(){
let branchCards = accordionDiv.getElementsByClassName("branch-card");

var filter = searchBar.value.toUpperCase().replaceAll('/', '-');

for (let i = 0; i < branchCards.length; i++) {
let card = branchCards[i]
let cardHeader = card.querySelector('.card-header');
if (cardHeader) {
if (cardHeader.id.toUpperCase().indexOf(filter) > -1) {
card.style.display = '';
} else {
card.style.display = 'none';
}
}
}
};
}

for (var i = 0; i < refs.length && i < maxRefsCount; ++i) {
var ref = refs[i] + ""; // Get a copy of it
if (ref[2] == '(' && ref[ref.length - 1] == ')') {
Expand All @@ -405,7 +427,7 @@ webui.SideBarView = function(mainView, noEventHandlers) {
ref = ' ' + newref;
}
}
var cardDiv = $('<div class="card custom-card">').appendTo(accordionDiv)[0];
var cardDiv = $('<div class="card custom-card branch-card">').appendTo(accordionDiv)[0];
if (id.indexOf("local-branches") > -1) {
// parses the output of git branch --verbose --verbose
var matches = /^\*?\s*([\w-.@&_\/]+)\s+([^\s]+)\s+(\[.*\])?.*/.exec(ref);
Expand Down
24 changes: 23 additions & 1 deletion git-webui/src/share/git-webui/webui/js/git-webui.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,28 @@ webui.SideBarView = function(mainView, noEventHandlers) {
}
});

// Search bar to filter the results
if (idPostfix =='popup') {
var searchBar = $('<input type="text" id="search-input" placeholder="Filter..." style="width:100%">').appendTo(accordionDiv)[0];
searchBar.onkeyup = function(){
let branchCards = accordionDiv.getElementsByClassName("branch-card");

var filter = searchBar.value.toUpperCase().replaceAll('/', '-');

for (let i = 0; i < branchCards.length; i++) {
let card = branchCards[i]
let cardHeader = card.querySelector('.card-header');
if (cardHeader) {
if (cardHeader.id.toUpperCase().indexOf(filter) > -1) {
card.style.display = '';
} else {
card.style.display = 'none';
}
}
}
};
}

for (var i = 0; i < refs.length && i < maxRefsCount; ++i) {
var ref = refs[i] + ""; // Get a copy of it
if (ref[2] == '(' && ref[ref.length - 1] == ')') {
Expand All @@ -405,7 +427,7 @@ webui.SideBarView = function(mainView, noEventHandlers) {
ref = ' ' + newref;
}
}
var cardDiv = $('<div class="card custom-card">').appendTo(accordionDiv)[0];
var cardDiv = $('<div class="card custom-card branch-card">').appendTo(accordionDiv)[0];
if (id.indexOf("local-branches") > -1) {
// parses the output of git branch --verbose --verbose
var matches = /^\*?\s*([\w-.@&_\/]+)\s+([^\s]+)\s+(\[.*\])?.*/.exec(ref);
Expand Down
Loading