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

Shield: Country Rules #3828

Merged
merged 33 commits into from
Feb 27, 2024
Merged

Shield: Country Rules #3828

merged 33 commits into from
Feb 27, 2024

Conversation

aerosol
Copy link
Member

@aerosol aerosol commented Feb 26, 2024

Changes

This is very similar to #3761 - allows users to store up to 30 country codes that will be rejected on ingestion against the geolocation classification.

Migration will be extracted to a separate PR.

Notable differences/changes:

  • no "description" field - country name/flag are pretty self-explanatory, unlike IP
  • combobox picker for countries
  • the sidebar now includes Shields in a nested level sub-menu
  • "Added at" tooltips now display formatted, in site's timezone

Global bugfix: ComboBox resumes suggestions popup after hitting Escape while typing

Extra: Plausible.Timezone module was simplified + tests were added

Tests

  • Automated tests have been added
  • This PR does not require tests

Changelog

  • Entry has been added to changelog
  • This PR does not make a user-facing change

Documentation

  • Docs have been updated
  • This change does not need a documentation update

Dark mode

  • The UI has been tested both in dark and light mode
  • This PR does not change the UI

@aerosol aerosol mentioned this pull request Feb 26, 2024
8 tasks
@aerosol aerosol added the deploy-to-staging Special label that triggers a deploy to a staging environment label Feb 26, 2024
lib/plausible/shields.ex Show resolved Hide resolved
lib/plausible/shields.ex Outdated Show resolved Hide resolved
<span
id={"country-#{rule.id}"}
class="mr-4 cursor-help border-b border-dotted border-gray-400"
title={"Added at #{rule.updated_at} by #{rule.added_by}"}
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems to be an UTC timestamp, not the users local time, will this cause confusion?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice, I'll use site's timezone.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh wait, this only renders a date

Copy link
Member Author

Choose a reason for hiding this comment

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


assert element_exists?(
resp,
~s/button[phx-click="remove-country-rule"][phx-value-rule-id="#{r2.id}"]#remove-country-rule-#{r2.id}/
Copy link
Contributor

Choose a reason for hiding this comment

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

This is clunky. Idea: Should we add a custom attribute to this element, e.g. data-test-remove-rule="123"? IMO this would make tests much easier to write and follow and would allow for separation of concerns.

Copy link
Member Author

Choose a reason for hiding this comment

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

Only for the sake of test selectors? I think using phx- attributes is meaningful because it implies LV picks them up.

Copy link
Member Author

Choose a reason for hiding this comment

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

How about I make this more readable?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@macobo macobo left a comment

Choose a reason for hiding this comment

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

LGTM.

Something to consider as a follow-up: It might be worth adding the VPN nation as a separate entity on top of the countries dropdown.

@aerosol aerosol merged commit 518cdb3 into master Feb 27, 2024
4 checks passed
@aerosol aerosol deleted the shield-countries branch February 27, 2024 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deploy-to-staging Special label that triggers a deploy to a staging environment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants