Added a demo mode to show or hide instance warnings that data is deleted

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2019-11-21 16:07:43 +01:00
parent 119cb5f71d
commit a53100ef6e
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773
11 changed files with 21 additions and 4 deletions

View file

@ -25,6 +25,7 @@ In order to move participant stats to the event table for existing events, you n
- Add a different welcome message when coming from registration - Add a different welcome message when coming from registration
- Link to participation page from event page when you are an organizer - Link to participation page from event page when you are an organizer
- Added a warning on login that everything is deleted regularily - Added a warning on login that everything is deleted regularily
- Added a demo mode to show or hide instance warnings that data is deleted
- Updated Occitan translations (Quentin) - Updated Occitan translations (Quentin)
- Updated French translations (Gavy, Zilverspar, ty kayn) - Updated French translations (Gavy, Zilverspar, ty kayn)
- Updated Swedish translations (Anton Strömkvist) - Updated Swedish translations (Anton Strömkvist)

View file

@ -18,6 +18,7 @@ config :mobilizon, :instance,
version: "1.0.0-dev", version: "1.0.0-dev",
hostname: System.get_env("MOBILIZON_INSTANCE_HOST") || "localhost", hostname: System.get_env("MOBILIZON_INSTANCE_HOST") || "localhost",
registrations_open: System.get_env("MOBILIZON_INSTANCE_REGISTRATIONS_OPEN") || false, registrations_open: System.get_env("MOBILIZON_INSTANCE_REGISTRATIONS_OPEN") || false,
demo: System.get_env("MOBILIZON_INSTANCE_DEMO_MODE") || 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 # Federation is to be activated with Mobilizon 1.0.0-beta.2

View file

@ -1,7 +1,7 @@
<template> <template>
<div id="mobilizon"> <div id="mobilizon">
<NavBar /> <NavBar />
<div class="container"> <div class="container" v-if="config && config.demoMode">
<b-message type="is-danger" :title="$t('Warning').toLocaleUpperCase()" closable aria-close-label="Close"> <b-message type="is-danger" :title="$t('Warning').toLocaleUpperCase()" closable aria-close-label="Close">
<p>{{ $t('This is a demonstration site to test the beta version of Mobilizon.') }}</p> <p>{{ $t('This is a demonstration site to test the beta version of Mobilizon.') }}</p>
<p v-html="$t('<b>Please do not use it in any real way</b>: everything you create here (accounts, events, identities, etc.) will be automatically deleted every 48 hours.')" /> <p v-html="$t('<b>Please do not use it in any real way</b>: everything you create here (accounts, events, identities, etc.) will be automatically deleted every 48 hours.')" />
@ -35,11 +35,14 @@ import { CURRENT_USER_CLIENT, UPDATE_CURRENT_USER_CLIENT } from '@/graphql/user'
import Footer from '@/components/Footer.vue'; import Footer from '@/components/Footer.vue';
import Logo from '@/components/Logo.vue'; import Logo from '@/components/Logo.vue';
import { initializeCurrentActor } from '@/utils/auth'; import { initializeCurrentActor } from '@/utils/auth';
import { CONFIG } from '@/graphql/config';
import { IConfig } from '@/types/config.model';
@Component({ @Component({
apollo: { apollo: {
currentUser: { currentUser: {
query: CURRENT_USER_CLIENT, query: CURRENT_USER_CLIENT,
}, },
config: CONFIG,
}, },
components: { components: {
Logo, Logo,
@ -48,6 +51,8 @@ import { initializeCurrentActor } from '@/utils/auth';
}, },
}) })
export default class App extends Vue { export default class App extends Vue {
config!: IConfig;
async created() { async created() {
if (await this.initializeCurrentUser()) { if (await this.initializeCurrentUser()) {
await initializeCurrentActor(this.$apollo.provider.defaultClient); await initializeCurrentActor(this.$apollo.provider.defaultClient);

View file

@ -6,6 +6,7 @@ query {
name, name,
description, description,
registrationsOpen, registrationsOpen,
demoMode,
countryCode, countryCode,
location { location {
latitude, latitude,

View file

@ -3,6 +3,7 @@ export interface IConfig {
description: string; description: string;
registrationsOpen: boolean; registrationsOpen: boolean;
demoMode: boolean;
countryCode: string; countryCode: string;
location: { location: {
latitude: number; latitude: number;

View file

@ -24,7 +24,7 @@
{{ $t('No user account with this email was found. Maybe you made a typo?') }} {{ $t('No user account with this email was found. Maybe you made a typo?') }}
</span> </span>
<!-- Warning that we delete everything every now and then --> <!-- Warning that we delete everything every now and then -->
<span v-if="error === LoginError.USER_DOES_NOT_EXIST"> <span v-if="error === LoginError.USER_DOES_NOT_EXIST && config.demoMode">
{{ $t('User accounts and every other data is currently deleted every 48 hours, so you may want to register again.') }} {{ $t('User accounts and every other data is currently deleted every 48 hours, so you may want to register again.') }}
</span> </span>
</b-message> </b-message>
@ -203,4 +203,4 @@ export default class Login extends Vue {
.container .columns { .container .columns {
margin: 1rem auto 3rem; margin: 1rem auto 3rem;
} }
</style> </style>

View file

@ -21,6 +21,9 @@ defmodule Mobilizon.Config do
@spec instance_registrations_open? :: boolean @spec instance_registrations_open? :: boolean
def instance_registrations_open?, do: to_boolean(instance_config()[:registrations_open]) def instance_registrations_open?, do: to_boolean(instance_config()[:registrations_open])
@spec instance_demo_mode? :: boolean
def instance_demo_mode?, do: to_boolean(instance_config()[:demo])
@spec instance_repository :: String.t() @spec instance_repository :: String.t()
def instance_repository, do: instance_config()[:repository] def instance_repository, do: instance_config()[:repository]

View file

@ -30,6 +30,7 @@ defmodule MobilizonWeb.Resolvers.Config do
%{ %{
name: Config.instance_name(), name: Config.instance_name(),
registrations_open: Config.instance_registrations_open?(), registrations_open: Config.instance_registrations_open?(),
demo_mode: Config.instance_demo_mode?(),
description: Config.instance_description(), description: Config.instance_description(),
location: location, location: location,
country_code: country_code, country_code: country_code,

View file

@ -13,6 +13,7 @@ defmodule MobilizonWeb.Schema.ConfigType do
field(:description, :string) field(:description, :string)
field(:registrations_open, :boolean) field(:registrations_open, :boolean)
field(:demo_mode, :boolean)
field(:country_code, :string) field(:country_code, :string)
field(:location, :lonlat) field(:location, :lonlat)
field(:geocoding, :geocoding) field(:geocoding, :geocoding)

View file

@ -72,6 +72,7 @@
</td> </td>
</tr> </tr>
<%= render @view_module, @view_template, assigns %> <%= render @view_module, @view_template, assigns %>
<% if Mobilizon.Config.instance_demo_mode?() do %>
<!-- BETA WARNING --> <!-- BETA WARNING -->
<tr> <tr>
<td bgcolor="#f4f4f4" align="center" style="padding: 30px 10px 0px 10px;"> <td bgcolor="#f4f4f4" align="center" style="padding: 30px 10px 0px 10px;">
@ -103,6 +104,7 @@
<![endif]--> <![endif]-->
</td> </td>
</tr> </tr>
<% end %>
<!-- SUPPORT CALLOUT --> <!-- SUPPORT CALLOUT -->
<tr> <tr>
<td bgcolor="#f4f4f4" align="center" style="padding: 30px 10px 0px 10px;"> <td bgcolor="#f4f4f4" align="center" style="padding: 30px 10px 0px 10px;">

View file

@ -1,5 +1,5 @@
# source: http://localhost:4000/api # source: http://localhost:4000/api
# timestamp: Wed Nov 20 2019 10:45:54 GMT+0100 (Central European Standard Time) # timestamp: Thu Nov 21 2019 15:58:08 GMT+0100 (Central European Standard Time)
schema { schema {
query: RootQueryType query: RootQueryType
@ -190,6 +190,7 @@ enum CommentVisibility {
"""A config object""" """A config object"""
type Config { type Config {
countryCode: String countryCode: String
demoMode: Boolean
description: String description: String
geocoding: Geocoding geocoding: Geocoding
location: Lonlat location: Lonlat