Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 🍰 Add Group To User Teaser, On Post Page, And On News Feed Etc. #5502

Merged
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ jobs:
report_name: Coverage Webapp
type: lcov
result_path: ./coverage/lcov.info
min_coverage: 65
min_coverage: 64
token: ${{ github.token }}

##############################################################################
Expand Down
2 changes: 2 additions & 0 deletions webapp/components/ContributionForm/ContributionForm.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ describe('ContributionForm.vue', () => {
categoryIds: [],
id: null,
image: null,
groupId: null,
},
}
postTitleInput = wrapper.find('.ds-input')
Expand Down Expand Up @@ -260,6 +261,7 @@ describe('ContributionForm.vue', () => {
content: propsData.contribution.content,
categoryIds: [],
id: propsData.contribution.id,
groupId: null,
image: {
sensitive: false,
},
Expand Down
5 changes: 5 additions & 0 deletions webapp/components/ContributionForm/ContributionForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ export default {
type: Object,
default: () => ({}),
},
groupId: {
type: String,
default: () => null,
},
},
data() {
const { title, content, image, categories } = this.contribution
Expand Down Expand Up @@ -173,6 +177,7 @@ export default {
categoryIds,
id: this.contribution.id || null,
image,
groupId: this.groupId,
},
})
.then(({ data }) => {
Expand Down
2 changes: 1 addition & 1 deletion webapp/components/PostTeaser/PostTeaser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<img :src="post.image | proxyApiUrl" class="image" />
</template>
<client-only>
<user-teaser :user="post.author" :date-time="post.createdAt" />
<user-teaser :user="post.author" :group="post.group" :date-time="post.createdAt" />
</client-only>
<h2 class="title hyphenate-text">{{ post.title }}</h2>
<!-- TODO: replace editor content with tiptap render view -->
Expand Down
55 changes: 54 additions & 1 deletion webapp/components/UserTeaser/UserTeaser.story.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,41 @@ export const user = {
followedBy: [],
socialMedia: [],
}
export const group = {
id: 'g2',
name: 'Yoga Practice',
slug: 'yoga-practice',
about: null,
description: `<h3>What Is yoga?</h3><p>Yoga is not just about practicing asanas. It's about how we do it.</p><p class="">And practicing asanas doesn't have to be yoga, it can be more athletic than yogic.</p><h3>What makes practicing asanas yogic?</h3><p class="">The important thing is:</p><ul><li><p>Use the exercises (consciously) for your personal development.</p></li></ul>`,
descriptionExcerpt: `<h3>What Is yoga?</h3><p>Yoga is not just about practicing asanas. It's about how we do it.</p><p>And practicing asanas doesn't have to be yoga, it can be more athletic than yogic.</p><h3>What makes practicing asanas yogic?</h3><p>The important thing is:</p><ul><li><p>Use the exercises …</p></li></ul>`,
groupType: 'public',
actionRadius: 'interplanetary',
categories: [
{
id: 'cat4',
icon: 'psyche',
name: 'psyche',
slug: 'psyche',
description: 'Seele, Gefühle, Glück',
},
{
id: 'cat5',
icon: 'movement',
name: 'body-and-excercise',
slug: 'body-and-excercise',
description: 'Sport, Yoga, Massage, Tanzen, Entspannung',
},
{
id: 'cat17',
icon: 'spirituality',
name: 'spirituality',
slug: 'spirituality',
description: 'Religion, Werte, Ethik',
},
],
locationName: null,
location: null,
}

storiesOf('UserTeaser', module)
.addDecorator(withA11y)
Expand All @@ -68,7 +103,7 @@ storiesOf('UserTeaser', module)
}),
template: '<user-teaser :user="user" />',
}))
.add('with Date', () => ({
.add('with date', () => ({
components: { UserTeaser },
store: helpers.store,
data: () => ({
Expand Down Expand Up @@ -98,3 +133,21 @@ storiesOf('UserTeaser', module)
}),
template: '<user-teaser :user="user" :date-time="new Date()" />',
}))
.add('with group and date', () => ({
components: { UserTeaser },
store: helpers.store,
data: () => ({
user,
group,
}),
template: '<user-teaser :user="user" :group="group" :date-time="new Date()" />',
}))
.add('with group and date – wide', () => ({
components: { UserTeaser },
store: helpers.store,
data: () => ({
user,
group,
}),
template: '<user-teaser :user="user" :group="group" wide :date-time="new Date()" />',
}))
78 changes: 60 additions & 18 deletions webapp/components/UserTeaser/UserTeaser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,53 @@
<span class="info anonymous">{{ $t('profile.userAnonym') }}</span>
</div>
<div v-else :class="[{ 'disabled-content': user.disabled }]" placement="top-start">
<nuxt-link :to="userLink" :class="['user-teaser']">
<profile-avatar v-if="showAvatar" :profile="user" size="small" />
<div class="info">
<span class="text">
<span class="slug">{{ userSlug }}</span>
<span v-if="dateTime">{{ userName }}</span>
</span>
<span v-if="dateTime" class="text">
<div :class="['user-teaser']">
<nuxt-link :to="userLink">
<profile-avatar v-if="showAvatar" :profile="user" size="small" />
</nuxt-link>
<div class="info flex-direction-column">
<div :class="wide ? 'flex-direction-row' : 'flex-direction-column'">
<nuxt-link :to="userLink">
<span class="text">
<span class="slug">{{ userSlug }}</span>
<span v-if="!userOnly" class="name">{{ userName }}</span>
</span>
</nuxt-link>
<span v-if="wide">&nbsp;&nbsp;&nbsp;</span>
<nuxt-link v-if="group" :to="groupLink">
<span class="text">
<span class="slug">{{ groupSlug }}</span>
<span v-if="!userOnly" class="name">{{ groupName }}</span>
</span>
</nuxt-link>
</div>
<span v-if="!userOnly" class="text">
<base-icon name="clock" />
<hc-relative-date-time :date-time="dateTime" />
<relative-date-time :date-time="dateTime" />
<slot name="dateTime"></slot>
</span>
<span v-else class="text">{{ userName }}</span>
</div>
</nuxt-link>
</div>
</div>
</template>

<script>
import { mapGetters } from 'vuex'

import HcRelativeDateTime from '~/components/RelativeDateTime'
import RelativeDateTime from '~/components/RelativeDateTime'
import ProfileAvatar from '~/components/_new/generic/ProfileAvatar/ProfileAvatar'

export default {
name: 'UserTeaser',
components: {
HcRelativeDateTime,
RelativeDateTime,
ProfileAvatar,
},
props: {
user: { type: Object, default: null },
group: { type: Object, default: null },
wide: { type: Boolean, default: false },
showAvatar: { type: Boolean, default: true },
dateTime: { type: [Date, String], default: null },
showPopover: { type: Boolean, default: true },
Expand Down Expand Up @@ -64,6 +79,22 @@ export default {
const { name } = this.user || {}
return name || this.$t('profile.userAnonym')
},
userOnly() {
return !this.dateTime && !this.group
},
groupLink() {
const { id, slug } = this.group
if (!(id && slug)) return ''
return { name: 'group-id-slug', params: { slug, id } }
},
groupSlug() {
const { slug } = this.group || {}
return slug && `&${slug}`
},
groupName() {
const { name } = this.group || {}
return name || this.$t('profile.userAnonym')
},
},
methods: {
optimisticFollow({ followedByCurrentUser }) {
Expand Down Expand Up @@ -93,17 +124,11 @@ export default {
}

> .info {
display: flex;
flex-direction: column;
justify-content: center;
padding-left: $space-xx-small;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;

color: $text-color-soft;
font-size: $font-size-small;

&.anonymous {
font-size: $font-size-base;
}
Expand All @@ -112,6 +137,23 @@ export default {
color: $color-primary;
font-size: $font-size-base;
}

.name {
color: $text-color-soft;
font-size: $font-size-small;
}
}

.flex-direction-column {
display: flex;
flex-direction: column;
justify-content: center;
}

.flex-direction-row {
display: flex;
flex-direction: row;
justify-content: center;
}

.text {
Expand Down
16 changes: 14 additions & 2 deletions webapp/graphql/PostMutations.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,20 @@ import gql from 'graphql-tag'
export default () => {
return {
CreatePost: gql`
mutation ($title: String!, $content: String!, $categoryIds: [ID], $image: ImageInput) {
CreatePost(title: $title, content: $content, categoryIds: $categoryIds, image: $image) {
mutation (
$title: String!
$content: String!
$categoryIds: [ID]
$image: ImageInput
$groupId: ID
) {
CreatePost(
title: $title
content: $content
categoryIds: $categoryIds
image: $image
groupId: $groupId
) {
title
slug
content
Expand Down
15 changes: 15 additions & 0 deletions webapp/graphql/PostQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ export default (i18n) => {
...locationAndBadges
}
}
group {
id
name
slug
}
}
}
`
Expand All @@ -64,6 +69,11 @@ export const filterPosts = (i18n) => {
...userCounts
...locationAndBadges
}
group {
id
name
slug
}
}
}
`
Expand Down Expand Up @@ -94,6 +104,11 @@ export const profilePagePosts = (i18n) => {
...userCounts
...locationAndBadges
}
group {
id
name
slug
}
}
}
`
Expand Down
18 changes: 18 additions & 0 deletions webapp/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,19 @@
"submitted": "Kommentar gesendet",
"updated": "Änderungen gespeichert"
},
"createNewPost": {
"forGroup": {
"title": "Für die Gruppe „{name}“"
},
"title": "Erstelle einen neuen Beitrag"
},
"edited": "bearbeitet",
"editPost": {
"forGroup": {
"title": "Für die Gruppe „{name}“"
},
"title": "Bearbeite deinen Beitrag"
},
"menu": {
"delete": "Beitrag löschen",
"edit": "Beitrag bearbeiten",
Expand All @@ -618,6 +630,12 @@
"pinned": "Meldung",
"takeAction": {
"name": "Aktiv werden"
},
"viewPost": {
"forGroup": {
"title": "In der Gruppe „{name}“"
},
"title": "Beitrag"
}
},
"profile": {
Expand Down
18 changes: 18 additions & 0 deletions webapp/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,19 @@
"submitted": "Comment submitted!",
"updated": "Changes saved!"
},
"createNewPost": {
"forGroup": {
"title": "For The Group “{name}”"
},
"title": "Create A New Post"
},
"edited": "edited",
"editPost": {
"forGroup": {
"title": "For The Group “{name}”"
},
"title": "Edit Your Post"
},
"menu": {
"delete": "Delete post",
"edit": "Edit post",
Expand All @@ -618,6 +630,12 @@
"pinned": "Announcement",
"takeAction": {
"name": "Take action"
},
"viewPost": {
"forGroup": {
"title": "In The Group “{name}”"
},
"title": "Post"
}
},
"profile": {
Expand Down
Loading