Commit Graph

18014 Commits

Author SHA1 Message Date
Javi Martín
3b125d9cfc Simplify styles for the remote translations button
We can use the `link` mixin. Note this mixin uses anchor-color instead
of brand-color; by default, they're both the same, so we probably meant
anchor-color here.
2023-02-16 17:24:34 +01:00
Javi Martín
fb2b88b10a Simplify styles for the remote translations message
Instead of adding all the styles of a callout and then overwriting half
of them, we can simply add the half we need.
2023-02-16 17:24:34 +01:00
Javi Martín
9bca73bc8b Fix background width in remote translations message
The `overflow: hidden` applied to the `.callout` selector made the full
width background invisible, meaning this section hasn't looked properly
on very large screens since  commit 701378d02.
2023-02-16 17:24:34 +01:00
Javi Martín
1778a7563b Use CSS to define alignment in translations message
That way it's possible to override the style without changing the HTML,
which is the hardest code to customize and maintain.
2023-02-16 17:24:34 +01:00
Javi Martín
efc69e8663 Extract component for remote translations button
So we're consistent with the rest of the code in the header, which
renders components and not partials.
2023-02-16 17:24:34 +01:00
Javi Martín
bbd4d3e62d Render components instead of partials in headers
We were using partials to render components in order to ease the
transition of custom code from earlier versions of Consul. However,
that was back in Consul 1.4, and now these views looked a bit messy
since they sometimes rendered components and sometimes they
rendered partials.
2023-02-16 17:24:34 +01:00
Javi Martín
2ac338f51a Remove redundant admin-top-bar element
We weren't using the `admin-top-bar` class since commit e6c1cf774, and
we can always use the `.admin .top-bar` selector if we need to. And the
`row expanded` classes basically give an element a width of 100%, which
is already the default width for block elements.
2023-02-16 17:24:34 +01:00
Javi Martín
49cb6e010b Extract component to render the responsive menu
We were using the same code for the button in both the public and admin
headers, so we're removing the duplication.

Since the menu and the button must go together, and the contents of the
menu are different for different layouts, we're passing these contents
using a block.

Note the ID of the menu was `responsive-menu` in the public section but
`responsive_menu` in the admin section. Since we usually use underscores
for IDs and dashes for classes, we're keeping the one with the
underscore.
2023-02-16 17:24:34 +01:00
Javi Martín
b489923f66 Move menu button to the left in the admin section
So now it uses the same interface and styles as the main layout. On
small screens, it's easier to play with the menu when the button is on
the left because the menu it opens is aligned to the left.

Note that now we can get rid of the title-bar class; we didn't use the
styles in the public area since commit dcec003d0, and we were overriding
all the Foundation styles in the admin area with the exception of the
padding, which we no longer need.
2023-02-16 17:24:34 +01:00
Javi Martín
b50b7ad64a Adjust order of elements on small screens
We're changing the order of the elements in the HTML so the menu button
appears next to the menu it opens, with no logo between them, which IMHO
makes sense and makes it easier to understand the layout for people
using screen readers.

A small advantage of this approach is that on very narrow screens or
Consul applications having a very long word for "Menu", the menu button
appeared on top, the logo appeared below it, and the contents of the
menu appeared below the logo. Now the logo appears on top, the menu
button appears below it, and the contents of the menu appear below the
menu button.
2023-02-16 17:24:34 +01:00
Javi Martín
045ac648d7 Fix menu on "wide" small screens
The menu didn't look properly on these screens since commit dcec003d0.

On small screens with enough horizontal space to show the menu button,
the logo, and the contents of the menu, all three elements were shown on
the same row, which looked broken.

Now the contents of the menu are shown below the menu button.

Note that, to force this, we're making the contents of the menu 100%
wide. That means links would take the 100% of the space, which would
make it easy to click on a link while trying to scroll when using
touchscreens. So we're making the links as wide as their text, which
also has a disadvantage: it's harder to click on narrow links like
"SDG".
2023-02-16 17:24:34 +01:00
Javi Martín
86dd34d32e Don't load Foundation styles for the top-bar
We're going to change these styles in order to fix a bug, and the
Foundation styles were getting in the way. Besides, we were overwriting
some rules and so now we're removing 6 properties while we're also
adding 6, so it isn't like the Foundation styles were helping us.
2023-02-16 17:24:24 +01:00
Javi Martín
c553e15a90 Remove usage of top-bar-left class
We don't need it since it's only used for flexbox styles, and we
already have a `flex-grow` rule for the `h1` element which does the
same thing.
2023-02-16 17:07:20 +01:00
Javi Martín
6b01dc53da Remove unused style inside top-bar-left
There isn't a `ul` element here, so this rule doesn't apply.
2023-02-16 17:07:20 +01:00
Javi Martín
70161720a0 Remove usages of the top-bar-right class
This is one of Foundation's classes that only applies when its
parent element is a flex container, which isn't the case here since
commit dcec003d0.
2023-02-16 17:07:20 +01:00
Javi Martín
3e5039d72c Remove usage of the top-bar-title class
This class was only there in order to use Foundation's styles, but
the amount of styles we were using was equal to the amount of
styles we were overwriting.
2023-02-16 17:07:20 +01:00
Javi Martín
d0fcc9022f Move menu and navigation styles to their own files
This way we follow the convention of one stylesheet per component.
Note that we depend on Foundation's `menu` class for some of the
styles and JavaScript behavior, so we're keeping both the `menu` and
`account-menu` classes.
2023-02-16 17:07:20 +01:00
Senén Rodero
3e8c4c4e61 Merge pull request #4937 from consul/dependabot/bundler/master/airbrake-13.0.2
Bump airbrake from 11.0.3 to 13.0.2
2023-02-03 19:01:06 +01:00
Javi Martín
76b47c3e42 Merge pull request #4992 from consul/proposal_image
Fix image size on proposals list
2023-02-03 18:06:32 +01:00
dependabot[bot]
b6e9a3c2f9 Bump airbrake from 11.0.3 to 13.0.2
Bumps [airbrake](https://github.com/airbrake/airbrake) from 11.0.3 to 13.0.2.
- [Release notes](https://github.com/airbrake/airbrake/releases)
- [Changelog](https://github.com/airbrake/airbrake/blob/master/CHANGELOG.md)
- [Commits](https://github.com/airbrake/airbrake/compare/v11.0.3...v13.0.2)

---
updated-dependencies:
- dependency-name: airbrake
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-03 17:53:54 +01:00
decabeza
01bf16fa46 Fix image size on proposals list 2023-02-03 17:42:00 +01:00
Senén Rodero
e147408ebd Merge pull request #5064 from consul/managment_print_budgets
Allow printing investments from any budget in the management interface
2023-02-03 15:46:27 +01:00
Senén Rodero
8c2db5cc27 Merge pull request #5061 from consul/managment_concurrent_budgets
Show published budgets in the valuation panel
2023-02-03 14:56:57 +01:00
Javi Martín
1212961454 Merge pull request #5058 from consul/poll_results_button
Change poll button if results or stats are enabled
2023-02-03 14:40:04 +01:00
Senén Rodero Rodríguez
96f584c4f7 Allow printing investments from any budget in the management interface 2023-02-03 12:18:13 +01:00
Senén Rodero Rodríguez
cdd26dd568 Fix access restriction in valuation budget investments controller
Since we allow many active budgets at the same time, the
controller should now check the budget given by params.

Before this change the controller was checking the latest
published budget, ignoring the request parameter `budget_id`.
2023-02-03 11:01:41 +01:00
Senén Rodero Rodríguez
0c09fd22af Do not show the Evaluate link when there are no projects to evaluate for current valuator 2023-02-03 11:01:41 +01:00
Senén Rodero Rodríguez
615b249144 Count only the investments visible and assigned to current valuator
It has more sense to show the count of the investments the
valuator is going to find in the investments valuation page.
2023-02-03 11:01:41 +01:00
Senén Rodero Rodríguez
282b8f8697 Load all the published budgets in the valuation interface
As now multiple budget can coexist at the same time it has sense to be able to
browse all the published budgets in the valuation budgets index page.
2023-02-03 11:01:41 +01:00
Senén Rodero Rodríguez
ee80b3f4a2 Extract valuation budget index view to components 2023-02-03 11:01:41 +01:00
Senén Rodero
2527c0e3c2 Merge pull request #5076 from consul/custom_mailers
Allow to add custom mailers
2023-02-01 17:52:53 +01:00
Senén Rodero Rodríguez
4d9814218e Allow to add custom mailers
In the same way we do for models, controllers ...
2023-01-31 18:18:49 +01:00
Javi Martín
082e009272 Merge pull request #5069 from consul/typos_pages_index
Fix dates in custom pages admin index
2023-01-31 17:08:53 +01:00
Javi Martín
15f31a9d25 Merge pull request #5070 from consul/ruby_3_warnings
Fix warnings in Ruby 2.7 and Ruby 3.0
2023-01-31 14:39:56 +01:00
Javi Martín
a4d6e232fa Enable deprecation warnings in test and development
Now that we've got rid of all the warnings we had, we can enable them so
we'll notice new warnings when we introduce them.

This was the default option until Ruby 2.7.2 was released [1]. These
warnings were turned off by default because pretty much every Ruby gem
had dozens of warnings with Ruby 2.7 due to the changes in the way Ruby
handles keyword arguments.

[1] https://www.ruby-lang.org/en/news/2020/10/02/ruby-2-7-2-released/
2023-01-26 17:58:55 +01:00
Javi Martín
e19205cfe5 Use variables instead of constants in dev seeds
While running the `dev_seed` twice, as we do in the tests, we were
getting the following warnings:

```
db/dev_seeds/proposals.rb:1: warning: already initialized constant
IMAGE_FILES

db/dev_seeds/budgets.rb:1: warning: already initialized constant
INVESTMENT_IMAGE_FILES
```

So we're extracting a method which allows us to use local variables
while removing duplication.

We had this warning with every version of Ruby, not just Ruby 2.7, but
since we're getting rid of all the warnings, we're taking care of this
one as well.
2023-01-26 17:58:12 +01:00
Javi Martín
5e7b3f72a2 Use File.exist? instead of File.exists?
We've noticed the following warning while testing the upgrade to
Ruby 3.0:

warning: File.exists? is deprecated; use File.exist? instead

We're adding a Rubocop rule so we don't call the deprecated method
in the future.
2023-01-26 17:21:19 +01:00
Javi Martín
023bc6eb59 Fix keyword args in random_locales_attributes calls
We were passing a hash when the method definition expected keyword
arguments, and so we were getting warnings in Ruby 2.7:

```
db/dev_seeds/widgets.rb:11: warning: Using the last argument as keyword
parameters is deprecated; maybe ** should be added to the call

db/dev_seeds/widgets.rb:23: warning: Using the last argument as keyword
parameters is deprecated; maybe ** should be added to the call

db/dev_seeds/widgets.rb:35: warning: Using the last argument as keyword
parameters is deprecated; maybe ** should be added to the call

db/dev_seeds/widgets.rb:47: warning: Using the last argument as keyword
parameters is deprecated; maybe ** should be added to the call

db/dev_seeds/admin_notifications.rb:3: warning: Using the last argument
as keyword parameters is deprecated; maybe ** should be added to the
call

db/dev_seeds/admin_notifications.rb:11: warning: Using the last argument
as keyword parameters is deprecated; maybe ** should be added to the
call

db/dev_seeds/admin_notifications.rb:19: warning: Using the last argument
as keyword parameters is deprecated; maybe ** should be added to the
call

db/dev_seeds/admin_notifications.rb:27: warning: Using the last argument
as keyword parameters is deprecated; maybe ** should be added to the
call
```

Converting the hash to keyword arguments solves the issue.
2023-01-26 17:21:19 +01:00
Javi Martín
b341debdff Update calls to within_fieldset with keyword args
We were getting a warning with Ruby 2.7:

```
ruby/gems/2.7.0/gems/capybara-3.37.1/lib/capybara/session.rb:377:
warning: Using the last argument as keyword parameters is deprecated;
maybe ** should be added to the call
```

On Ruby 3.0, the test failed with `Unable to find fieldset
{:text=>"Draft phase"}` and we were also getting another warning:

```
Locator Hash:{:text=>"Draft phase"} for selector :fieldset must be an
instance of String or Symbol. This will raise an error in a future
version of Capybara
```
2023-01-26 17:21:12 +01:00
Javi Martín
3fe65bafd1 Use keyword arguments in mappable specs
We were getting a warning with Ruby 2.7 due to the change in the way
keyword arguments are handled in Ruby 3.0.

```
ruby/gems/2.7.0/gems/rspec-support-3.11.0/lib/rspec/support/with_keywords_when_needed.rb:18:
warning: Passing the keyword argument as the last hash parameter is
deprecated
```

As hinted by the warning, this code crashes with Ruby 3.0:

```
ArgumentError:
  unknown keyword: :budget_id
```

I'm not sure why this is the case, though, since we were already
explicitely passing a hash first before passing the keyword parameters.
I guess there are some cases in this whole keyword VS hash parameters
incompatibility that I haven't completely understood.
2023-01-26 17:19:15 +01:00
Javi Martín
5c2ca27df1 Update Globalize monkey-patch to forward kw args
This method changed in Globalize version 6.0.1 [1], which we're using since
commit 6072372c9d.

We were getting a deprecation warning in Ruby 2.7:

```
config/initializers/globalize.rb:8: warning: Using the last argument as
keyword parameters is deprecated; maybe ** should be added to the call
```

So we're using the `(...)` arguments syntax to make it compatible with
Ruby 3.0, just like Globalize does when using Ruby 2.7.

[1] See pull request 778 in the globalize/globalize GitHub repo.
2023-01-26 17:19:15 +01:00
Javi Martín
dffe7966f6 Fix keyword arguments in action components calls
We were passing a hash of options instead of converting them to keyword
parameters, which resulted in warnings on Ruby 2.7:

```
app/components/admin/table_actions_component.html.erb:5: warning: Using
the last argument as keyword parameters is deprecated; maybe ** should
be added to the call

app/components/admin/table_actions_component.html.erb:9: warning: Using
the last argument as keyword parameters is deprecated; maybe ** should
be added to the call

app/components/admin/widget/cards/row_component.html.erb:20: warning:
Using the last argument as keyword parameters is deprecated; maybe **
should be added to the call

app/components/admin/widget/cards/table_component.html.erb:14: warning:
Using the last argument as keyword parameters is deprecated; maybe **
should be added to the call
```
2023-01-26 17:19:15 +01:00
Javi Martín
a75a2894ce Make link_list compatible with Ruby 3 keyword args
We were using an optional parameter followed by keyword parameters,
which caused a warning with Ruby 2.7:

```
app/components/shared/link_list_component.rb:20: warning: Using the last
argument as keyword parameters is deprecated; maybe ** should be added
to the call
```

I've tried to make `current:` a named parameter as well and then change
all method calls to `link_list`, but was still getting the same warning.
Might have something to do with the fact that we're dealing with arrays
with hashes inside them instead of passing the keyword arguments
directly to the method.
2023-01-26 17:19:15 +01:00
Javi Martín
1839e9dded Merge pull request #5067 from consul/rails-6.0.6.1
Bump rails from 6.0.5.1 to 6.0.6.1
2023-01-26 15:37:45 +01:00
Javi Martín
119f64ac44 Fix dates in custom pages admin index
We weren't showing the year when a page was created/updated, and we
were displaying the created date instead of the updated one.

Co-Authored-By: Diego Calvo <diego.calvo@enreda.coop>
2023-01-22 17:15:12 +01:00
Javi Martín
d5f440c9bb Simplify header in custom pages admin index
Now that we're using a component, we can reuse the Header module.
2023-01-22 17:14:35 +01:00
Javi Martín
f9d334fb36 Move admin pages index to a component
This way it'll be easier to write tests for it.
2023-01-22 16:32:34 +01:00
Javi Martín
81f0c90aba Bump Rails from 6.0.5.1 to 6.0.6.1
This version fixes a security issue in ActiveRercord [1].

[1] https://discuss.rubyonrails.org/t/cve-2023-22794-sql-injection-vulnerability-via-activerecord-comments/82117
2023-01-20 16:19:49 +01:00
Javi Martín
854f20016e Merge pull request #5066 from consul/dependabot/bundler/globalid-1.0.1
Bump globalid from 1.0.0 to 1.0.1
2023-01-20 16:19:05 +01:00
dependabot[bot]
92af75bdef Bump globalid from 1.0.0 to 1.0.1
Bumps [globalid](https://github.com/rails/globalid) from 1.0.0 to 1.0.1.
- [Release notes](https://github.com/rails/globalid/releases)
- [Commits](https://github.com/rails/globalid/compare/v1.0.0...v1.0.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-20 16:01:50 +01:00