Merge pull request #5502 from Ocelot-Social-Community/5059-groups/5501-add-group-link-to-posts-in-webapp

This commit is contained in:
Wolfgang Huß 2022-10-22 11:13:25 +02:00 committed by GitHub
commit 2e50e616a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 162 additions and 50 deletions

View File

@ -1,7 +1,7 @@
import { When } from "cypress-cucumber-preprocessor/steps";
When('I click on the author', () => {
cy.get('.user-teaser')
cy.get('[data-test="avatarUserLink"]')
.click()
.url().should('include', '/profile/')
})

View File

@ -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 -->

View File

@ -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)
@ -68,7 +103,7 @@ storiesOf('UserTeaser', module)
}),
template: '<user-teaser :user="user" />',
}))
.add('with Date', () => ({
.add('with date', () => ({
components: { UserTeaser },
store: helpers.store,
data: () => ({
@ -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()" />',
}))

View File

@ -4,38 +4,58 @@
<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" data-test="avatarUserLink">
<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;</span>
<span v-if="group">
<span class="text">
{{ $t('group.in') }}
</span>
<nuxt-link :to="groupLink">
<span class="text">
<span class="slug">{{ groupSlug }}</span>
<span v-if="!userOnly" class="name">{{ groupName }}</span>
</span>
</nuxt-link>
</span>
</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 },
@ -64,6 +84,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 }) {
@ -93,17 +129,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;
}
@ -112,6 +142,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 {

View File

@ -69,6 +69,11 @@ export const filterPosts = (i18n) => {
...userCounts
...locationAndBadges
}
group {
id
name
slug
}
}
}
`
@ -99,6 +104,11 @@ export const profilePagePosts = (i18n) => {
...userCounts
...locationAndBadges
}
group {
id
name
slug
}
}
}
`

View File

@ -426,6 +426,7 @@
"general": "Allgemein",
"goal": "Ziel der Gruppe",
"groupCreated": "Die Gruppe wurde angelegt!",
"in": "in",
"joinLeaveButton": {
"iAmMember": "Bin Mitglied",
"join": "Beitreten"

View File

@ -426,6 +426,7 @@
"general": "General",
"goal": "Goal of group",
"groupCreated": "The group was created!",
"in": "in",
"joinLeaveButton": {
"iAmMember": "I'm a member",
"join": "Join"

View File

@ -244,8 +244,8 @@ describe('GroupProfileSlug', () => {
})
it('has group slug', () => {
expect(wrapper.find('[data-test="at"]').exists()).toBe(true)
expect(wrapper.text()).toContain('yoga-practice')
// expect(wrapper.find('[data-test="ampersand"]').exists()).toBe(true)
expect(wrapper.text()).toContain('&yoga-practice')
})
describe('displays no(!) group location because is "null"', () => {
@ -397,8 +397,8 @@ describe('GroupProfileSlug', () => {
})
it('has group slug', () => {
expect(wrapper.find('[data-test="at"]').exists()).toBe(true)
expect(wrapper.text()).toContain('yoga-practice')
// expect(wrapper.find('[data-test="ampersand"]').exists()).toBe(true)
expect(wrapper.text()).toContain('&yoga-practice')
})
describe('displays no(!) group location because is "null"', () => {
@ -510,8 +510,8 @@ describe('GroupProfileSlug', () => {
})
it('has group slug', () => {
expect(wrapper.find('[data-test="at"]').exists()).toBe(true)
expect(wrapper.text()).toContain('yoga-practice')
// expect(wrapper.find('[data-test="ampersand"]').exists()).toBe(true)
expect(wrapper.text()).toContain('&yoga-practice')
})
describe('displays no(!) group location because is "null"', () => {
@ -623,8 +623,8 @@ describe('GroupProfileSlug', () => {
})
it('has group slug', () => {
expect(wrapper.find('[data-test="at"]').exists()).toBe(true)
expect(wrapper.text()).toContain('yoga-practice')
// expect(wrapper.find('[data-test="ampersand"]').exists()).toBe(true)
expect(wrapper.text()).toContain('&yoga-practice')
})
describe('displays no(!) group location because is "null"', () => {
@ -740,8 +740,8 @@ describe('GroupProfileSlug', () => {
})
it('has group slug', () => {
expect(wrapper.find('[data-test="at"]').exists()).toBe(true)
expect(wrapper.text()).toContain('school-for-citizens')
// expect(wrapper.find('[data-test="ampersand"]').exists()).toBe(true)
expect(wrapper.text()).toContain('&school-for-citizens')
})
describe('displays group location', () => {
@ -857,8 +857,8 @@ describe('GroupProfileSlug', () => {
})
it('has group slug', () => {
expect(wrapper.find('[data-test="at"]').exists()).toBe(true)
expect(wrapper.text()).toContain('school-for-citizens')
// expect(wrapper.find('[data-test="ampersand"]').exists()).toBe(true)
expect(wrapper.text()).toContain('&school-for-citizens')
})
describe('displays group location', () => {
@ -974,8 +974,8 @@ describe('GroupProfileSlug', () => {
})
it('has group slug', () => {
expect(wrapper.find('[data-test="at"]').exists()).toBe(true)
expect(wrapper.text()).toContain('school-for-citizens')
// expect(wrapper.find('[data-test="ampersand"]').exists()).toBe(true)
expect(wrapper.text()).toContain('&school-for-citizens')
})
describe('displays group location', () => {
@ -1091,8 +1091,8 @@ describe('GroupProfileSlug', () => {
})
it('has group slug', () => {
expect(wrapper.find('[data-test="at"]').exists()).toBe(true)
expect(wrapper.text()).toContain('school-for-citizens')
// expect(wrapper.find('[data-test="ampersand"]').exists()).toBe(true)
expect(wrapper.text()).toContain('&school-for-citizens')
})
describe('displays group location', () => {
@ -1212,8 +1212,8 @@ describe('GroupProfileSlug', () => {
})
it('has group slug', () => {
expect(wrapper.find('[data-test="at"]').exists()).toBe(true)
expect(wrapper.text()).toContain('investigative-journalism')
// expect(wrapper.find('[data-test="ampersand"]').exists()).toBe(true)
expect(wrapper.text()).toContain('&investigative-journalism')
})
describe('displays group location', () => {
@ -1332,8 +1332,8 @@ describe('GroupProfileSlug', () => {
})
it('has group slug', () => {
expect(wrapper.find('[data-test="at"]').exists()).toBe(true)
expect(wrapper.text()).toContain('investigative-journalism')
// expect(wrapper.find('[data-test="ampersand"]').exists()).toBe(true)
expect(wrapper.text()).toContain('&investigative-journalism')
})
describe('displays group location', () => {
@ -1452,8 +1452,8 @@ describe('GroupProfileSlug', () => {
})
it('has no(!) group slug', () => {
expect(wrapper.find('[data-test="at"]').exists()).toBe(false)
expect(wrapper.text()).not.toContain('investigative-journalism')
// expect(wrapper.find('[data-test="ampersand"]').exists()).toBe(false)
expect(wrapper.text()).not.toContain('&investigative-journalism')
})
describe('displays not(!) group location', () => {
@ -1560,8 +1560,8 @@ describe('GroupProfileSlug', () => {
})
it('has no(!) group slug', () => {
expect(wrapper.find('[data-test="at"]').exists()).toBe(false)
expect(wrapper.text()).not.toContain('investigative-journalism')
// expect(wrapper.find('[data-test="ampersand"]').exists()).toBe(false)
expect(wrapper.text()).not.toContain('&investigative-journalism')
})
describe('displays not(!) group location', () => {

View File

@ -38,8 +38,8 @@
</ds-heading>
<!-- group slug -->
<ds-text align="center" color="soft">
<base-icon name="at" data-test="at" />
{{ groupSlug }}
<!-- <base-icon name="at" data-test="ampersand" /> -->
{{ `&${groupSlug}` }}
</ds-text>
<!-- group location -->
<ds-text v-if="group && group.location" align="center" color="soft" size="small">

View File

@ -33,7 +33,7 @@
</aside>
</template>
<section class="menu">
<user-teaser :user="post.author" :date-time="post.createdAt">
<user-teaser :user="post.author" :group="post.group" wide :date-time="post.createdAt">
<template #dateTime>
<ds-text v-if="post.createdAt !== post.updatedAt">
({{ $t('post.edited') }})

View File

@ -31,8 +31,8 @@
{{ userName }}
</ds-heading>
<ds-text align="center" color="soft">
<base-icon name="at" />
{{ userSlug }}
<!-- <base-icon name="at" data-test="at" /> -->
{{ `@${userSlug}` }}
</ds-text>
<ds-text v-if="user.location" align="center" color="soft" size="small">
<base-icon name="map-marker" />