Fix lint issues

And disable eslint when building in prod mode

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2020-11-30 10:24:11 +01:00
parent da42522073
commit 2d541f2e32
161 changed files with 3869 additions and 1236 deletions

View File

@@ -20,7 +20,12 @@
:type="errors.title ? 'is-danger' : null"
:message="errors.title"
>
<b-input size="is-large" aria-required="true" required v-model="post.title" />
<b-input
size="is-large"
aria-required="true"
required
v-model="post.title"
/>
</b-field>
<tag-input v-model="post.tags" :data="tags" path="title" />
@@ -61,7 +66,9 @@
<div class="navbar-menu">
<div class="navbar-end">
<span class="navbar-item">
<b-button type="is-text" @click="$router.go(-1)">{{ $t("Cancel") }}</b-button>
<b-button type="is-text" @click="$router.go(-1)">{{
$t("Cancel")
}}</b-button>
</span>
<span class="navbar-item" v-if="this.isUpdate">
<b-button type="is-danger is-outlined" @click="deletePost">{{
@@ -76,7 +83,9 @@
</span>
<span class="navbar-item">
<b-button type="is-primary" native-type="submit">
<span v-if="isUpdate === false || post.draft === true">{{ $t("Publish") }}</span>
<span v-if="isUpdate === false || post.draft === true">{{
$t("Publish")
}}</span>
<span v-else>{{ $t("Update post") }}</span>
</b-button>
@@ -108,7 +117,12 @@ 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 {
FETCH_POST,
CREATE_POST,
UPDATE_POST,
DELETE_POST,
} from "../../graphql/post";
import { IPost } from "../../types/post.model";
import Editor from "../../components/Editor.vue";
@@ -210,7 +224,10 @@ export default class EditPost extends mixins(GroupMixin) {
},
});
if (data && data.updatePost) {
this.$router.push({ name: RouteName.POST, params: { slug: data.updatePost.slug } });
this.$router.push({
name: RouteName.POST,
params: { slug: data.updatePost.slug },
});
}
} else {
try {
@@ -225,14 +242,22 @@ export default class EditPost extends mixins(GroupMixin) {
},
});
if (data && data.createPost) {
this.$router.push({ name: RouteName.POST, params: { slug: data.createPost.slug } });
this.$router.push({
name: RouteName.POST,
params: { slug: data.createPost.slug },
});
}
} catch (error) {
console.error(error);
this.errors = error.graphQLErrors.reduce((acc: { [key: string]: any }, localError: any) => {
acc[localError.field] = EditPost.transformMessage(localError.message);
return acc;
}, {});
this.errors = error.graphQLErrors.reduce(
(acc: { [key: string]: any }, localError: any) => {
acc[localError.field] = EditPost.transformMessage(
localError.message
);
return acc;
},
{}
);
}
}
}
@@ -247,7 +272,9 @@ export default class EditPost extends mixins(GroupMixin) {
if (data && this.post.attributedTo) {
this.$router.push({
name: RouteName.POSTS,
params: { preferredUsername: usernameWithDomain(this.post.attributedTo) },
params: {
preferredUsername: usernameWithDomain(this.post.attributedTo),
},
});
}
}
@@ -278,9 +305,13 @@ export default class EditPost extends mixins(GroupMixin) {
}
try {
if (this.post.picture) {
const oldPictureFile = (await buildFileFromIMedia(this.post.picture)) as File;
const oldPictureFile = (await buildFileFromIMedia(
this.post.picture
)) as File;
const oldPictureFileContent = await readFileAsync(oldPictureFile);
const newPictureFileContent = await readFileAsync(this.pictureFile as File);
const newPictureFileContent = await readFileAsync(
this.pictureFile as File
);
if (oldPictureFileContent === newPictureFileContent) {
obj.picture = { mediaId: this.post.picture.id };
}
@@ -303,7 +334,8 @@ export default class EditPost extends mixins(GroupMixin) {
return (
this.person &&
this.person.memberships.elements.some(
({ parent: { id }, role }) => id === this.actualGroup.id && roles.includes(role)
({ parent: { id }, role }) =>
id === this.actualGroup.id && roles.includes(role)
)
);
}

View File

@@ -158,7 +158,9 @@ export default class PostList extends mixins(GroupMixin) {
get isCurrentActorMember(): boolean {
if (!this.group || !this.memberships) return false;
return this.memberships.map(({ parent: { id } }) => id).includes(this.group.id);
return this.memberships
.map(({ parent: { id } }) => id)
.includes(this.group.id);
}
}
</script>

View File

@@ -8,20 +8,34 @@
slot="author"
:to="{
name: RouteName.GROUP,
params: { preferredUsername: usernameWithDomain(post.attributedTo) },
params: {
preferredUsername: usernameWithDomain(post.attributedTo),
},
}"
>{{ post.attributedTo.name }}</router-link
>
</i18n>
<p class="published" v-if="!post.draft">{{ post.publishAt | formatDateTimeString }}</p>
<small v-if="post.visibility === PostVisibility.PRIVATE" class="has-text-grey">
<p class="published" v-if="!post.draft">
{{ post.publishAt | formatDateTimeString }}
</p>
<small
v-if="post.visibility === PostVisibility.PRIVATE"
class="has-text-grey"
>
<b-icon icon="lock" size="is-small" />
{{ $t("Accessible only to members", { group: post.attributedTo.name }) }}
{{
$t("Accessible only to members", { group: post.attributedTo.name })
}}
</small>
<p class="buttons" v-if="isCurrentActorMember">
<b-tag type="is-warning" size="is-medium" v-if="post.draft">{{ $t("Draft") }}</b-tag>
<b-tag type="is-warning" size="is-medium" v-if="post.draft">{{
$t("Draft")
}}</b-tag>
<router-link
v-if="currentActor.id === post.author.id || isCurrentActorAGroupModerator"
v-if="
currentActor.id === post.author.id ||
isCurrentActorAGroupModerator
"
:to="{ name: RouteName.POST_EDIT, params: { slug: post.slug } }"
tag="button"
class="button is-text"
@@ -128,7 +142,9 @@ export default class Post extends mixins(GroupMixin) {
get isCurrentActorMember(): boolean {
if (!this.post.attributedTo || !this.memberships) return false;
return this.memberships.map(({ parent: { id } }) => id).includes(this.post.attributedTo.id);
return this.memberships
.map(({ parent: { id } }) => id)
.includes(this.post.attributedTo.id);
}
}
</script>