Skip to content

Commit

Permalink
fix icon picker (#4065)
Browse files Browse the repository at this point in the history
  • Loading branch information
ashton22305 authored Jan 9, 2025
1 parent ad1e1bc commit e6884ed
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
23 changes: 15 additions & 8 deletions apps/dashboard/app/javascript/icon_picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,22 @@ function searchIcons(event) {
const uniqueSearchCharacters = new Set(searchString.split(''));
const searchCharacters = [...uniqueSearchCharacters].filter((char) => indexKeys.includes(char));

searchCharacters.forEach(char => {
const indices = invertedIndex[char]; // Get indices for the character in the inverted index
indices.forEach(index => {
const iconStr = ALL_ICONS[index].toLowerCase();
if (iconStr.includes(searchString)) {
resultIndices.add(index);
}
// Account for boundary condition where the search string is empty
if(searchString.length === 0) {
for(let i = 0; i < ALL_ICONS.length; i++) {
resultIndices.add(i);
}
} else {
searchCharacters.forEach(char => {
const indices = invertedIndex[char]; // Get indices for the character in the inverted index
indices.forEach(index => {
const iconStr = ALL_ICONS[index].toLowerCase();
if (iconStr.includes(searchString)) {
resultIndices.add(index);
}
});
});
});
}

ALL_ICONS.forEach((name, idx) => {
const ele = $(`#${iconId(name)}`)[0];
Expand Down
11 changes: 9 additions & 2 deletions apps/dashboard/test/system/project_manager_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,18 @@ def add_auto_environment_variable(project_id, launcher_id, save: true)
end

test 'searching icons works' do
# TODO
visit(new_project_path)
find('#product_icon_select').set('')
find('#product_icon_select').set('cog')
icons = find('#icon_picker_list').all('i')
assert_equal(4, icons.size)
end

test 'all icons show after clearing input field' do
# TODO
visit(new_project_path)
find('#product_icon_select').set('')
icons = find('#icon_picker_list').all('i')
assert_equal(990, icons.size)
end

test 'creating and showing launchers' do
Expand Down

0 comments on commit e6884ed

Please sign in to comment.