Commit Graph

18107 Commits

Author SHA1 Message Date
Javi Martín
44e3a393a0 Move navigation and footer partials to components
This way it'll be easier to decide when they should be rendered.

In order to be consistent, we're using the `Layout` module for both
components; previously, the navigation partial was in the `shared`
folder while the footer partial was in the `layout` folder, which IMHO
didn't make much sense.
2023-01-16 14:22:23 +01:00
Javi Martín
64536f069c Extract component for account/admin menu links
This way we remove the duplication in the layouts which had these links.

Since we're now passing the `current_user` option to partials in all
cases, IMHO the code is easier to follow if we use the
`Layout::NotificationItemComponent` instead of its partial.
2023-01-16 14:22:23 +01:00
Javi Martín
ca28a31ee5 Extract method in admin header component 2023-01-16 14:22:23 +01:00
Javi Martín
86fd14f8f0 Move admin header partial to a component
This way it's easier to refactor it.

Note we're using `with_request_url` in the tests because the component
renders the locale switcher, which needs a URL in order to work. This
doesn't affect whether we're in the management section or not.
2023-01-16 14:22:13 +01:00
Senén Rodero Rodríguez
569138cbae Extract view into component 2023-01-16 13:36:31 +01:00
Javi Martín
7b30ab7e61 Merge pull request #4967 from consul/dependabot/bundler/master/rubocop-performance-1.14.3
Bump rubocop-performance from 1.11.4 to 1.14.3
2023-01-12 16:57:07 +01:00
decabeza
717845ff1a Change poll button if results or stats are enabled 2023-01-12 15:19:10 +01:00
Javi Martín
d27bfb2afd Merge pull request #5062 from consul/admin_menu_links
Move admin menu methods to the component
2023-01-12 15:03:36 +01:00
Javi Martín
b74d82e17b Fix extra space in admin menu code
Rubocop wasn't warning us about because I guess it thought we were
trying to align these elements.
2023-01-12 14:07:52 +01:00
Javi Martín
dbca3b5342 Move admin menu methods to the component
This way we finish what we started in commit 1046ec5e7, making the menu
easier to customize.
2023-01-12 13:45:10 +01:00
Javi Martín
e3b3a8b87a Remove no longer needed style in admin menu
We don't need it since we removed the `is-active` class in submenu items
in commit 55d2cfe5b.
2023-01-12 13:36:26 +01:00
Javi Martín
efc46fe6c8 Add Performance/StringIdentifierArgument rule
It was added in rubocop-performance 1.13.0. We were already applying it
in most places.

We aren't adding it for performance reasons but in order to make the
code more consistent.
2023-01-11 16:05:20 +01:00
dependabot[bot]
5655702c49 Bump rubocop-performance from 1.11.4 to 1.14.3
Bumps [rubocop-performance](https://github.com/rubocop/rubocop-performance) from 1.11.4 to 1.14.3.
- [Release notes](https://github.com/rubocop/rubocop-performance/releases)
- [Changelog](https://github.com/rubocop/rubocop-performance/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop-performance/compare/v1.11.4...v1.14.3)

---
updated-dependencies:
- dependency-name: rubocop-performance
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-11 16:05:17 +01:00
Javi Martín
b717bfbbda Merge pull request #4978 from consul/remove_github_changelog_generator
Remove Github Changelog Generator dependency
2023-01-11 15:56:26 +01:00
Javi Martín
becd0acff1 Remove Github Changelog Generator dependency
Unfortunately this gem no longer works on our repository because it
reaches a request limit:

Octokit::TooManyRequests
403 - You have exceeded a secondary rate limit. Please wait a few
minutes before you try again.
See: https://docs.github.com/en/free-pro-team@latest/rest/overview/resources-in-the-rest-api#secondary-rate-limits

We can still use github_fast_changelog, which can be run locally without
being included as a dependencly, to help us update our CHANGELOG.
2023-01-11 15:38:46 +01:00
Javi Martín
30edfbcea6 Merge pull request #4878 from consul/verification_info
Show verification info only if verification is enabled
2023-01-10 15:01:06 +01:00
Javi Martín
00849f500b Merge pull request #5059 from consul/dependabot/bundler/httparty-0.21.0
Bump httparty from 0.20.0 to 0.21.0
2023-01-04 16:13:27 +01:00
Javi Martín
f1387092e8 Don't use line-height to set verified text margin
Using line-height is confusing and has unexpected results when texts
span over multiple lines, as might be the case in some language and
screen resolution combinations.
2023-01-04 16:06:29 +01:00
Javi Martín
6cc2003e1f Fix contrast in account verified text
The contrast value was 1.75, which makes the text hard to read and it
isn't even near to the minimum accessibility requirements.

We're using the `$color-success` variable since the `$check` color is
green and this one is green too.
2023-01-04 16:06:29 +01:00
Javi Martín
3938f4ff95 Render account verified icon using CSS
As mentioned in commit 925f04e3f, icon classes make screen readers
announce strange symbols and aren't properly displayed for people who
have changed their preferred font family.
2023-01-04 16:06:29 +01:00
decabeza
d59d02ba83 Show verification info only if verification is enabled 2023-01-04 16:06:29 +01:00
Javi Martín
3f664e4ccd Don't ask verified users to verify their account
It was strange to tell users they need to verify their account in order
to perform all available actions when they've already verified their
account.
2023-01-04 16:06:29 +01:00
Javi Martín
1ecd422f7f Extract component to render verification info
We're also adding tests showing the current behavior, which we're about
to change.
2023-01-04 16:06:29 +01:00
dependabot[bot]
ac7dc058ab Bump httparty from 0.20.0 to 0.21.0
Bumps [httparty](https://github.com/jnunemaker/httparty) from 0.20.0 to 0.21.0.
- [Release notes](https://github.com/jnunemaker/httparty/releases)
- [Changelog](https://github.com/jnunemaker/httparty/blob/master/Changelog.md)
- [Commits](https://github.com/jnunemaker/httparty/compare/v0.20.0...v0.21.0)

---
updated-dependencies:
- dependency-name: httparty
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-04 15:52:14 +01:00
Senén Rodero
f9ec038671 Merge pull request #5048 from consul/tenant_administrator
Create an administrator in new tenant
2022-12-29 16:31:38 +01:00
taitus
951eec7d08 Copy the main tenant administrator login credentials into the new tenant
Co-Authored-By: Senén Rodero <senenrodero@gmail.com>
2022-12-29 15:43:16 +01:00
Javi Martín
171cf4e634 Merge pull request #5050 from consul/hide_tenants
Make it possible to disable tenants
2022-12-28 15:06:49 +01:00
Javi Martín
25435b0297 Make it possible to disable tenants
Note we could use `acts_as_paranoid` with the `without_default_scope`
option, but we aren't doing so because it isn't possible to consider
deleted records in uniqueness validations with the paranoia gem [1].
I've added tests for these cases so we don't accidentally add
`acts_as_paranoid` in the future.

Also note we're extracting a `RowComponent` because, when
enabling/disabling a tenant, we're also enabling/disabling the link
pointing to its URL, and so we need to update the URL column after the
AJAX call.

[1] See issues 285 and 319 in https://github.com/rubysherpas/paranoia/
2022-12-28 14:34:00 +01:00
Javi Martín
0dac6ead77 Raise an exception when accessing a domain as subdomain
We were returning `nil` in this case, meaning we would be accessing the
main tenant in this situation instead of returning "Not Found".
2022-12-28 14:34:00 +01:00
Javi Martín
0d18e25e99 Extract component to render a switch
We're going to use it in other places.
2022-12-28 14:34:00 +01:00
Javi Martín
72704d7761 Use separate actions to enable/disable budget phases
This is consistent with the way we use separate actions to hide and
restore records, which is similar to enabling and disabling a record. We
might do something similar with the `toggle_selection` actions in the
future. For now, we're only doing it with budget phases because we're
going to add a similar switch control to hide and restore tenants.

We're also making these actions idempotent, so sending many requests to
the same action will get the same result, which wasn't the case with the
`toggle` action. Although it's a low probability case, the `toggle`
action could result in disabling a phase when trying to enable it if
someone else has enabled it between the time the page loaded and the
time the admin clicked on the "enable" button.
2022-12-28 14:34:00 +01:00
Javi Martín
3e7b68c544 Merge pull request #5053 from consul/ruby_2.7.7
Upgrade Ruby to version 2.7.7
2022-12-28 14:26:49 +01:00
Esther Nass
9616637aa4 Merge pull request #5056 from consul/consul_democracy_logo
Update consul democracy logo
2022-12-22 15:17:06 +01:00
decabeza
41dd51b189 Update consul democracy logo 2022-12-22 12:42:58 +01:00
Javi Martín
47a5840c70 Upgrade Ruby to version 2.7.7
So get the latest fixes in the 2.7.x series.

We're also updating the parser gem so we don't get any warnings.
2022-12-21 15:57:02 +01:00
Senén Rodero
fc0bb21821 Merge pull request #5052 from consul/tenant_not_found_exception
Do not track `Apartment::TenantNotFound` exceptions through `Airbrake`
2022-12-20 17:20:47 +01:00
Senén Rodero Rodríguez
e08d287ef8 Do not track Apartment::TenantNotFound exceptions through Airbrake
As we do with `ActiveRecord::NotFound` exceptions. Otherwise, we
can quickly flood the third-party application in charge of tracking
exceptions.
2022-12-20 16:46:00 +01:00
Javi Martín
d63efc7815 Merge pull request #5046 from consul/tenant_url
Use the tenant URL as a link to the tenant
2022-12-15 13:20:07 +01:00
Javi Martín
f70e3fae6e Merge pull request #5047 from consul/dependabot/bundler/rails-html-sanitizer-1.4.4
Bump rails-html-sanitizer from 1.4.3 to 1.4.4
2022-12-14 18:34:38 +01:00
dependabot[bot]
f705eecc19 Bump rails-html-sanitizer from 1.4.3 to 1.4.4
Bumps [rails-html-sanitizer](https://github.com/rails/rails-html-sanitizer) from 1.4.3 to 1.4.4.
- [Release notes](https://github.com/rails/rails-html-sanitizer/releases)
- [Changelog](https://github.com/rails/rails-html-sanitizer/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rails/rails-html-sanitizer/compare/v1.4.3...v1.4.4)

---
updated-dependencies:
- dependency-name: rails-html-sanitizer
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-14 18:18:31 +01:00
Javi Martín
6506f8d7cf Merge pull request #5045 from consul/dependabot/bundler/loofah-2.19.1
Bump loofah from 2.18.0 to 2.19.1
2022-12-14 18:17:51 +01:00
dependabot[bot]
892db0a1a4 Bump loofah from 2.18.0 to 2.19.1
Bumps [loofah](https://github.com/flavorjones/loofah) from 2.18.0 to 2.19.1.
- [Release notes](https://github.com/flavorjones/loofah/releases)
- [Changelog](https://github.com/flavorjones/loofah/blob/main/CHANGELOG.md)
- [Commits](https://github.com/flavorjones/loofah/compare/v2.18.0...v2.19.1)

---
updated-dependencies:
- dependency-name: loofah
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-14 17:59:17 +01:00
Javi Martín
41c01da133 Merge pull request #5044 from consul/dependabot/bundler/nokogiri-1.13.10
Bump nokogiri from 1.13.9 to 1.13.10
2022-12-14 17:57:32 +01:00
dependabot[bot]
dc00b3ca8d Bump nokogiri from 1.13.9 to 1.13.10
Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.13.9 to 1.13.10.
- [Release notes](https://github.com/sparklemotion/nokogiri/releases)
- [Changelog](https://github.com/sparklemotion/nokogiri/blob/main/CHANGELOG.md)
- [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.13.9...v1.13.10)

---
updated-dependencies:
- dependency-name: nokogiri
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-14 17:04:55 +01:00
Javi Martín
7bcdb6a9db Use the tenant URL as a link to the tenant
In general, we don't use links inside admin tables because we don't know
where the link will point to, and use "view" actions/links instead.

However, in this case, we're showing a URL, so it's perfectly obvious
where the link will point to. And so it makes sense to use the URL as a
link instead of using a "view" action/link.
2022-12-14 13:52:26 +01:00
Senén Rodero
b5f1b64d8a Merge pull request #5040 from consul/i18n_crowdin
Update translations from Crowdin
2022-12-13 17:08:52 +01:00
Javi Martín
09b9d2b88e Merge pull request #5007 from consul/tenant_domains
Allow using domains in tenants
2022-12-13 13:33:15 +01:00
Javi Martín
e1e16d21c3 Allow having tenants with different domains
Some institutions using CONSUL have expressed interest in this feature
since some of their tenants might already have their own domains.

We've considered many options for the user interface to select whether
we're using a subdomain or a domain, like having two separate fields,
using a check box, ... In the end we've chosen radio buttons because
they make it easier to follow a logical sequence: first you decide
whether you're introducing a domain or subdomain, and then you enter it.

We've also considered hiding this option and assuming "if it's got a
dot, it's a domain". However, this wouldn't work with nested subdomains
and it wouldn't work with domains which are simply machine names.

Note that a group of radio buttons (or check boxes) is difficult to
style when the text of the label might expand over more than one line
(as is the case here on small screens); in this case, most solutions
result in the second line of the label appearing immediately under the
radio button, instead of being aligned with the first line of the label.
That's why I've added a container for the input+label combination.
2022-12-13 13:10:02 +01:00
Javi Martín
e9c2776252 Don't create schemas in model tests unless needed
Creating a schema takes about 3-4 seconds on my machine, so omitting
the callbacks makes tests much faster.

To do so, we're using the `insert!` method added in Rails 6.0, which
inserts a record without executing callbacks or validations. To make the
tests look consistent, we're adding a FactoryBot strategy which uses
`insert!` instead of `create!`.

Note this strategy is useless in most cases because it doesn't work when
models have translatable attributes or associations. However, IMHO it's
worth it even if we only use it for tenants.

We could also use `Tenant.insert!` instead, but then we would have to
add all the mandatory attributes, and in this case the code is clearer
if we only add the attributes we need for the test.
2022-12-13 13:10:02 +01:00
Javi Martín
50076870eb Merge pull request #5041 from consul/not_found_tenants
Respond with not found on missing tenants
2022-12-12 11:49:55 +01:00