Skip to content
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

Feature: Filter Aliases by Category/Type #1024

Merged
merged 18 commits into from
Aug 25, 2021
Merged

Conversation

maxxcrawford
Copy link
Contributor

@maxxcrawford maxxcrawford commented Aug 17, 2021

TODO:

  • Confirm mobile design/functionality
  • Add multiple filter support (Active, domain only)
  • Clicking off the pop-up should close it
  • Pressing "Esc" should close the pop-up
  • Add strings to FTL
  • Auto-apply the filtering when the checkbox is clicked (don't wait for the user to click "Apply") Deferring this for now.

Bonus Items/issues:

  • Add keyboard controls
  • Create empty results state (Check with UX)
  • A11y check

Questions/Edge cases: (Answered by Eduardo on Aug 18)

  • What to do when two opposing (on/off) categories are selected?
    • Answer: If one option conflicts with another, uncheck it. (psuedo radio buttons)
  • What happens when a user searches while the category filter is active?
    • Answer: The filter only applies to active elements. If a user has category filtered, searching should only apply to those (and vice versa if search is active.
  • How do we show a user the category filter is active?
    • Answer: For now, keep the filter icon hover state active.

@maxxcrawford maxxcrawford added the 🚧 WIP Work in Progress label Aug 17, 2021
@maxxcrawford maxxcrawford linked an issue Aug 17, 2021 that may be closed by this pull request
@maxxcrawford maxxcrawford force-pushed the 1023-filter-category branch 2 times, most recently from 4b3d643 to 723d50e Compare August 19, 2021 15:47
@maxxcrawford maxxcrawford marked this pull request as ready for review August 19, 2021 15:56
@maxxcrawford maxxcrawford requested a review from codemist August 19, 2021 15:56
@@ -10,7 +14,7 @@
}
}

&.is-search-active {
&.is-search-visible {
margin-bottom: 4.5rem;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is ~72px. The biggest the spacing- tokens go is 48px. Leaving as is.

Copy link
Contributor Author

@maxxcrawford maxxcrawford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self JS review

Comment on lines +10 to +11
let currentFilteredByCategoryAliases;
let currentFilteredBySearchAliases;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let sniff: This is part of some wild west state management. If we want to flag it for a state. type object, we can refactor heavily to manage this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh, some random state object flying around would be worse than let anyway. If I can't come up with a refactor in 10-15m I'm fine with keeping let

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's worth exploring later on, when we have even more search going on. When filters get stacked on top of each other, having single point of reference of what should be filtered is helpful.

static/js/filter.js Outdated Show resolved Hide resolved
function toggleAliasSearchBar() {
filterToggleSearchInput.classList.toggle("is-enabled");
filterContainer.classList.toggle("is-search-active")
filterContainer.classList.toggle("is-search-visible");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class is used to toggle (via CSS) search on mobile/tablet.

static/js/filter.js Outdated Show resolved Hide resolved
Comment on lines 54 to 58
if (isCategoryFilterActive) {
// aliases =
currentFilteredByCategoryAliases = document.querySelectorAll(".c-alias:not(.is-hidden)");
} else {
filterContainer.classList.add("is-filtered-by-search");
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic block appears throughout this PR and is the crux of the overall feature. Basically when either search or category filtering is active, we have to trunicate the list of available aliases for the OTHER filter to query from. Moving to state management would drop this logic, giving each filtering type the same centralized "target" to query from.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this feels like we're getting closer and closer to doing a full-on Redux/React refactor sometime.

static/js/filter.js Outdated Show resolved Hide resolved
Comment on lines +331 to +342
oppositeCheck: (e) => {
const currentCategory = e.target;

if (!currentCategory.checked) {
return;
}

const currentParentCategory = currentCategory.dataset.parentCategory;

filterCategoryCheckboxes.forEach(checkbox => {
if ( (currentCategory !== checkbox) && (checkbox.dataset.parentCategory === currentParentCategory) && checkbox.checked) {
checkbox.checked = !checkbox.checked;
}
});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This an edgecase function to make the checkboxes from the UI behave like radio buttons in certain cases:

Example: User opens filter and selects "show all active aliases" AND "show all disabled aliases". Since this would make the filter…useless, we detect this and toggle off the opposing checkbox.

@maxxcrawford maxxcrawford removed the 🚧 WIP Work in Progress label Aug 20, 2021
Copy link
Member

@groovecoder groovecoder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any cardinal sins in this code. There's a couple UX behaviors we might want to do?

  1. Clicking off the pop-up should close it
  2. Pressing "Esc" should close the pop-up
  3. Auto-apply the filtering when the checkbox is clicked (don't wait for the user to click "Apply")

privaterelay/templates/includes/dashboard-filter.html Outdated Show resolved Hide resolved
id="active-aliases"
value=""
>
<label class="mzp-c-choice-label" for="active-aliases">Active aliases</label>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The English strings need to be internationalized ... unless these aren't final UI strings, in which case, ignore.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strings added.

Comment on lines +10 to +11
let currentFilteredByCategoryAliases;
let currentFilteredBySearchAliases;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh, some random state object flying around would be worse than let anyway. If I can't come up with a refactor in 10-15m I'm fine with keeping let

Comment on lines 54 to 58
if (isCategoryFilterActive) {
// aliases =
currentFilteredByCategoryAliases = document.querySelectorAll(".c-alias:not(.is-hidden)");
} else {
filterContainer.classList.add("is-filtered-by-search");
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this feels like we're getting closer and closer to doing a full-on Redux/React refactor sometime.

static/js/filter.js Show resolved Hide resolved
static/scss/app.scss Show resolved Hide resolved
Copy link
Collaborator

@codemist codemist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, just nits :)

privaterelay/templates/includes/dashboard-filter.html Outdated Show resolved Hide resolved
privaterelay/templates/includes/dashboard-filter.html Outdated Show resolved Hide resolved
@maxxcrawford
Copy link
Contributor Author

Related PR for strings: mozilla-l10n/fx-private-relay-l10n#5

@maxxcrawford maxxcrawford merged commit 34e94f3 into main Aug 25, 2021
@groovecoder groovecoder deleted the 1023-filter-category branch October 7, 2021 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Alias Filter Feature: Filter by Attribute/Category
3 participants