Fix eslint warnings

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2020-11-27 19:27:44 +01:00
parent 487ac56b4c
commit da42522073
130 changed files with 702 additions and 734 deletions

View File

@@ -9,7 +9,7 @@
import { Component, Vue, Watch } from "vue-property-decorator";
import { PRIVACY } from "@/graphql/config";
import { IConfig } from "@/types/config.model";
import { InstancePrivacyType } from "@/types/admin.model";
import { InstancePrivacyType } from "@/types/enums";
@Component({
apollo: {
@@ -31,19 +31,18 @@ export default class Privacy extends Vue {
locale: string | null = null;
created() {
created(): void {
this.locale = this.$i18n.locale;
}
@Watch("config", { deep: true })
watchConfig(config: IConfig) {
watchConfig(config: IConfig): void {
if (config.privacy.type) {
console.log(this.config.privacy);
this.redirectToUrl();
}
}
redirectToUrl() {
redirectToUrl(): void {
if (this.config.privacy.type === InstancePrivacyType.URL) {
window.location.replace(this.config.privacy.url);
}

View File

@@ -7,10 +7,9 @@
</template>
<script lang="ts">
import { Component, Vue, Watch } from "vue-property-decorator";
import { Component, Vue } from "vue-property-decorator";
import { RULES } from "@/graphql/config";
import { IConfig } from "@/types/config.model";
import { InstanceTermsType } from "@/types/admin.model";
import RouteName from "../../router/name";
@Component({

View File

@@ -9,7 +9,7 @@
import { Component, Vue, Watch } from "vue-property-decorator";
import { TERMS } from "@/graphql/config";
import { IConfig } from "@/types/config.model";
import { InstanceTermsType } from "@/types/admin.model";
import { InstanceTermsType } from "@/types/enums";
@Component({
apollo: {
@@ -31,19 +31,18 @@ export default class Terms extends Vue {
locale: string | null = null;
created() {
created(): void {
this.locale = this.$i18n.locale;
}
@Watch("config", { deep: true })
watchConfig(config: IConfig) {
watchConfig(config: IConfig): void {
if (config.terms.type) {
console.log(this.config.terms);
this.redirectToUrl();
}
}
redirectToUrl() {
redirectToUrl(): void {
if (this.config.terms.type === InstanceTermsType.URL) {
window.location.replace(this.config.terms.url);
}

View File

@@ -199,8 +199,9 @@
import { Component, Vue, Prop } from "vue-property-decorator";
import { GET_GROUP, REFRESH_PROFILE } from "@/graphql/group";
import { formatBytes } from "@/utils/datetime";
import { MemberRole } from "@/types/enums";
import { SUSPEND_PROFILE, UNSUSPEND_PROFILE } from "../../graphql/actor";
import { IGroup, MemberRole } from "../../types/actor";
import { IGroup } from "../../types/actor";
import { usernameWithDomain, IActor } from "../../types/actor/actor.model";
import RouteName from "../../router/name";
import ActorCard from "../../components/Account/ActorCard.vue";

View File

@@ -64,10 +64,11 @@
import { Component, Vue, Prop } from "vue-property-decorator";
import { Route } from "vue-router";
import { formatBytes } from "@/utils/datetime";
import { ICurrentUserRole } from "@/types/enums";
import { GET_USER, SUSPEND_USER } from "../../graphql/user";
import { usernameWithDomain } from "../../types/actor/actor.model";
import RouteName from "../../router/name";
import { IUser, ICurrentUserRole } from "../../types/current-user.model";
import { IUser } from "../../types/current-user.model";
import { IPerson } from "../../types/actor";
@Component({

View File

@@ -83,7 +83,6 @@
<script lang="ts">
import { Component, Vue, Watch } from "vue-property-decorator";
import { LIST_GROUPS } from "@/graphql/group";
import { LIST_PROFILES } from "../../graphql/actor";
import RouteName from "../../router/name";
const PROFILES_PER_PAGE = 10;
@@ -124,7 +123,7 @@ export default class GroupProfiles extends Vue {
RouteName = RouteName;
async onPageChange(page: number) {
async onPageChange(page: number): Promise<void> {
this.page = page;
await this.$apollo.queries.groups.fetchMore({
variables: {
@@ -150,13 +149,19 @@ export default class GroupProfiles extends Vue {
});
}
onFiltersChange({ preferredUsername, domain }: { preferredUsername: string; domain: string }) {
onFiltersChange({
preferredUsername,
domain,
}: {
preferredUsername: string;
domain: string;
}): void {
this.preferredUsername = preferredUsername;
this.domain = domain;
}
@Watch("domain")
domainNotLocal() {
domainNotLocal(): void {
this.local = this.domain === "";
}
}

View File

@@ -123,7 +123,7 @@ export default class Profiles extends Vue {
RouteName = RouteName;
async onPageChange(page: number) {
async onPageChange(page: number): Promise<void> {
this.page = page;
await this.$apollo.queries.persons.fetchMore({
variables: {
@@ -149,13 +149,19 @@ export default class Profiles extends Vue {
});
}
onFiltersChange({ preferredUsername, domain }: { preferredUsername: string; domain: string }) {
onFiltersChange({
preferredUsername,
domain,
}: {
preferredUsername: string;
domain: string;
}): void {
this.preferredUsername = preferredUsername;
this.domain = domain;
}
@Watch("domain")
domainNotLocal() {
domainNotLocal(): void {
this.local = this.domain === "";
}
}

View File

@@ -290,12 +290,8 @@
<script lang="ts">
import { Component, Vue, Watch } from "vue-property-decorator";
import { ADMIN_SETTINGS, SAVE_ADMIN_SETTINGS, LANGUAGES } from "@/graphql/admin";
import {
IAdminSettings,
InstanceTermsType,
InstancePrivacyType,
ILanguage,
} from "../../types/admin.model";
import { InstancePrivacyType, InstanceTermsType } from "@/types/enums";
import { IAdminSettings, ILanguage } from "../../types/admin.model";
import RouteName from "../../router/name";
@Component({

View File

@@ -123,7 +123,7 @@ export default class Users extends Vue {
RouteName = RouteName;
async onPageChange(page: number) {
async onPageChange(page: number): Promise<void> {
this.page = page;
await this.$apollo.queries.users.fetchMore({
variables: {

View File

@@ -222,23 +222,24 @@ export default class discussion extends mixins(GroupMixin) {
},
});
if (!discussionData) return;
const { discussion } = discussionData;
discussion.lastComment = replyToDiscussion.lastComment;
discussion.comments.elements.push(replyToDiscussion.lastComment);
discussion.comments.total += 1;
const { discussion: discussionCached } = discussionData;
discussionCached.lastComment = replyToDiscussion.lastComment;
discussionCached.comments.elements.push(replyToDiscussion.lastComment);
discussionCached.comments.total += 1;
store.writeQuery({
query: GET_DISCUSSION,
variables: { slug: this.slug, page: this.page },
data: { discussion },
data: { discussion: discussionCached },
});
},
// We don't need to handle cache update since there's the subscription that handles this for us
// We don't need to handle cache update since
// there's the subscription that handles this for us
});
this.newComment = "";
}
async updateComment(comment: IComment): Promise<void> {
const { data } = await this.$apollo.mutate<{ deleteComment: IComment }>({
await this.$apollo.mutate<{ deleteComment: IComment }>({
mutation: UPDATE_COMMENT,
variables: {
commentId: comment.id,
@@ -256,25 +257,25 @@ export default class discussion extends mixins(GroupMixin) {
},
});
if (!discussionData) return;
const { discussion } = discussionData;
const index = discussion.comments.elements.findIndex(
const { discussion: discussionCached } = discussionData;
const index = discussionCached.comments.elements.findIndex(
({ id }) => id === data.deleteComment.id
);
if (index > -1) {
discussion.comments.elements.splice(index, 1);
discussion.comments.total -= 1;
discussionCached.comments.elements.splice(index, 1);
discussionCached.comments.total -= 1;
}
store.writeQuery({
query: GET_DISCUSSION,
variables: { slug: this.slug, page: this.page },
data: { discussion },
data: { discussion: discussionCached },
});
},
});
}
async deleteComment(comment: IComment): Promise<void> {
const { data } = await this.$apollo.mutate<{ deleteComment: IComment }>({
await this.$apollo.mutate<{ deleteComment: IComment }>({
mutation: DELETE_COMMENT,
variables: {
commentId: comment.id,
@@ -291,21 +292,21 @@ export default class discussion extends mixins(GroupMixin) {
},
});
if (!discussionData) return;
const { discussion } = discussionData;
const index = discussion.comments.elements.findIndex(
const { discussion: discussionCached } = discussionData;
const index = discussionCached.comments.elements.findIndex(
({ id }) => id === data.deleteComment.id
);
if (index > -1) {
const updatedComment = discussion.comments.elements[index];
const updatedComment = discussionCached.comments.elements[index];
updatedComment.deletedAt = new Date();
updatedComment.actor = null;
updatedComment.text = "";
discussion.comments.elements.splice(index, 1, updatedComment);
discussionCached.comments.elements.splice(index, 1, updatedComment);
}
store.writeQuery({
query: GET_DISCUSSION,
variables: { slug: this.slug, page: this.page },
data: { discussion },
data: { discussion: discussionCached },
});
},
});
@@ -327,13 +328,13 @@ export default class discussion extends mixins(GroupMixin) {
if (!fetchMoreResult) return previousResult;
const newComments = fetchMoreResult.discussion.comments.elements;
this.hasMoreComments = newComments.length === 1;
const { discussion } = previousResult;
discussion.comments.elements = [
const { discussion: discussionCached } = previousResult;
discussionCached.comments.elements = [
...previousResult.discussion.comments.elements,
...newComments,
];
return { discussion };
return { discussion: discussionCached };
},
});
} catch (e) {
@@ -359,12 +360,12 @@ export default class discussion extends mixins(GroupMixin) {
},
});
if (!discussionData) return;
const { discussion } = discussionData;
discussion.title = updateDiscussion.title;
const { discussion: discussionCached } = discussionData;
discussionCached.title = updateDiscussion.title;
store.writeQuery({
query: GET_DISCUSSION,
variables: { slug: this.slug, page: this.page },
data: { discussion },
data: { discussion: discussionCached },
});
},
});

View File

@@ -11,8 +11,8 @@
</template>
<script lang="ts">
import { ErrorCode } from "@/types/enums";
import { Component, Vue } from "vue-property-decorator";
import { ErrorCode } from "@/types/error-code.model";
@Component
export default class ErrorPage extends Vue {
@@ -20,7 +20,7 @@ export default class ErrorPage extends Vue {
ErrorCode = ErrorCode;
mounted() {
mounted(): void {
this.code = this.$route.query.code as ErrorCode;
}
}

View File

@@ -353,8 +353,13 @@ import IdentityPickerWrapper from "@/views/Account/IdentityPickerWrapper.vue";
import Subtitle from "@/components/Utils/Subtitle.vue";
import { Route } from "vue-router";
import { formatList } from "@/utils/i18n";
import { CommentModeration } from "../../types/event-options.model";
import { ParticipantRole } from "../../types/participant.model";
import {
CommentModeration,
EventJoinOptions,
EventStatus,
EventVisibility,
ParticipantRole,
} from "@/types/enums";
import OrganizerPickerWrapper from "../../components/Event/OrganizerPickerWrapper.vue";
import {
CREATE_EVENT,
@@ -362,13 +367,7 @@ import {
EVENT_PERSON_PARTICIPATION,
FETCH_EVENT,
} from "../../graphql/event";
import {
EventJoinOptions,
EventModel,
EventStatus,
EventVisibility,
IEvent,
} from "../../types/event.model";
import { EventModel, IEvent } from "../../types/event.model";
import {
CURRENT_ACTOR_CLIENT,
LOGGED_USER_DRAFTS,
@@ -837,9 +836,9 @@ export default class EditEvent extends Vue {
/**
* Confirm cancel
*/
confirmGoElsewhere(callback: (value?: string) => any): void | Function {
confirmGoElsewhere(callback: (value?: string) => any): void {
if (!this.isEventModified) {
return callback();
callback();
}
const title: string = this.isUpdate
? (this.$t("Cancel edition") as string)
@@ -872,7 +871,8 @@ export default class EditEvent extends Vue {
this.confirmGoElsewhere(() => this.$router.go(-1));
}
beforeRouteLeave(to: Route, from: Route, next: Function): void {
// eslint-disable-next-line consistent-return
beforeRouteLeave(to: Route, from: Route, next: () => void): void {
if (to.name === RouteName.EVENT) return next();
this.confirmGoElsewhere(() => next());
}

View File

@@ -504,6 +504,7 @@
<script lang="ts">
import { Component, Prop, Watch } from "vue-property-decorator";
import BIcon from "buefy/src/components/icon/Icon.vue";
import { EventJoinOptions, EventStatus, EventVisibility, ParticipantRole } from "@/types/enums";
import {
EVENT_PERSON_PARTICIPATION,
EVENT_PERSON_PARTICIPATION_SUBSCRIPTION_CHANGED,
@@ -511,13 +512,7 @@ import {
JOIN_EVENT,
} from "../../graphql/event";
import { CURRENT_ACTOR_CLIENT } from "../../graphql/actor";
import {
EventModel,
EventStatus,
EventVisibility,
IEvent,
EventJoinOptions,
} from "../../types/event.model";
import { EventModel, IEvent } from "../../types/event.model";
import { IActor, IPerson, Person, usernameWithDomain } from "../../types/actor";
import { GRAPHQL_API_ENDPOINT } from "../../api/_entrypoint";
import DateCalendarIcon from "../../components/Event/DateCalendarIcon.vue";
@@ -546,7 +541,7 @@ import Tag from "../../components/Tag.vue";
import EventMetadataBlock from "../../components/Event/EventMetadataBlock.vue";
import ActorCard from "../../components/Account/ActorCard.vue";
import PopoverActorCard from "../../components/Account/PopoverActorCard.vue";
import { IParticipant, ParticipantRole } from "../../types/participant.model";
import { IParticipant } from "../../types/participant.model";
@Component({
components: {

View File

@@ -74,7 +74,8 @@ import Subtitle from "@/components/Utils/Subtitle.vue";
import EventListViewCard from "@/components/Event/EventListViewCard.vue";
import { CURRENT_ACTOR_CLIENT, PERSON_MEMBERSHIPS } from "@/graphql/actor";
import GroupMixin from "@/mixins/group";
import { IGroup, IMember, IPerson, usernameWithDomain } from "../../types/actor";
import { IMember } from "@/types/actor/member.model";
import { IGroup, IPerson, usernameWithDomain } from "../../types/actor";
@Component({
apollo: {

View File

@@ -88,7 +88,8 @@
<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
import { IParticipant, Participant, ParticipantRole } from "../../types/participant.model";
import { ParticipantRole } from "@/types/enums";
import { IParticipant, Participant } from "../../types/participant.model";
import { LOGGED_USER_PARTICIPATIONS, LOGGED_USER_DRAFTS } from "../../graphql/actor";
import { EventModel, IEvent } from "../../types/event.model";
import EventListCard from "../../components/Event/EventListCard.vue";

View File

@@ -185,7 +185,8 @@
<script lang="ts">
import { Component, Prop, Vue, Watch, Ref } from "vue-property-decorator";
import { IParticipant, ParticipantRole } from "../../types/participant.model";
import { ParticipantRole } from "@/types/enums";
import { IParticipant } from "../../types/participant.model";
import { IEvent, IEventParticipantStats } from "../../types/event.model";
import { PARTICIPANTS, UPDATE_PARTICIPANT } from "../../graphql/event";
import { CURRENT_ACTOR_CLIENT } from "../../graphql/actor";

View File

@@ -67,14 +67,15 @@
<script lang="ts">
import { Component, Watch } from "vue-property-decorator";
import { Group, IPerson, usernameWithDomain, MemberRole } from "@/types/actor";
import { Group, IPerson, usernameWithDomain } from "@/types/actor";
import { CURRENT_ACTOR_CLIENT, PERSON_MEMBERSHIPS } from "@/graphql/actor";
import { CREATE_GROUP } from "@/graphql/group";
import PictureUpload from "@/components/PictureUpload.vue";
import { mixins } from "vue-class-component";
import IdentityEditionMixin from "@/mixins/identityEdition";
import { MemberRole } from "@/types/enums";
import RouteName from "../../router/name";
import { convertToUsername } from "../../utils/username";
import PictureUpload from "../../components/PictureUpload.vue";
@Component({
components: {

View File

@@ -362,7 +362,7 @@
<script lang="ts">
import { Component, Prop, Watch } from "vue-property-decorator";
import EventCard from "@/components/Event/EventCard.vue";
import { IActor, usernameWithDomain, MemberRole, IMember, Openness } from "@/types/actor";
import { IActor, usernameWithDomain } from "@/types/actor";
import Subtitle from "@/components/Utils/Subtitle.vue";
import CompactTodo from "@/components/Todo/CompactTodo.vue";
import EventMinimalistCard from "@/components/Event/EventMinimalistCard.vue";
@@ -380,6 +380,8 @@ import { IConfig } from "@/types/config.model";
import GroupMixin from "@/mixins/group";
import { mixins } from "vue-class-component";
import { JOIN_GROUP } from "@/graphql/member";
import { MemberRole, Openness } from "@/types/enums";
import { IMember } from "@/types/actor/member.model";
import RouteName from "../../router/name";
import GroupSection from "../../components/Group/GroupSection.vue";
import ReportModal from "../../components/Report/ReportModal.vue";

View File

@@ -184,10 +184,11 @@ import { Component, Watch } from "vue-property-decorator";
import GroupMixin from "@/mixins/group";
import { mixins } from "vue-class-component";
import { FETCH_GROUP } from "@/graphql/group";
import { MemberRole } from "@/types/enums";
import { IMember } from "@/types/actor/member.model";
import RouteName from "../../router/name";
import { INVITE_MEMBER, GROUP_MEMBERS, REMOVE_MEMBER, UPDATE_MEMBER } from "../../graphql/member";
import { usernameWithDomain } from "../../types/actor";
import { IMember, MemberRole } from "../../types/actor/group.model";
@Component({
apollo: {

View File

@@ -152,9 +152,10 @@ import { Route } from "vue-router";
import PictureUpload from "@/components/PictureUpload.vue";
import { mixins } from "vue-class-component";
import GroupMixin from "@/mixins/group";
import { Openness } from "@/types/enums";
import RouteName from "../../router/name";
import { UPDATE_GROUP, DELETE_GROUP } from "../../graphql/group";
import { IGroup, usernameWithDomain, Openness } from "../../types/actor";
import { IGroup, usernameWithDomain } from "../../types/actor";
import { Address, IAddress } from "../../types/address.model";
@Component({

View File

@@ -51,8 +51,10 @@ import { LEAVE_GROUP } from "@/graphql/group";
import GroupMemberCard from "@/components/Group/GroupMemberCard.vue";
import Invitations from "@/components/Group/Invitations.vue";
import { Paginate } from "@/types/paginate";
import { IGroup, IMember, MemberRole, usernameWithDomain } from "@/types/actor";
import { IGroup, usernameWithDomain } from "@/types/actor";
import { Route } from "vue-router";
import { IMember } from "@/types/actor/member.model";
import { MemberRole } from "@/types/enums";
import RouteName from "../../router/name";
@Component({

View File

@@ -126,8 +126,7 @@
</span>
<div>
<EventListCard
v-for="participation in row[1]"
v-if="isInLessThanSevenDays(row[0])"
v-for="participation in thisWeek(row)"
@event-deleted="eventDeleted"
:key="participation[1].id"
:participation="participation[1]"
@@ -173,7 +172,8 @@
<script lang="ts">
import { Component, Vue, Watch } from "vue-property-decorator";
import { IParticipant, Participant, ParticipantRole } from "../types/participant.model";
import { ParticipantRole } from "@/types/enums";
import { IParticipant, Participant } from "../types/participant.model";
import { FETCH_EVENTS } from "../graphql/event";
import EventListCard from "../components/Event/EventListCard.vue";
import EventCard from "../components/Event/EventCard.vue";
@@ -286,6 +286,13 @@ export default class Home extends Vue {
return window.localStorage.getItem("new-registered-user") === "yes";
}
thisWeek(row: [string, Map<string, IParticipant>]): Map<string, IParticipant> {
if (this.isInLessThanSevenDays(row[0])) {
return row[1];
}
return new Map();
}
// eslint-disable-next-line class-methods-use-this
mounted(): void {
if (window.localStorage.getItem("welcome-back")) {

View File

@@ -1,32 +0,0 @@
<template>
<div>{{ center.lat }} - {{ center.lng }}</div>
</template>
<script lang="ts">
import { Component, Prop, Vue } from "vue-property-decorator";
@Component
export default class Location extends Vue {
@Prop(String) address!: string;
description = "Paris, France";
center = { lat: 48.85, lng: 2.35 };
markers: any[] = [];
setPlace(place: any) {
this.center = {
lat: place.geometry.location.lat(),
lng: place.geometry.location.lng(),
};
this.markers = [
{
position: { lat: this.center.lat, lng: this.center.lng },
},
];
this.$emit("input", place.formatted_address);
}
}
</script>

View File

@@ -158,9 +158,10 @@
</template>
<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
import { IActionLog, ActionLogAction } from "@/types/report.model";
import { IActionLog } from "@/types/report.model";
import { LOGS } from "@/graphql/report";
import ReportCard from "@/components/Report/ReportCard.vue";
import { ActionLogAction } from "@/types/enums";
import RouteName from "../../router/name";
import { displayNameAndUsername } from "../../types/actor";

View File

@@ -241,14 +241,15 @@
<script lang="ts">
import { Component, Prop, Vue } from "vue-property-decorator";
import { CREATE_REPORT_NOTE, REPORT, UPDATE_REPORT } from "@/graphql/report";
import { IReport, IReportNote, ReportStatusEnum } from "@/types/report.model";
import { IReport, IReportNote } from "@/types/report.model";
import { CURRENT_ACTOR_CLIENT } from "@/graphql/actor";
import { IPerson, ActorType, displayNameAndUsername } from "@/types/actor";
import { IPerson, displayNameAndUsername } from "@/types/actor";
import { DELETE_EVENT } from "@/graphql/event";
import { uniq } from "lodash";
import { nl2br } from "@/utils/html";
import { DELETE_COMMENT } from "@/graphql/comment";
import { IComment } from "@/types/comment.model";
import { ActorType, ReportStatusEnum } from "@/types/enums";
import RouteName from "../../router/name";
@Component({

View File

@@ -45,9 +45,10 @@
</template>
<script lang="ts">
import { Component, Vue, Watch } from "vue-property-decorator";
import { IReport, ReportStatusEnum } from "@/types/report.model";
import { IReport } from "@/types/report.model";
import { REPORTS } from "@/graphql/report";
import ReportCard from "@/components/Report/ReportCard.vue";
import { ReportStatusEnum } from "@/types/enums";
import RouteName from "../../router/name";
@Component({

View File

@@ -46,8 +46,8 @@ export default class PageNotFound extends Vue {
return this.$t("Search events, groups, etc.") as string;
}
enter() {
this.$router.push({
async enter(): Promise<void> {
await this.$router.push({
name: RouteName.SEARCH,
query: { term: this.searchText },
});

View File

@@ -105,11 +105,12 @@ import { mixins } from "vue-class-component";
import { FETCH_GROUP } from "@/graphql/group";
import { buildFileFromIMedia, readFileAsync } from "@/utils/image";
import GroupMixin from "@/mixins/group";
import { PostVisibility } from "@/types/enums";
import { TAGS } from "../../graphql/tags";
import { CONFIG } from "../../graphql/config";
import { FETCH_POST, CREATE_POST, UPDATE_POST, DELETE_POST } from "../../graphql/post";
import { IPost, PostVisibility } from "../../types/post.model";
import { IPost } from "../../types/post.model";
import Editor from "../../components/Editor.vue";
import { IActor, IGroup, usernameWithDomain } from "../../types/actor";
import TagInput from "../../components/Event/TagInput.vue";

View File

@@ -82,10 +82,11 @@ import { Component, Prop } from "vue-property-decorator";
import { CURRENT_ACTOR_CLIENT, PERSON_MEMBERSHIPS } from "@/graphql/actor";
import { mixins } from "vue-class-component";
import GroupMixin from "@/mixins/group";
import { IMember } from "@/types/actor/member.model";
import { FETCH_GROUP_POSTS } from "../../graphql/post";
import { Paginate } from "../../types/paginate";
import { IPost } from "../../types/post.model";
import { IGroup, IMember, IPerson, usernameWithDomain } from "../../types/actor";
import { IGroup, IPerson, usernameWithDomain } from "../../types/actor";
import RouteName from "../../router/name";
import PostElementItem from "../../components/Post/PostElementItem.vue";

View File

@@ -47,13 +47,14 @@
<script lang="ts">
import { Component, Prop } from "vue-property-decorator";
import { mixins } from "vue-class-component";
import Editor from "@/components/Editor.vue";
import GroupMixin from "@/mixins/group";
import { PostVisibility } from "@/types/enums";
import { IMember } from "@/types/actor/member.model";
import { CURRENT_ACTOR_CLIENT, PERSON_MEMBERSHIPS } from "../../graphql/actor";
import { FETCH_POST } from "../../graphql/post";
import { IPost, PostVisibility } from "../../types/post.model";
import { IMember, IPerson, usernameWithDomain } from "../../types/actor";
import { IPost } from "../../types/post.model";
import { IPerson, usernameWithDomain } from "../../types/actor";
import RouteName from "../../router/name";
import Tag from "../../components/Tag.vue";

View File

@@ -21,9 +21,8 @@
>
</li>
<li
v-if="resource.path !== '/'"
:class="{ 'is-active': index + 1 === ResourceMixin.resourcePathArray(resource).length }"
v-for="(pathFragment, index) in ResourceMixin.resourcePathArray(resource)"
v-for="(pathFragment, index) in filteredPath"
:key="pathFragment"
>
<router-link
@@ -145,8 +144,8 @@
<resource-selector
:initialResource="updatedResource"
:username="usernameWithDomain(resource.actor)"
@updateResource="moveResource"
@closeMoveModal="moveModal = false"
@update-resource="moveResource"
@close-move-modal="moveModal = false"
/>
</section>
</div>
@@ -303,6 +302,13 @@ export default class Resources extends Mixins(ResourceMixin) {
return path[0] !== "/" ? `/${path}` : path;
}
get filteredPath(): string[] {
if (this.resource && this.resource.path !== "/") {
return ResourceMixin.resourcePathArray(this.resource);
}
return [];
}
async createResource(): Promise<void> {
if (!this.resource.actor) return;
try {

View File

@@ -152,6 +152,7 @@ import {
startOfMonth,
eachWeekendOfInterval,
} from "date-fns";
import { SearchTabs } from "@/types/enums";
import EventCard from "../components/Event/EventCard.vue";
import { FETCH_EVENTS } from "../graphql/event";
import { IEvent } from "../types/event.model";
@@ -160,7 +161,6 @@ import { IAddress, Address } from "../types/address.model";
import AddressAutoComplete from "../components/Event/AddressAutoComplete.vue";
import { SEARCH_EVENTS, SEARCH_GROUPS } from "../graphql/search";
import { Paginate } from "../types/paginate";
import { SearchTabs } from "../types/search.model";
import { IGroup } from "../types/actor";
import GroupCard from "../components/Group/GroupCard.vue";
import { CONFIG } from "../graphql/config";

View File

@@ -10,14 +10,13 @@
</div>
</template>
<script lang="ts">
import { Component, Vue, Watch } from "vue-property-decorator";
import { Route } from "vue-router";
import { Component, Vue } from "vue-property-decorator";
import SettingsMenu from "../components/Settings/SettingsMenu.vue";
import RouteName from "../router/name";
import { IPerson, Person } from "../types/actor";
import { IDENTITIES } from "../graphql/actor";
import { CURRENT_USER_CLIENT } from "../graphql/user";
import { ICurrentUser, ICurrentUserRole } from "../types/current-user.model";
import { ICurrentUser } from "../types/current-user.model";
@Component({
components: { SettingsMenu },

View File

@@ -176,11 +176,12 @@
</template>
<script lang="ts">
import { IAuthProvider } from "@/types/enums";
import { Component, Vue, Ref } from "vue-property-decorator";
import { Route } from "vue-router";
import { CHANGE_EMAIL, CHANGE_PASSWORD, DELETE_ACCOUNT, LOGGED_USER } from "../../graphql/user";
import RouteName from "../../router/name";
import { IUser, IAuthProvider } from "../../types/current-user.model";
import { IUser } from "../../types/current-user.model";
import { logout, SELECTED_PROVIDERS } from "../../utils/auth";
@Component({
@@ -299,7 +300,7 @@ export default class AccountSettings extends Vue {
get hasUserGotAPassword(): boolean {
return (
this.loggedUser &&
(this.loggedUser.provider == null || this.loggedUser.provider == IAuthProvider.LDAP)
(this.loggedUser.provider == null || this.loggedUser.provider === IAuthProvider.LDAP)
);
}

View File

@@ -102,8 +102,9 @@
</template>
<script lang="ts">
import { Component, Vue, Watch } from "vue-property-decorator";
import { INotificationPendingEnum } from "@/types/enums";
import { USER_SETTINGS, SET_USER_SETTINGS } from "../../graphql/user";
import { IUser, INotificationPendingEnum } from "../../types/current-user.model";
import { IUser } from "../../types/current-user.model";
import RouteName from "../../router/name";
@Component({

View File

@@ -42,11 +42,12 @@
</template>
<script lang="ts">
import { Component, Prop, Vue } from "vue-property-decorator";
import { ITodo, ITodoList } from "@/types/todos";
import { ITodo } from "@/types/todos";
import { CREATE_TODO, FETCH_TODO_LIST } from "@/graphql/todos";
import CompactTodo from "@/components/Todo/CompactTodo.vue";
import { CURRENT_ACTOR_CLIENT } from "@/graphql/actor";
import { IActor } from "@/types/actor";
import { ITodoList } from "@/types/todolist";
import RouteName from "../../router/name";
@Component({
@@ -77,7 +78,7 @@ export default class TodoList extends Vue {
RouteName = RouteName;
async createNewTodo() {
async createNewTodo(): Promise<void> {
await this.$apollo.mutate({
mutation: CREATE_TODO,
variables: {

View File

@@ -54,9 +54,9 @@
import { Component, Prop, Vue } from "vue-property-decorator";
import { FETCH_GROUP } from "@/graphql/group";
import { IGroup, usernameWithDomain } from "@/types/actor";
import { ITodoList } from "@/types/todos";
import { CREATE_TODO_LIST } from "@/graphql/todos";
import CompactTodo from "@/components/Todo/CompactTodo.vue";
import { ITodoList } from "@/types/todolist";
import RouteName from "../../router/name";
@Component({

View File

@@ -98,14 +98,14 @@
<script lang="ts">
import { Component, Prop, Vue } from "vue-property-decorator";
import { Route } from "vue-router";
import { ICurrentUser } from "@/types/current-user.model";
import { LoginError, LoginErrorCode } from "@/types/enums";
import { LOGIN } from "../../graphql/auth";
import { validateEmailField, validateRequiredField } from "../../utils/validators";
import { initializeCurrentActor, NoIdentitiesException, saveUserData } from "../../utils/auth";
import { ILogin } from "../../types/login.model";
import { CURRENT_USER_CLIENT, UPDATE_CURRENT_USER_CLIENT } from "../../graphql/user";
import RouteName from "../../router/name";
import { LoginErrorCode, LoginError } from "../../types/login-error-code.model";
import { ICurrentUser } from "../../types/current-user.model";
import { CONFIG } from "../../graphql/config";
import { IConfig } from "../../types/config.model";
import AuthProviders from "../../components/User/AuthProviders.vue";

View File

@@ -52,21 +52,21 @@ export default class PasswordReset extends Vue {
errors: string[] = [];
rules = {
passwordLength: (value: string) =>
passwordLength: (value: string): boolean | string =>
value.length > 6 || "Password must be at least 6 characters long",
required: validateRequiredField,
passwordEqual: (value: string) =>
passwordEqual: (value: string): boolean | string =>
value === this.credentials.password || "Passwords must be the same",
};
get samePasswords() {
get samePasswords(): boolean {
return (
this.rules.passwordLength(this.credentials.password) === true &&
this.credentials.password === this.credentials.passwordConfirmation
);
}
async resetAction(e: Event) {
async resetAction(e: Event): Promise<void> {
e.preventDefault();
this.errors.splice(0);

View File

@@ -1,59 +1,58 @@
<template></template>
<script lang="ts">
import { Component, Prop, Vue } from "vue-property-decorator";
import { VALIDATE_USER, UPDATE_CURRENT_USER_CLIENT, LOGGED_USER } from "../../graphql/user";
import { Component, Vue } from "vue-property-decorator";
import { ICurrentUserRole } from "@/types/enums";
import { UPDATE_CURRENT_USER_CLIENT, LOGGED_USER } from "../../graphql/user";
import RouteName from "../../router/name";
import { saveUserData, changeIdentity } from "../../utils/auth";
import { ILogin } from "../../types/login.model";
import { ICurrentUserRole, ICurrentUser, IUser } from "../../types/current-user.model";
import { IDENTITIES } from "../../graphql/actor";
import { IUser } from "../../types/current-user.model";
@Component
export default class ProviderValidate extends Vue {
async mounted() {
async mounted(): Promise<void> {
const accessToken = this.getValueFromMeta("auth-access-token");
const refreshToken = this.getValueFromMeta("auth-refresh-token");
const userId = this.getValueFromMeta("auth-user-id");
const userEmail = this.getValueFromMeta("auth-user-email");
const userRole = this.getValueFromMeta("auth-user-role") as ICurrentUserRole;
const userActorId = this.getValueFromMeta("auth-user-actor-id");
if (!(userId && userEmail && userRole && accessToken && refreshToken)) {
return this.$router.push("/");
}
const login = {
user: { id: userId, email: userEmail, role: userRole, isLoggedIn: true },
accessToken,
refreshToken,
};
saveUserData(login);
await this.$apollo.mutate({
mutation: UPDATE_CURRENT_USER_CLIENT,
variables: {
id: userId,
email: userEmail,
isLoggedIn: true,
role: ICurrentUserRole.USER,
},
});
const { data } = await this.$apollo.query<{ loggedUser: IUser }>({
query: LOGGED_USER,
});
const { loggedUser } = data;
if (loggedUser.defaultActor) {
await changeIdentity(this.$apollo.provider.defaultClient, loggedUser.defaultActor);
await this.$router.push({ name: RouteName.HOME });
await this.$router.push("/");
} else {
// If the user didn't register any profile yet, let's create one for them
await this.$router.push({
name: RouteName.REGISTER_PROFILE,
params: { email: loggedUser.email, userAlreadyActivated: "true" },
const login = {
user: { id: userId, email: userEmail, role: userRole, isLoggedIn: true },
accessToken,
refreshToken,
};
saveUserData(login);
await this.$apollo.mutate({
mutation: UPDATE_CURRENT_USER_CLIENT,
variables: {
id: userId,
email: userEmail,
isLoggedIn: true,
role: ICurrentUserRole.USER,
},
});
const { data } = await this.$apollo.query<{ loggedUser: IUser }>({
query: LOGGED_USER,
});
const { loggedUser } = data;
if (loggedUser.defaultActor) {
await changeIdentity(this.$apollo.provider.defaultClient, loggedUser.defaultActor);
await this.$router.push({ name: RouteName.HOME });
} else {
// If the user didn't register any profile yet, let's create one for them
await this.$router.push({
name: RouteName.REGISTER_PROFILE,
params: { email: loggedUser.email, userAlreadyActivated: "true" },
});
}
}
}
getValueFromMeta(name: string) {
// eslint-disable-next-line class-methods-use-this
getValueFromMeta(name: string): string | null {
const element = document.querySelector(`meta[name="${name}"]`);
if (element && element.getAttribute("content")) {
return element.getAttribute("content");

View File

@@ -143,7 +143,6 @@
<script lang="ts">
import { Component, Prop, Vue } from "vue-property-decorator";
import { Route } from "vue-router";
import { CREATE_USER } from "../../graphql/user";
import RouteName from "../../router/name";
import { IConfig } from "../../types/config.model";

View File

@@ -68,11 +68,11 @@ export default class ResendConfirmation extends Vue {
email: validateEmailField,
};
mounted() {
mounted(): void {
this.credentials.email = this.email;
}
async resendConfirmationAction(e: Event) {
async resendConfirmationAction(e: Event): Promise<void> {
e.preventDefault();
this.error = false;

View File

@@ -16,11 +16,11 @@
<script lang="ts">
import { Component, Prop, Vue } from "vue-property-decorator";
import { ICurrentUserRole } from "@/types/enums";
import { VALIDATE_USER, UPDATE_CURRENT_USER_CLIENT } from "../../graphql/user";
import RouteName from "../../router/name";
import { saveUserData, saveTokenData, changeIdentity } from "../../utils/auth";
import { ILogin } from "../../types/login.model";
import { ICurrentUserRole } from "../../types/current-user.model";
@Component
export default class Validate extends Vue {
@@ -30,11 +30,11 @@ export default class Validate extends Vue {
failed = false;
async created() {
async created(): Promise<void> {
await this.validateAction();
}
async validateAction() {
async validateAction(): Promise<void> {
try {
const { data } = await this.$apollo.mutate<{ validateUser: ILogin }>({
mutation: VALIDATE_USER,