Commit Graph

16247 Commits

Author SHA1 Message Date
decabeza
428c1695f2 Add new styles for admin tables 2021-02-18 15:46:16 +01:00
decabeza
a45ab81885 Fix SCSS-Lint QualifyingElement warning 2021-02-18 15:46:16 +01:00
Javi Martín
e266e0e0e2 Simplify code to display text of new notifications
We couldn't do this refactoring earlier because we weren't using the
unread notifications count. This was fixed in the previous commit.
2021-02-18 14:45:48 +01:00
Javi Martín
fb88e0b77c Fix number of new notifications
We were displaying the total number of notifications with a message "You
have N unread notifications", but were using the total number of
notifications instead of the unread ones.
2021-02-18 14:45:48 +01:00
Javi Martín
0839c5ea75 Adjust new notifications icon position
It was hard to know where the numbers were coming from; they depended on
the padding of the link and the size of the notification icon size. So
we're using variables to make it more explicit.

However, the code is now too complex, so we'll probably have to simplify
it in the future.
2021-02-18 14:45:48 +01:00
Javi Martín
4c289f2489 Simplify notification item HTML
Other than simplifying the view, we can write tests using `click_link`,
which makes the tests more robust. Clicking the `.icon-notification`
element was causing some tests to fail when defining a window height of
750 pixels in the `admin_budgets` branch.
2021-02-16 23:21:51 +01:00
Javi Martín
5b6551f6d7 Extract method to get the notifications link text 2021-02-16 00:01:10 +01:00
Javi Martín
f11f2cd3dd Extract component to render notifications item 2021-02-16 00:00:49 +01:00
Javi Martín
b6c269008f Merge pull request #4358 from consul/sdg_related_list_fieldest
Improve goals/targets selector accessibility
2021-02-15 16:12:15 +01:00
Javi Martín
ab2b3a2671 Improve help messages in SDG selector
Hopefully now it's a bit more obvious that SDGs can be selected by
clicking on them and that the field to select goals and the field to
select targets/goals are related (since they're now part of the same
fieldset).
2021-02-15 15:48:25 +01:00
Javi Martín
6ecb6757a6 Use real check boxes to select goals
We were using list items with the checkbox role. This is probably
confusing since list items have a listitem role, and so we were
basically using a list with no listitem.

We could add a `<span role="checkbox">` tag inside the list item, but
using real checkboxes is probably easier. We're also adding a test to
verify the checkboxes native behavior is compatible with our code.

Note we're using the "enter" key to toggle the "checked" status of the
SDG. This is probably not intuitive for screen reader users who might
try to submit the form using the "enter" key after selecting a goal.

However, the alternative would be even less intuitive for sighted
keyboard users, since for them these icons look like links or buttons
and they would accidentally submit the form when trying to select a
goal.

Since we haven't come up with a better interface yet, for now we're
following the principle of least damage; we consider submitting the form
against a user's will is less annoying than forcing users to move to a
different field before being able to submit the form.

Also note we can't write `check` in the tests because Capybara will try
to click the checkbox, which is hidden by the image in the label.
2021-02-15 15:48:25 +01:00
Javi Martín
6ab78a5290 Merge pull request #4357 from consul/fix_tags_in_forms
Fix tags styles in forms
2021-02-15 15:36:15 +01:00
Javi Martín
7eea641163 Merge pull request #4352 from consul/google_icon
Use google icon in sign in page
2021-02-15 15:00:46 +01:00
Javi Martín
e6437bb896 Fix tags styles in forms
These styles were broken in commit 2614de79c, since there we only
considered scenarios where the `tags` element is a list. In these forms, however, the `tags` element is a regular <div> tag.
2021-02-14 18:56:52 +01:00
Javi Martín
7ce61ced85 Use font awesome in social share icons
Since we've changed the facebook and twitter login icons, it makes sense
to use the same icons in social share links.

Besides, using font-awesome simplifies the code and prevents problems
with screen readers announcing the value of the `content:` CSS property.
2021-02-14 14:57:13 +01:00
Javi Martín
741f2fc141 Use icon width variable in SSB icons
The font size and the line-height were chosen according to the width of
the icon; we're now making it clear.
2021-02-14 14:42:40 +01:00
Javi Martín
60c3fd2fff Use google icon in sign in page
We were using the icon for google plus, which was confusing since google
plus no longer exists.

Note this change requires changing the font for these icons, since the
google icon is not present in the "icons" font. On the plus side, using
the font awesome icons we can simplify the code a little bit.
2021-02-09 19:12:47 +01:00
Javi Martín
b867243e83 Remove redundant background property
The property is overwritten for each icon.
2021-02-09 19:00:04 +01:00
Javi Martín
3ce86078e1 Remove unused styles for button-telegram
We only use the button-* classes in the sign in form, and there's no
"Sign in through Telegram" feature.
2021-02-09 18:19:17 +01:00
Javi Martín
a3675a8a24 Merge pull request #4350 from consul/flaggable_specs
Try to avoid exceptions after flaggable tests
2021-02-09 17:18:32 +01:00
Javi Martín
7489f16633 Try to avoid exception after flaggable tests
We had one exception running test suite [1]:

```
  1) Commenting legislation questions Merged comment threads View
comments of annotations in an included range
     Failure/Error: count: annotation.comments.roots.count) %>

     ActionView::Template::Error:
       PG::ProtocolViolation: ERROR:  bind message supplies 0
parameters, but prepared statement "" requires 2
       : SELECT COUNT(*) FROM "comments" WHERE "comments"."hidden_at" IS
NULL AND "comments"."commentable_id" = $1 AND
"comments"."commentable_type" = $2 AND "comments"."ancestry" IS NULL
```

Debugging shows this test was run right after the flaggable specs.
There's a chance these exceptions take place because the test is
accessing the database after the browser (chromedriver) process has
already accessed the database.

This is just an attempt at fixing the issue; I don't know whether these
changes will fix it since I've only seen this exception on Github
Actions (never on my machine). Worst case scenario, we're encouraging
good practices of system tests: test things from the user's point of
view.

[1] https://github.com/consul/consul/runs/1856245992
2021-02-08 20:23:08 +01:00
Javi Martín
5e01664ed7 Merge pull request #4348 from consul/columns_button
Allow toggling the column selector with a keyboard
2021-02-08 20:13:30 +01:00
Javi Martín
5569663308 Use aria-expanded on column selector toggle button
This way screen reader users will be informed about what happens when
the button is clicked. We also simplify the HTML/JavaScript a little
bit.
2021-02-08 19:57:42 +01:00
Javi Martín
00dfa95902 Allow toggling the column selector with a keyboard
Using a button tag, it's possible for every user to "click" the element.
Besides, we don't need to call the `preventDefault` function, because
buttons with type "button" don't do anything by default.
2021-02-08 19:57:42 +01:00
Javi Martín
945d723fef Merge pull request #4349 from consul/fix_budget_polls_spec
Fix flaky budget polls voting spec
2021-02-08 17:01:38 +01:00
Javi Martín
2bca1eccbf Merge pull request #4101 from consul/dependabot/bundler/social-share-button-1.2.3
Bump social-share-button from 1.1.0 to 1.2.3
2021-02-08 17:00:06 +01:00
Javi Martín
aed38aa3cf Fix styles for mobile icons in featured proposals
We were only adding styles for facebook and twitter, meaning telegram
and whatsapp looked out of place.
2021-02-08 16:31:26 +01:00
Javi Martín
abc81b30be Simplify styles for SSB icons
By using the same selector used by the social-share-button gem, we can
remove all the !important rules.
2021-02-08 16:31:26 +01:00
Javi Martín
68260360ef Remove unused styles
As far as I can see, the `.jumbo-budget` never had social share button
elements inside it.
2021-02-08 16:31:26 +01:00
Javi Martín
780660afc7 Use the icon-width variable to set SSB icon size
The same way we use it for SDG icons.
2021-02-08 16:31:26 +01:00
Javi Martín
86cac524b2 Remove unnecessary <div> tag
The `proposal-show` HTML class was only used in this context to style
the whatsapp icon, which is now styled the same way as other social
share icons. The `proposal-show` class should be reserved for the actual
proposal show action.
2021-02-08 16:31:26 +01:00
Javi Martín
0d8119a1e3 Use social-share-button whatsapp icon
We were using a custom icon because in the past social-share-button
didn't have support for whatsapp. But now that it does, we can remove
our custom icon.

Note we're using the `_app` suffix because that's the name of the icon
meant for mobile devices.
2021-02-08 16:31:26 +01:00
Javi Martín
ae8afc9b75 Remove duplication in social share button styles
All buttons were using the same styles, so we might as well style them
together.
2021-02-08 16:31:26 +01:00
Javi Martín
c5a56214c6 Remove redundant social share button styles
These styles were defined twice in our layout stylesheet.
2021-02-08 16:31:25 +01:00
dependabot-preview[bot]
4a61fd2d8c Bump social-share-button from 1.1.0 to 1.2.3
Bumps [social-share-button](https://github.com/huacnlee/social-share-button) from 1.1.0 to 1.2.3.
- [Release notes](https://github.com/huacnlee/social-share-button/releases)
- [Changelog](https://github.com/huacnlee/social-share-button/blob/master/CHANGELOG.md)
- [Commits](https://github.com/huacnlee/social-share-button/compare/v1.1.0...v1.2.3)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-02-08 16:31:23 +01:00
Javi Martín
ef0494f09c Fix missing expectation in budget polls spec
We've had a failure in one of our test suite runs [1]. A possible cause
could be an HTTP request taking place at the same time as an AJAX
request, with both trying to access the database at the same time.

We've had several similar issues in the past which have been fixed by
checking the AJAX request has finished before requesting another page,
so we're applying the same principle here.

[1] https://github.com/consul/consul/runs/1855207922
2021-02-08 15:45:25 +01:00
Javi Martín
63820fb59f Merge pull request #4102 from consul/dependabot/bundler/erb_lint-0.0.35
Apply Rubocop rules in ERB files
2021-02-08 15:39:27 +01:00
Javi Martín
00656e2e10 Fix SpaceAroundErbTag offense 2021-02-08 15:18:56 +01:00
Javi Martín
b214205d8f Use Capybara to disable animations in tests
We were doing it manually, but Capybara offers an option which does the
exact same thing.

This way we also apply the NoJavascriptTagHelper ERB rule, which
reported one error in the `disable_animations_in_tests` partial.
2021-02-05 17:46:23 +01:00
Javi Martín
1c2886debb Remove redundant condition
The association `organization.user` returns `nil` when the user is
hidden.

This was discovered thanks to the `Style/AndOr` rule. We were using
`and` and `||` on the same line, which is confusing.
2021-02-05 17:46:23 +01:00
Javi Martín
e7ca01fad7 Apply Rails/Presence rule in ERB files 2021-02-05 17:46:23 +01:00
Javi Martín
82200c5d0b Apply ParenthesesAsGroupedExpression rule in ERB 2021-02-05 17:46:23 +01:00
Javi Martín
c1cf9f0c34 Apply Style/SymbolProc rule in ERB files 2021-02-05 17:46:23 +01:00
Javi Martín
cc2aa6de6e Apply Style/TrailingCommaInHashLiteral rule in ERB 2021-02-05 17:46:23 +01:00
Javi Martín
2eb255e85a Apply Rails/SafeNavigation rule in ERB files 2021-02-05 17:46:23 +01:00
Javi Martín
0911b89d16 Add name attribute to heading content blocks
This way we can simplify the code and don't have to rely on `.try`
statements which are confusing and so we don't allow them in the
`Rails/SafeNavigation` Rubocop rule.
2021-02-05 17:46:23 +01:00
Javi Martín
2d37a0396b Apply Layout/ExtraSpacing rule in ERB files
Note that in Ruby files this rule allows vertical alignment, but doesn't
seem to do the same in ERB. Since we only used vertical alignment in one
place, and that place also had an unneeded extra space on every aligned
line, I've decided to change the code in that place and follow the rule.
2021-02-05 17:46:23 +01:00
Javi Martín
4809a87a78 Apply Style/HashSyntax rule in ERB files 2021-02-05 17:46:23 +01:00
Javi Martín
67c6515405 Apply Style/CollectionMethods rule to ERB files 2021-02-05 17:46:23 +01:00
Javi Martín
32ef8ff301 Unify Ruby and ERB Rubocop rules
So now we remove duplication between .rubocop.yml and the rubocop rules
defined for erblint. Having the rules in two places led to some
mistakes, like renaming Layout/Tab to Layout/IndentationStyle in
`.rubocop.yml` but forgetting to do so in `.erb-lint.yml`.

This also means we can use the EnforcedStyle options for
Layout/SpaceInsideHashLiteralBraces in views as well.

We couldn't implement this feature earlier because it required Ruby 2.4
and due to incompatibilities between versions of erb_lint and versions
of rubocop.

There are some rules which do not apply to ERB files and so we're
disabling them.

* Layout/LineLength, Layout/TrailingEmptyLines and Lint/UselssAssignment
  generate false positives
* Rails/OutputSafety is redundant since its functionality is already
  covered by ERB Lint ErbSafety linter
2021-02-05 17:45:50 +01:00