From 353fe4f9adf6b8dcc1343d902501adcec061aa71 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Mon, 8 Jun 2020 16:47:57 +0200 Subject: [PATCH] Add toggle to disable groups Signed-off-by: Thomas Citharel --- config/config.exs | 3 ++- config/dev.exs | 3 ++- js/src/components/NavBar.vue | 9 ++++++--- js/src/graphql/config.ts | 3 +++ js/src/types/config.model.ts | 3 +++ js/src/views/Event/Edit.vue | 2 +- js/src/views/Moderation/ReportList.vue | 2 +- lib/graphql/resolvers/config.ex | 5 ++++- lib/graphql/schema/config.ex | 5 +++++ lib/mobilizon/config.ex | 2 ++ 10 files changed, 29 insertions(+), 8 deletions(-) diff --git a/config/config.exs b/config/config.exs index d84a3654d..5ee17d3fa 100644 --- a/config/config.exs +++ b/config/config.exs @@ -21,8 +21,9 @@ config :mobilizon, :instance, demo: false, repository: Mix.Project.config()[:source_url], allow_relay: true, - # Federation is to be activated with Mobilizon 1.0.0-beta.2 federating: true, + # Groups are to be activated with Mobilizon 1.0.0 + groups: false, remote_limit: 100_000, upload_limit: 10_000_000, avatar_upload_limit: 2_000_000, diff --git a/config/dev.exs b/config/dev.exs index c13c594f8..bfddae9ca 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -87,7 +87,8 @@ config :mobilizon, :instance, hostname: System.get_env("MOBILIZON_INSTANCE_HOST", "Mobilizon"), email_from: System.get_env("MOBILIZON_INSTANCE_EMAIL"), email_reply_to: System.get_env("MOBILIZON_INSTANCE_EMAIL"), - registrations_open: System.get_env("MOBILIZON_INSTANCE_REGISTRATIONS_OPEN") == "true" + registrations_open: System.get_env("MOBILIZON_INSTANCE_REGISTRATIONS_OPEN") == "true", + groups: true # config :mobilizon, :activitypub, sign_object_fetches: false diff --git a/js/src/components/NavBar.vue b/js/src/components/NavBar.vue index 9732f6d05..a97d6792c 100644 --- a/js/src/components/NavBar.vue +++ b/js/src/components/NavBar.vue @@ -12,9 +12,12 @@ {{ $t("My events") }} - {{ - $t("My groups") - }} + {{ $t("My groups") }} {{ $t("Create") diff --git a/js/src/graphql/config.ts b/js/src/graphql/config.ts index 16637d8e9..f7d07cbf3 100644 --- a/js/src/graphql/config.ts +++ b/js/src/graphql/config.ts @@ -56,6 +56,9 @@ export const CONFIG = gql` endpoint software } + features { + groups + } } } `; diff --git a/js/src/types/config.model.ts b/js/src/types/config.model.ts index 9cf449695..07f83f5c2 100644 --- a/js/src/types/config.model.ts +++ b/js/src/types/config.model.ts @@ -58,4 +58,7 @@ export interface IConfig { }; resourceProviders: IProvider[]; timezones: string[]; + features: { + groups: boolean; + }; } diff --git a/js/src/views/Event/Edit.vue b/js/src/views/Event/Edit.vue index c4a041b2d..6959a3e5c 100644 --- a/js/src/views/Event/Edit.vue +++ b/js/src/views/Event/Edit.vue @@ -51,7 +51,7 @@ /> -
+
diff --git a/js/src/views/Moderation/ReportList.vue b/js/src/views/Moderation/ReportList.vue index ddb769b5d..51ae764d7 100644 --- a/js/src/views/Moderation/ReportList.vue +++ b/js/src/views/Moderation/ReportList.vue @@ -12,7 +12,7 @@ }}
    -
  • +
  • diff --git a/lib/graphql/resolvers/config.ex b/lib/graphql/resolvers/config.ex index a72d624c2..46f16ab82 100644 --- a/lib/graphql/resolvers/config.ex +++ b/lib/graphql/resolvers/config.ex @@ -102,7 +102,10 @@ defmodule Mobilizon.GraphQL.Resolvers.Config do } }, resource_providers: Config.instance_resource_providers(), - timezones: Tzdata.zone_list() + timezones: Tzdata.zone_list(), + features: %{ + groups: Config.instance_group_feature_enabled?() + } } end end diff --git a/lib/graphql/schema/config.ex b/lib/graphql/schema/config.ex index d0925cfe9..f67ddb616 100644 --- a/lib/graphql/schema/config.ex +++ b/lib/graphql/schema/config.ex @@ -22,6 +22,7 @@ defmodule Mobilizon.GraphQL.Schema.ConfigType do field(:anonymous, :anonymous) field(:resource_providers, list_of(:resource_provider)) field(:timezones, list_of(:string)) + field(:features, :features) field(:terms, :terms, description: "The instance's terms") do arg(:locale, :string, default_value: "en") @@ -105,6 +106,10 @@ defmodule Mobilizon.GraphQL.Schema.ConfigType do field(:software, :string) end + object :features do + field(:groups, :boolean) + end + object :config_queries do @desc "Get the instance config" field :config, :config do diff --git a/lib/mobilizon/config.ex b/lib/mobilizon/config.ex index de4883184..14f6de390 100644 --- a/lib/mobilizon/config.ex +++ b/lib/mobilizon/config.ex @@ -162,6 +162,8 @@ defmodule Mobilizon.Config do end end + def instance_group_feature_enabled?, do: Application.get_env(:mobilizon, :instance)[:groups] + def anonymous_actor_id, do: get_cached_value(:anonymous_actor_id) def relay_actor_id, do: get_cached_value(:relay_actor_id)