Introduce group basic federation, event new page and notifications

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2020-02-18 08:57:00 +01:00
parent 300ef8f245
commit 4144e9ffd0
416 changed files with 32220 additions and 16750 deletions

View File

@@ -2,15 +2,18 @@
<section class="section container">
<div class="columns is-mobile is-centered">
<div class="column is-half-desktop">
<h1 class="title">
{{ $t('Register an account on Mobilizon!') }}
</h1>
<b-message v-if="userAlreadyActivated">
{{ $t('To achieve your registration, please create a first identity profile.')}}
</b-message>
<h1 class="title">{{ $t("Register an account on Mobilizon!") }}</h1>
<b-message v-if="userAlreadyActivated">{{
$t("To achieve your registration, please create a first identity profile.")
}}</b-message>
<form v-if="!validationSent" @submit.prevent="submit">
<b-field :label="$t('Display name')">
<b-input aria-required="true" required v-model="identity.name" @input="autoUpdateUsername($event)"/>
<b-input
aria-required="true"
required
v-model="identity.name"
@input="autoUpdateUsername($event)"
/>
</b-field>
<b-field
@@ -32,26 +35,32 @@
</b-field>
<b-field :label="$t('Description')">
<b-input type="textarea" v-model="identity.summary"/>
<b-input type="textarea" v-model="identity.summary" />
</b-field>
<p class="control has-text-centered">
<b-button type="is-primary" size="is-large" native-type="submit">
{{ $t('Create my profile') }}
</b-button>
<b-button type="is-primary" size="is-large" native-type="submit">{{
$t("Create my profile")
}}</b-button>
</p>
</form>
<div v-if="validationSent && !userAlreadyActivated">
<b-message title="Success" type="is-success" closable="false">
<h2 class="title">
{{ $t('Your account is nearly ready, {username}', { username: identity.preferredUsername }) }}
{{
$t("Your account is nearly ready, {username}", {
username: identity.preferredUsername,
})
}}
</h2>
<p>{{ $t("A validation email was sent to {email}", { email }) }}</p>
<p>
{{ $t('A validation email was sent to {email}', { email }) }}
</p>
<p>
{{ $t('Before you can login, you need to click on the link inside it to validate your account') }}
{{
$t(
"Before you can login, you need to click on the link inside it to validate your account"
)
}}
</p>
</b-message>
</div>
@@ -61,25 +70,29 @@
</template>
<script lang="ts">
import { Component, Prop } from 'vue-property-decorator';
import { IPerson } from '@/types/actor';
import { IDENTITIES, REGISTER_PERSON } from '@/graphql/actor';
import { MOBILIZON_INSTANCE_HOST } from '@/api/_entrypoint';
import { RouteName } from '@/router';
import { changeIdentity } from '@/utils/auth';
import { mixins } from 'vue-class-component';
import identityEditionMixin from '@/mixins/identityEdition';
import { Component, Prop } from "vue-property-decorator";
import { mixins } from "vue-class-component";
import { IPerson } from "../../types/actor";
import { IDENTITIES, REGISTER_PERSON } from "../../graphql/actor";
import { MOBILIZON_INSTANCE_HOST } from "../../api/_entrypoint";
import RouteName from "../../router/name";
import { changeIdentity } from "../../utils/auth";
import identityEditionMixin from "../../mixins/identityEdition";
@Component
export default class Register extends mixins(identityEditionMixin) {
@Prop({ type: String, required: true }) email!: string;
@Prop({ type: Boolean, required: false, default: false }) userAlreadyActivated!: boolean;
@Prop({ type: Boolean, required: false, default: false })
userAlreadyActivated!: boolean;
host?: string = MOBILIZON_INSTANCE_HOST;
errors: object = {};
validationSent: boolean = false;
sendingValidation: boolean = false;
validationSent = false;
sendingValidation = false;
async created() {
// Make sure no one goes to this page if we don't want to
@@ -94,13 +107,15 @@ export default class Register extends mixins(identityEditionMixin) {
this.errors = {};
const { data } = await this.$apollo.mutate<{ registerPerson: IPerson }>({
mutation: REGISTER_PERSON,
variables: Object.assign({ email: this.email }, this.identity),
update: (store, { data }) => {
variables: { email: this.email, ...this.identity },
update: (store, { data: localData }) => {
if (this.userAlreadyActivated) {
const identitiesData = store.readQuery<{ identities: IPerson[] }>({ query: IDENTITIES });
const identitiesData = store.readQuery<{ identities: IPerson[] }>({
query: IDENTITIES,
});
if (identitiesData && data) {
identitiesData.identities.push(data.registerPerson);
if (identitiesData && localData) {
identitiesData.identities.push(localData.registerPerson);
store.writeQuery({ query: IDENTITIES, data: identitiesData });
}
}
@@ -108,7 +123,7 @@ export default class Register extends mixins(identityEditionMixin) {
});
if (data) {
this.validationSent = true;
window.localStorage.setItem('new-registered-user', 'yes');
window.localStorage.setItem("new-registered-user", "yes");
if (this.userAlreadyActivated) {
await changeIdentity(this.$apollo.provider.defaultClient, data.registerPerson);
@@ -116,13 +131,16 @@ export default class Register extends mixins(identityEditionMixin) {
await this.$router.push({ name: RouteName.HOME });
}
}
} catch (error) {
this.errors = error.graphQLErrors.reduce((acc, error) => {
acc[error.details] = error.message;
return acc;
}, {});
console.error('Error while registering person', error);
console.error('Errors while registering person', this.errors);
} catch (errorCatched) {
this.errors = errorCatched.graphQLErrors.reduce(
(acc: { [key: string]: string }, error: any) => {
acc[error.details] = error.message;
return acc;
},
{}
);
console.error("Error while registering person", errorCatched);
console.error("Errors while registering person", this.errors);
}
}
}
@@ -142,7 +160,7 @@ export default class Register extends mixins(identityEditionMixin) {
display: none;
}
.container .columns {
margin: 1rem auto 3rem;
}
.container .columns {
margin: 1rem auto 3rem;
}
</style>