Merge branch 'fixes' into 'main'

Various fixes

Closes #1223 et #1214

See merge request framasoft/mobilizon!1348
This commit is contained in:
Thomas Citharel 2022-12-22 11:24:30 +00:00
commit ce9a310d91
8 changed files with 65 additions and 61 deletions

View file

@ -235,7 +235,7 @@ const isComponentModalActive = ref(false);
const contactFilter = ref(""); const contactFilter = ref("");
const membersPage = ref(1); const membersPage = ref(1);
const { result: membersResult } = useQuery<{ group: Pick<IGroup, 'members'> }>( const { result: membersResult } = useQuery<{ group: Pick<IGroup, "members"> }>(
GROUP_MEMBERS, GROUP_MEMBERS,
() => ({ () => ({
groupName: usernameWithDomain(selectedActor.value), groupName: usernameWithDomain(selectedActor.value),
@ -247,8 +247,10 @@ const { result: membersResult } = useQuery<{ group: Pick<IGroup, 'members'> }>(
() => ({ enabled: selectedActor.value?.type === ActorType.GROUP }) () => ({ enabled: selectedActor.value?.type === ActorType.GROUP })
); );
const members = computed<Paginate<IMember>>( const members = computed<Paginate<IMember>>(() =>
() => selectedActor.value?.type === ActorType.GROUP ? membersResult.value?.group?.members ?? { elements: [], total: 0 } : { elements: [], total: 0 } selectedActor.value?.type === ActorType.GROUP
? membersResult.value?.group?.members ?? { elements: [], total: 0 }
: { elements: [], total: 0 }
); );
const actualContacts = computed({ const actualContacts = computed({

View file

@ -118,6 +118,8 @@ const icons: Record<string, () => Promise<any>> = {
Loading: () => Loading: () =>
import(`../../../node_modules/vue-material-design-icons/Loading.vue`), import(`../../../node_modules/vue-material-design-icons/Loading.vue`),
Eye: () => import(`../../../node_modules/vue-material-design-icons/Eye.vue`), Eye: () => import(`../../../node_modules/vue-material-design-icons/Eye.vue`),
EyeOff: () =>
import(`../../../node_modules/vue-material-design-icons/EyeOff.vue`),
AlertCircle: () => AlertCircle: () =>
import(`../../../node_modules/vue-material-design-icons/AlertCircle.vue`), import(`../../../node_modules/vue-material-design-icons/AlertCircle.vue`),
Rss: () => import(`../../../node_modules/vue-material-design-icons/Rss.vue`), Rss: () => import(`../../../node_modules/vue-material-design-icons/Rss.vue`),

View file

@ -49,7 +49,7 @@ app.component("breadcrumbs-nav", Breadcrumbs);
app.component("material-icon", MaterialIcon); app.component("material-icon", MaterialIcon);
app.use(Oruga, orugaConfig); app.use(Oruga, orugaConfig);
const instanceName = ref(); const instanceName = ref<string>();
apolloClient apolloClient
.query<{ config: IConfig }>({ .query<{ config: IConfig }>({

View file

@ -134,9 +134,7 @@ export const routes = [
path: "/auth/:provider/callback", path: "/auth/:provider/callback",
name: "auth-callback", name: "auth-callback",
component: (): Promise<any> => component: (): Promise<any> =>
import( import("@/views/User/ProviderValidation.vue"),
/* webpackChunkName: "ProviderValidation" */ "@/views/User/ProviderValidation.vue"
),
meta: { meta: {
announcer: { announcer: {
message: (): string => t("Redirecting to Mobilizon") as string, message: (): string => t("Redirecting to Mobilizon") as string,

View file

@ -221,8 +221,9 @@ const newRelayAddress = ref("");
// relayFollowers: Paginate<IFollower> = { elements: [], total: 0 }; // relayFollowers: Paginate<IFollower> = { elements: [], total: 0 };
const updateDomainFilter = (domain: string) => { const updateDomainFilter = (event: InputEvent) => {
filterDomain.value = domain; const newValue = (event.target as HTMLInputElement).value;
filterDomain.value = newValue;
}; };
const debouncedUpdateDomainFilter = debounce(updateDomainFilter, 500); const debouncedUpdateDomainFilter = debounce(updateDomainFilter, 500);

View file

@ -74,17 +74,13 @@
v-model="passwordForEmailChange" v-model="passwordForEmailChange"
/> />
</o-field> </o-field>
<o-button <o-button class="mt-2" variant="primary" nativeType="submit">
class="mt-2"
variant="primary"
:disabled="!(emailForm && emailForm.checkValidity())"
>
{{ t("Change my email") }} {{ t("Change my email") }}
</o-button> </o-button>
</form> </form>
<h2 class="mt-2">{{ t("Password") }}</h2> <h2 class="mt-2">{{ t("Password") }}</h2>
<o-notification <o-notification
v-if="!canChangePassword" v-if="!canChangePassword && loggedUser.provider"
variant="warning" variant="warning"
:closable="false" :closable="false"
> >
@ -134,11 +130,7 @@
v-model="newPassword" v-model="newPassword"
/> />
</o-field> </o-field>
<o-button <o-button class="mt-2" variant="primary" nativeType="submit">
class="mt-2"
variant="primary"
:disabled="!(passwordForm && passwordForm.checkValidity())"
>
{{ t("Change my password") }} {{ t("Change my password") }}
</o-button> </o-button>
</form> </form>
@ -258,8 +250,8 @@ useHead({
title: computed(() => t("General settings")), title: computed(() => t("General settings")),
}); });
const passwordForm = ref<HTMLElement>(); const passwordForm = ref<HTMLFormElement>();
const emailForm = ref<HTMLElement>(); const emailForm = ref<HTMLFormElement>();
const passwordForEmailChange = ref(""); const passwordForEmailChange = ref("");
const newEmail = ref(""); const newEmail = ref("");
@ -294,12 +286,14 @@ changeEmailMutationError((err) => {
}); });
const resetEmailAction = async (): Promise<void> => { const resetEmailAction = async (): Promise<void> => {
changeEmailErrors.value = []; if (emailForm.value?.reportValidity()) {
changeEmailErrors.value = [];
changeEmailMutation({ changeEmailMutation({
email: newEmail.value, email: newEmail.value,
password: passwordForEmailChange.value, password: passwordForEmailChange.value,
}); });
}
}; };
const { const {
@ -319,12 +313,14 @@ onChangePasswordMutationError((err) => {
}); });
const resetPasswordAction = async (): Promise<void> => { const resetPasswordAction = async (): Promise<void> => {
changePasswordErrors.value = []; if (passwordForm.value?.reportValidity()) {
changePasswordErrors.value = [];
changePasswordMutation({ changePasswordMutation({
oldPassword: oldPassword.value, oldPassword: oldPassword.value,
newPassword: newPassword.value, newPassword: newPassword.value,
}); });
}
}; };
const openDeleteAccountModal = (): void => { const openDeleteAccountModal = (): void => {

View file

@ -1,6 +1,7 @@
<template> <template>
<p>{{ t("Redirecting in progress…") }}</p> <p>{{ t("Redirecting in progress…") }}</p>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ICurrentUserRole } from "@/types/enums"; import { ICurrentUserRole } from "@/types/enums";
import { UPDATE_CURRENT_USER_CLIENT, LOGGED_USER } from "../../graphql/user"; import { UPDATE_CURRENT_USER_CLIENT, LOGGED_USER } from "../../graphql/user";
@ -9,10 +10,10 @@ import { saveUserData } from "../../utils/auth";
import { changeIdentity } from "../../utils/identity"; import { changeIdentity } from "../../utils/identity";
import { ICurrentUser, IUser } from "../../types/current-user.model"; import { ICurrentUser, IUser } from "../../types/current-user.model";
import { useRouter } from "vue-router"; import { useRouter } from "vue-router";
import { useMutation, useQuery } from "@vue/apollo-composable"; import { useLazyQuery, useMutation } from "@vue/apollo-composable";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import { useHead } from "@vueuse/head"; import { useHead } from "@vueuse/head";
import { computed } from "vue"; import { computed, onMounted } from "vue";
const { t } = useI18n({ useScope: "global" }); const { t } = useI18n({ useScope: "global" });
useHead({ useHead({
@ -35,15 +36,17 @@ const userRole = getValueFromMeta("auth-user-role") as ICurrentUserRole;
const router = useRouter(); const router = useRouter();
const { onDone, mutate } = useMutation<{ updateCurrentUser: ICurrentUser }>( const { onDone, mutate } = useMutation<
UPDATE_CURRENT_USER_CLIENT { updateCurrentUser: ICurrentUser },
); { id: string; email: string; isLoggedIn: boolean; role: ICurrentUserRole }
>(UPDATE_CURRENT_USER_CLIENT);
onDone(() => { const { onResult: onLoggedUserResult, load: loadUser } = useLazyQuery<{
const { onResult: onLoggedUserResult } = useQuery<{ loggedUser: IUser }>( loggedUser: IUser;
LOGGED_USER }>(LOGGED_USER);
);
onDone(async () => {
loadUser();
onLoggedUserResult(async ({ data: { loggedUser } }) => { onLoggedUserResult(async ({ data: { loggedUser } }) => {
if (loggedUser.defaultActor) { if (loggedUser.defaultActor) {
await changeIdentity(loggedUser.defaultActor); await changeIdentity(loggedUser.defaultActor);
@ -54,26 +57,28 @@ onDone(() => {
}); });
}); });
if (!(userId && userEmail && userRole && accessToken && refreshToken)) { onMounted(async () => {
await router.push("/"); if (!(userId && userEmail && userRole && accessToken && refreshToken)) {
} else { await router.push("/");
const login = { } else {
user: { const login = {
user: {
id: userId,
email: userEmail,
role: userRole,
isLoggedIn: true,
},
accessToken,
refreshToken,
};
saveUserData(login);
mutate({
id: userId, id: userId,
email: userEmail, email: userEmail,
role: userRole,
isLoggedIn: true, isLoggedIn: true,
}, role: userRole,
accessToken, });
refreshToken, }
}; });
saveUserData(login);
mutate({
id: userId,
email: userEmail,
isLoggedIn: true,
role: userRole,
});
}
</script> </script>

View file

@ -155,7 +155,7 @@ msgstr "Les inscriptions ne sont pas ouvertes"
#: lib/graphql/resolvers/user.ex:444 #: lib/graphql/resolvers/user.ex:444
msgid "The current password is invalid" msgid "The current password is invalid"
msgstr "Le mot de passe actuel est invalid" msgstr "Le mot de passe actuel est invalide"
#: lib/graphql/resolvers/admin.ex:336 lib/graphql/resolvers/user.ex:487 #: lib/graphql/resolvers/admin.ex:336 lib/graphql/resolvers/user.ex:487
msgid "The new email doesn't seem to be valid" msgid "The new email doesn't seem to be valid"