Merge branch 'exclude-drafts-in-group-preview' into 'master'

Hide drafts and visibility limited content on group public preview page

Closes #775

See merge request framasoft/mobilizon!990
This commit is contained in:
Thomas Citharel 2021-07-21 10:50:36 +00:00
commit 05af6e50a3
2 changed files with 36 additions and 8 deletions

View file

@ -18,6 +18,7 @@ export interface IGroup extends IActor {
todoLists: Paginate<ITodoList>; todoLists: Paginate<ITodoList>;
discussions: Paginate<IDiscussion>; discussions: Paginate<IDiscussion>;
organizedEvents: Paginate<IEvent>; organizedEvents: Paginate<IEvent>;
posts: Paginate<IPost>;
physicalAddress: IAddress; physicalAddress: IAddress;
openness: Openness; openness: Openness;
visibility: GroupVisibility; visibility: GroupVisibility;

View file

@ -473,10 +473,10 @@
<subtitle>{{ $t("Upcoming events") }}</subtitle> <subtitle>{{ $t("Upcoming events") }}</subtitle>
<div <div
class="organized-events-wrapper" class="organized-events-wrapper"
v-if="group && group.organizedEvents.total > 0" v-if="group && organizedEvents.elements.length > 0"
> >
<EventMinimalistCard <EventMinimalistCard
v-for="event in group.organizedEvents.elements" v-for="event in organizedEvents.elements"
:event="event" :event="event"
:key="event.uuid" :key="event.uuid"
class="organized-event" class="organized-event"
@ -487,20 +487,20 @@
</empty-content> </empty-content>
<b-skeleton animated v-else-if="$apollo.loading"></b-skeleton> <b-skeleton animated v-else-if="$apollo.loading"></b-skeleton>
<router-link <router-link
v-if="group.organizedEvents.total > 0" v-if="organizedEvents.total > 0"
:to="{ :to="{
name: RouteName.GROUP_EVENTS, name: RouteName.GROUP_EVENTS,
params: { preferredUsername: usernameWithDomain(group) }, params: { preferredUsername: usernameWithDomain(group) },
query: { future: group.organizedEvents.elements.length > 0 }, query: { future: organizedEvents.elements.length > 0 },
}" }"
>{{ $t("View all events") }}</router-link >{{ $t("View all events") }}</router-link
> >
</section> </section>
<section> <section>
<subtitle>{{ $t("Latest posts") }}</subtitle> <subtitle>{{ $t("Latest posts") }}</subtitle>
<div v-if="group.posts.total > 0" class="posts-wrapper"> <div v-if="posts.elements.length > 0" class="posts-wrapper">
<post-list-item <post-list-item
v-for="post in group.posts.elements" v-for="post in posts.elements"
:key="post.id" :key="post.id"
:post="post" :post="post"
/> />
@ -510,7 +510,7 @@
</empty-content> </empty-content>
<b-skeleton animated v-else-if="$apollo.loading"></b-skeleton> <b-skeleton animated v-else-if="$apollo.loading"></b-skeleton>
<router-link <router-link
v-if="group.posts.total > 0" v-if="posts.total > 0"
:to="{ :to="{
name: RouteName.POSTS, name: RouteName.POSTS,
params: { preferredUsername: usernameWithDomain(group) }, params: { preferredUsername: usernameWithDomain(group) },
@ -579,7 +579,7 @@ import { IConfig } from "@/types/config.model";
import GroupMixin from "@/mixins/group"; import GroupMixin from "@/mixins/group";
import { mixins } from "vue-class-component"; import { mixins } from "vue-class-component";
import { JOIN_GROUP } from "@/graphql/member"; import { JOIN_GROUP } from "@/graphql/member";
import { MemberRole, Openness } from "@/types/enums"; import { MemberRole, Openness, PostVisibility } from "@/types/enums";
import { IMember } from "@/types/actor/member.model"; import { IMember } from "@/types/actor/member.model";
import RouteName from "../../router/name"; import RouteName from "../../router/name";
import GroupSection from "../../components/Group/GroupSection.vue"; import GroupSection from "../../components/Group/GroupSection.vue";
@ -589,6 +589,9 @@ import { LEAVE_GROUP } from "@/graphql/group";
import LazyImageWrapper from "../../components/Image/LazyImageWrapper.vue"; import LazyImageWrapper from "../../components/Image/LazyImageWrapper.vue";
import EventMetadataBlock from "../../components/Event/EventMetadataBlock.vue"; import EventMetadataBlock from "../../components/Event/EventMetadataBlock.vue";
import EmptyContent from "../../components/Utils/EmptyContent.vue"; import EmptyContent from "../../components/Utils/EmptyContent.vue";
import { Paginate } from "@/types/paginate";
import { IEvent } from "@/types/event.model";
import { IPost } from "@/types/post.model";
@Component({ @Component({
apollo: { apollo: {
@ -880,6 +883,30 @@ export default class Group extends mixins(GroupMixin) {
this.config.anonymous.reports.allowed) this.config.anonymous.reports.allowed)
); );
} }
get organizedEvents(): Paginate<IEvent> {
return {
total: this.group.organizedEvents.total,
elements: this.group.organizedEvents.elements.filter((event: IEvent) => {
if (this.previewPublic) {
return !event.draft; // TODO when events get visibility access add visibility constraint like below for posts
}
return true;
}),
};
}
get posts(): Paginate<IPost> {
return {
total: this.group.posts.total,
elements: this.group.posts.elements.filter((post: IPost) => {
if (this.previewPublic) {
return !(post.draft || post.visibility == PostVisibility.PRIVATE);
}
return true;
}),
};
}
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>