Add toggle to disable groups

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2020-06-08 16:47:57 +02:00
parent 7767a6efc7
commit 7dbabcf15f
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773
10 changed files with 29 additions and 8 deletions

View file

@ -21,8 +21,9 @@ config :mobilizon, :instance,
demo: false, demo: false,
repository: Mix.Project.config()[:source_url], repository: Mix.Project.config()[:source_url],
allow_relay: true, allow_relay: true,
# Federation is to be activated with Mobilizon 1.0.0-beta.2
federating: true, federating: true,
# Groups are to be activated with Mobilizon 1.0.0
groups: false,
remote_limit: 100_000, remote_limit: 100_000,
upload_limit: 10_000_000, upload_limit: 10_000_000,
avatar_upload_limit: 2_000_000, avatar_upload_limit: 2_000_000,

View file

@ -87,7 +87,8 @@ config :mobilizon, :instance,
hostname: System.get_env("MOBILIZON_INSTANCE_HOST", "Mobilizon"), hostname: System.get_env("MOBILIZON_INSTANCE_HOST", "Mobilizon"),
email_from: System.get_env("MOBILIZON_INSTANCE_EMAIL"), email_from: System.get_env("MOBILIZON_INSTANCE_EMAIL"),
email_reply_to: 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 # config :mobilizon, :activitypub, sign_object_fetches: false

View file

@ -12,9 +12,12 @@
<b-navbar-item tag="router-link" :to="{ name: RouteName.MY_EVENTS }">{{ <b-navbar-item tag="router-link" :to="{ name: RouteName.MY_EVENTS }">{{
$t("My events") $t("My events")
}}</b-navbar-item> }}</b-navbar-item>
<b-navbar-item tag="router-link" :to="{ name: RouteName.MY_GROUPS }">{{ <b-navbar-item
$t("My groups") tag="router-link"
}}</b-navbar-item> :to="{ name: RouteName.MY_GROUPS }"
v-if="config && config.features.groups"
>{{ $t("My groups") }}</b-navbar-item
>
<b-navbar-item tag="span"> <b-navbar-item tag="span">
<b-button tag="router-link" :to="{ name: RouteName.CREATE_EVENT }" type="is-success">{{ <b-button tag="router-link" :to="{ name: RouteName.CREATE_EVENT }" type="is-success">{{
$t("Create") $t("Create")

View file

@ -56,6 +56,9 @@ export const CONFIG = gql`
endpoint endpoint
software software
} }
features {
groups
}
} }
} }
`; `;

View file

@ -58,4 +58,7 @@ export interface IConfig {
}; };
resourceProviders: IProvider[]; resourceProviders: IProvider[];
timezones: string[]; timezones: string[];
features: {
groups: boolean;
};
} }

View file

@ -51,7 +51,7 @@
/> />
</b-field> </b-field>
</div> </div>
<div class="column"> <div class="column" v-if="config && config.features.groups">
<b-field :label="$t('Group')" v-if="event.organizerActor"> <b-field :label="$t('Group')" v-if="event.organizerActor">
<group-picker-wrapper v-model="event.attributedTo" :identity="event.organizerActor" /> <group-picker-wrapper v-model="event.attributedTo" :identity="event.organizerActor" />
</b-field> </b-field>

View file

@ -12,7 +12,7 @@
}}</b-radio-button> }}</b-radio-button>
</b-field> </b-field>
<ul v-if="reports.length > 0"> <ul v-if="reports.length > 0">
<li v-for="report in reports"> <li v-for="report in reports" :key="report.id">
<router-link :to="{ name: RouteName.REPORT, params: { reportId: report.id } }"> <router-link :to="{ name: RouteName.REPORT, params: { reportId: report.id } }">
<report-card :report="report" /> <report-card :report="report" />
</router-link> </router-link>

View file

@ -102,7 +102,10 @@ defmodule Mobilizon.GraphQL.Resolvers.Config do
} }
}, },
resource_providers: Config.instance_resource_providers(), resource_providers: Config.instance_resource_providers(),
timezones: Tzdata.zone_list() timezones: Tzdata.zone_list(),
features: %{
groups: Config.instance_group_feature_enabled?()
}
} }
end end
end end

View file

@ -22,6 +22,7 @@ defmodule Mobilizon.GraphQL.Schema.ConfigType do
field(:anonymous, :anonymous) field(:anonymous, :anonymous)
field(:resource_providers, list_of(:resource_provider)) field(:resource_providers, list_of(:resource_provider))
field(:timezones, list_of(:string)) field(:timezones, list_of(:string))
field(:features, :features)
field(:terms, :terms, description: "The instance's terms") do field(:terms, :terms, description: "The instance's terms") do
arg(:locale, :string, default_value: "en") arg(:locale, :string, default_value: "en")
@ -105,6 +106,10 @@ defmodule Mobilizon.GraphQL.Schema.ConfigType do
field(:software, :string) field(:software, :string)
end end
object :features do
field(:groups, :boolean)
end
object :config_queries do object :config_queries do
@desc "Get the instance config" @desc "Get the instance config"
field :config, :config do field :config, :config do

View file

@ -162,6 +162,8 @@ defmodule Mobilizon.Config do
end end
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 anonymous_actor_id, do: get_cached_value(:anonymous_actor_id)
def relay_actor_id, do: get_cached_value(:relay_actor_id) def relay_actor_id, do: get_cached_value(:relay_actor_id)