From aec42b87b782554d06e468a963752cd41f3a7a98 Mon Sep 17 00:00:00 2001
From: Thomas Citharel
Date: Thu, 18 Jun 2020 15:23:05 +0200
Subject: [PATCH 1/2] Participation panel revamp and fixes
Apollo is a pain in the ass with pagination & filters, so this removes
the tabs system and uses a
- (rejectedPage = page)"
- />
-
-
-
-
+
+
-
diff --git a/lib/graphql/resolvers/event.ex b/lib/graphql/resolvers/event.ex
index 824c5e869..808de4fd3 100644
--- a/lib/graphql/resolvers/event.ex
+++ b/lib/graphql/resolvers/event.ex
@@ -92,7 +92,8 @@ defmodule Mobilizon.GraphQL.Resolvers.Event do
|> Enum.map(&String.to_existing_atom/1)
end
- {:ok, Events.list_participants_for_event(event_id, roles, page, limit)}
+ participants = Events.list_participants_for_event(event_id, roles, page, limit)
+ {:ok, participants}
else
{:is_owned, nil} ->
{:error, "Moderator Actor ID is not owned by authenticated user"}
@@ -115,17 +116,12 @@ defmodule Mobilizon.GraphQL.Resolvers.Event do
_args,
%{context: %{current_user: %User{id: user_id} = _user}} = _resolution
) do
- if Events.is_user_moderator_for_event?(user_id, event_id) do
- stats =
- Map.put(
- stats,
- :going,
- stats.participant + stats.moderator + stats.administrator + stats.creator
- )
+ going = stats.participant + stats.moderator + stats.administrator + stats.creator
- {:ok, stats}
+ if Events.is_user_moderator_for_event?(user_id, event_id) do
+ {:ok, Map.put(stats, :going, going)}
else
- {:ok, %EventParticipantStats{}}
+ {:ok, %{going: going}}
end
end
diff --git a/lib/mobilizon/events/events.ex b/lib/mobilizon/events/events.ex
index 4a942b78b..f9f01e6e5 100644
--- a/lib/mobilizon/events/events.ex
+++ b/lib/mobilizon/events/events.ex
@@ -752,7 +752,6 @@ defmodule Mobilizon.Events do
end
@moderator_roles [:moderator, :administrator, :creator]
- @default_participant_roles [:participant] ++ @moderator_roles
@doc """
Returns the list of participants for an event.
@@ -762,13 +761,14 @@ defmodule Mobilizon.Events do
Page.t()
def list_participants_for_event(
id,
- roles \\ @default_participant_roles,
+ roles \\ [],
page \\ nil,
limit \\ nil
) do
id
|> list_participants_for_event_query()
|> filter_role(roles)
+ |> order_by(asc: :role)
|> Page.build_page(page, limit)
end
diff --git a/lib/web/views/error_view.ex b/lib/web/views/error_view.ex
index d52d16fe3..398c8b954 100644
--- a/lib/web/views/error_view.ex
+++ b/lib/web/views/error_view.ex
@@ -4,11 +4,11 @@ defmodule Mobilizon.Web.ErrorView do
"""
use Mobilizon.Web, :view
alias Mobilizon.Service.Metadata.Instance
- alias Mobilizon.Web.PageView
+ import Mobilizon.Web.Views.Utils
- def render("404.html", _assigns) do
+ def render("404.html", %{conn: conn}) do
tags = Instance.build_tags()
- PageView.inject_tags(tags)
+ inject_tags(tags, get_locale(conn))
end
def render("404.json", _assigns) do
diff --git a/lib/web/views/page_view.ex b/lib/web/views/page_view.ex
index 7bbd75f45..3615ddc15 100644
--- a/lib/web/views/page_view.ex
+++ b/lib/web/views/page_view.ex
@@ -13,10 +13,10 @@ defmodule Mobilizon.Web.PageView do
alias Mobilizon.Service.Metadata
alias Mobilizon.Service.Metadata.Instance
- alias Mobilizon.Service.Metadata.Utils, as: MetadataUtils
alias Mobilizon.Federation.ActivityPub.Utils
alias Mobilizon.Federation.ActivityStream.Convertible
+ import Mobilizon.Web.Views.Utils
def render("actor.activity-json", %{conn: %{assigns: %{object: %Actor{} = actor}}}) do
actor
@@ -59,38 +59,4 @@ defmodule Mobilizon.Web.PageView do
tags = Instance.build_tags()
inject_tags(tags, get_locale(conn))
end
-
- @spec inject_tags(List.t(), String.t()) :: {:safe, String.t()}
- def inject_tags(tags, locale \\ "en") do
- with {:ok, index_content} <- File.read(index_file_path()) do
- do_replacements(index_content, MetadataUtils.stringify_tags(tags), locale)
- end
- end
-
- @spec index_file_path :: String.t()
- defp index_file_path do
- Path.join(Application.app_dir(:mobilizon, "priv/static"), "index.html")
- end
-
- @spec replace_meta(String.t(), String.t()) :: String.t()
- # TODO: Find why it's different in dev/prod and during tests
- defp replace_meta(index_content, tags) do
- index_content
- |> String.replace("", tags)
- |> String.replace("", tags)
- end
-
- @spec do_replacements(String.t(), String.t(), String.t()) :: {:safe, String.t()}
- defp do_replacements(index_content, tags, locale) do
- index_content
- |> replace_meta(tags)
- |> String.replace("", "")
- |> String.replace("", "")
- |> (&{:safe, &1}).()
- end
-
- @spec get_locale(Conn.t()) :: String.t()
- defp get_locale(%{private: %{cldr_locale: nil}}), do: "en"
- defp get_locale(%{private: %{cldr_locale: %{requested_locale_name: locale}}}), do: locale
- defp get_locale(_), do: "en"
end
diff --git a/lib/web/views/utils.ex b/lib/web/views/utils.ex
new file mode 100644
index 000000000..234e222cf
--- /dev/null
+++ b/lib/web/views/utils.ex
@@ -0,0 +1,41 @@
+defmodule Mobilizon.Web.Views.Utils do
+ @moduledoc """
+ Utils for views
+ """
+
+ alias Mobilizon.Service.Metadata.Utils, as: MetadataUtils
+
+ @spec inject_tags(List.t(), String.t()) :: {:safe, String.t()}
+ def inject_tags(tags, locale \\ "en") do
+ with {:ok, index_content} <- File.read(index_file_path()) do
+ do_replacements(index_content, MetadataUtils.stringify_tags(tags), locale)
+ end
+ end
+
+ @spec index_file_path :: String.t()
+ defp index_file_path do
+ Path.join(Application.app_dir(:mobilizon, "priv/static"), "index.html")
+ end
+
+ @spec replace_meta(String.t(), String.t()) :: String.t()
+ # TODO: Find why it's different in dev/prod and during tests
+ defp replace_meta(index_content, tags) do
+ index_content
+ |> String.replace("", tags)
+ |> String.replace("", tags)
+ end
+
+ @spec do_replacements(String.t(), String.t(), String.t()) :: {:safe, String.t()}
+ defp do_replacements(index_content, tags, locale) do
+ index_content
+ |> replace_meta(tags)
+ |> String.replace("", "")
+ |> String.replace("", "")
+ |> (&{:safe, &1}).()
+ end
+
+ @spec get_locale(Conn.t()) :: String.t()
+ def get_locale(%{private: %{cldr_locale: nil}}), do: "en"
+ def get_locale(%{private: %{cldr_locale: %{requested_locale_name: locale}}}), do: locale
+ def get_locale(_), do: "en"
+end
diff --git a/priv/repo/migrations/20190929170817_rename_postgres_types.exs b/priv/repo/migrations/20190929170817_rename_postgres_types.exs
index cb129d5b5..a46d0d28b 100644
--- a/priv/repo/migrations/20190929170817_rename_postgres_types.exs
+++ b/priv/repo/migrations/20190929170817_rename_postgres_types.exs
@@ -2,7 +2,7 @@ defmodule Mobilizon.Storage.Repo.Migrations.RenamePostgresTypes do
use Ecto.Migration
alias Mobilizon.Actors.{ActorVisibility, MemberRole}
- alias alias Mobilizon.Conversations.CommentVisibility
+ alias Mobilizon.Conversations.CommentVisibility
alias Mobilizon.Events.{
JoinOptions,
diff --git a/test/federation/activity_pub/transmogrifier_test.exs b/test/federation/activity_pub/transmogrifier_test.exs
index 56ed28449..1960c46b3 100644
--- a/test/federation/activity_pub/transmogrifier_test.exs
+++ b/test/federation/activity_pub/transmogrifier_test.exs
@@ -1365,8 +1365,7 @@ defmodule Mobilizon.Federation.ActivityPub.TransmogrifierTest do
assert event.id
|> Events.list_participants_for_event()
|> Map.get(:elements)
- |> Enum.map(& &1.id) ==
- []
+ |> Enum.map(& &1.role) == [:rejected]
end
end
From 1cb4dfe9d6d8adc20b78054e4300e111e4a36dfc Mon Sep 17 00:00:00 2001
From: Thomas Citharel
Date: Thu, 18 Jun 2020 16:01:14 +0200
Subject: [PATCH 2/2] Login UI improvements
Signed-off-by: Thomas Citharel
---
js/src/i18n/en_US.json | 16 ++++++++++------
js/src/i18n/fr_FR.json | 11 ++++++++++-
js/src/views/User/Login.vue | 5 +++++
js/src/views/User/ResendConfirmation.vue | 12 +++++++++---
js/src/views/User/SendPasswordReset.vue | 21 +++++++++++++++++----
5 files changed, 51 insertions(+), 14 deletions(-)
diff --git a/js/src/i18n/en_US.json b/js/src/i18n/en_US.json
index 76facffe2..5508375ac 100644
--- a/js/src/i18n/en_US.json
+++ b/js/src/i18n/en_US.json
@@ -317,7 +317,6 @@
"Registration is currently closed.": "Registration is currently closed.",
"Registrations are restricted by whitelisting.": "Registrations are restricted by whitelisting.",
"Reject": "Reject",
- "Rejected participations": "Rejected participations",
"Rejected": "Rejected",
"Reopen": "Reopen",
"Reply": "Reply",
@@ -330,7 +329,6 @@
"Reported identity": "Reported identity",
"Reported": "Reported",
"Reports": "Reports",
- "Requests": "Requests",
"Resend confirmation email": "Resend confirmation email",
"Reset my password": "Reset my password",
"Resolved": "Resolved",
@@ -343,8 +341,6 @@
"Search": "Search",
"Searching…": "Searching…",
"Send email": "Send email",
- "Send me an email to reset my password": "Send me an email to reset my password",
- "Send me the confirmation email once again": "Send me the confirmation email once again",
"Send the report": "Send the report",
"Set an URL to a page with your own terms.": "Set an URL to a page with your own terms.",
"Settings": "Settings",
@@ -419,7 +415,6 @@
"View page on {hostname} (in a new window)": "View page on {hostname} (in a new window)",
"Visible everywhere on the web (public)": "Visible everywhere on the web (public)",
"Waiting for organization team approval.": "Waiting for organization team approval.",
- "Waiting list": "Waiting list",
"Warning": "Warning",
"We just sent an email to {email}": "We just sent an email to {email}",
"We want to develop a digital common, that everyone can make their own, which respects privacy and activism by design.": "We want to develop a digital common, that everyone can make their own, which respects privacy and activism by design.",
@@ -647,5 +642,14 @@
"Change timezone": "Change timezone",
"Select a language": "Select a language",
"This event is accessible only through it's link. Be careful where you post this link.": "This event is accessible only through it's link. Be careful where you post this link.",
- "This event has been cancelled.": "This event has been cancelled."
+ "This event has been cancelled.": "This event has been cancelled.",
+ "Actions": "Actions",
+ "Everything": "Everything",
+ "Not approved": "Not approved",
+ "No participant matches the filters": "No participant matches the filters",
+ "Send the confirmation email again": "Send the confirmation email again",
+ "Forgot your password?": "Forgot your password?",
+ "Enter your email address below, and we'll email you instructions on how to change your password.": "Enter your email address below, and we'll email you instructions on how to change your password.",
+ "Submit": "Submit",
+ "Email address": "Email address"
}
diff --git a/js/src/i18n/fr_FR.json b/js/src/i18n/fr_FR.json
index ab80b2f38..8627d864f 100644
--- a/js/src/i18n/fr_FR.json
+++ b/js/src/i18n/fr_FR.json
@@ -670,5 +670,14 @@
"Change timezone": "Changer de fuseau horaire",
"Select a language": "Choisissez une langue",
"This event is accessible only through it's link. Be careful where you post this link.": "Cet événement est accessible uniquement à travers son lien. Faites attention où vous le diffusez.",
- "This event has been cancelled.": "Cet événement a été annulé."
+ "This event has been cancelled.": "Cet événement a été annulé.",
+ "Actions": "Actions",
+ "Everything": "Tous",
+ "Not approved": "Non approuvé·es",
+ "No participant matches the filters": "Aucun·e participant·e ne correspond aux filtres",
+ "Send the confirmation email again": "Envoyer l'email de confirmation à nouveau",
+ "Forgot your password?": "Mot de passe oublié ?",
+ "Enter your email address below, and we'll email you instructions on how to change your password.": "Indiquez votre adresse e-mail ci-dessous. Nous vous enverrons des instructions concernant la modification de votre mot de passe.",
+ "Submit": "Valider",
+ "Email address": "Adresse email"
}
diff --git a/js/src/views/User/Login.vue b/js/src/views/User/Login.vue
index 507be8576..73293f269 100644
--- a/js/src/views/User/Login.vue
+++ b/js/src/views/User/Login.vue
@@ -67,6 +67,11 @@
>{{ $t("Forgot your password ?") }}
+ {{ $t("Didn't receive the instructions ?") }}
@@ -37,6 +40,7 @@
import { Component, Prop, Vue } from "vue-property-decorator";
import { validateEmailField, validateRequiredField } from "../../utils/validators";
import { RESEND_CONFIRMATION_EMAIL } from "../../graphql/auth";
+import RouteName from "../../router/name";
@Component
export default class ResendConfirmation extends Vue {
@@ -50,6 +54,8 @@ export default class ResendConfirmation extends Vue {
error = false;
+ RouteName = RouteName;
+
state = {
email: {
status: null,
diff --git a/js/src/views/User/SendPasswordReset.vue b/js/src/views/User/SendPasswordReset.vue
index c1d14cd87..941e913a2 100644
--- a/js/src/views/User/SendPasswordReset.vue
+++ b/js/src/views/User/SendPasswordReset.vue
@@ -3,8 +3,15 @@