Merge branch 'master' into deployment-secrets

This commit is contained in:
Ulf Gebhardt 2023-03-14 20:24:54 +01:00 committed by GitHub
commit 895ba16ab1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 170 additions and 64 deletions

View File

@ -16,6 +16,7 @@ export default {
Group: async (_object, params, context, _resolveInfo) => { Group: async (_object, params, context, _resolveInfo) => {
const { isMember, id, slug, first, offset } = params const { isMember, id, slug, first, offset } = params
let pagination = '' let pagination = ''
const orderBy = 'ORDER BY group.createdAt DESC'
if (first !== undefined && offset !== undefined) pagination = `SKIP ${offset} LIMIT ${first}` if (first !== undefined && offset !== undefined) pagination = `SKIP ${offset} LIMIT ${first}`
const matchParams = { id, slug } const matchParams = { id, slug }
removeUndefinedNullValuesFromObject(matchParams) removeUndefinedNullValuesFromObject(matchParams)
@ -29,6 +30,7 @@ export default {
WITH group, membership WITH group, membership
WHERE (group.groupType IN ['public', 'closed']) OR (group.groupType = 'hidden' AND membership.role IN ['usual', 'admin', 'owner']) WHERE (group.groupType IN ['public', 'closed']) OR (group.groupType = 'hidden' AND membership.role IN ['usual', 'admin', 'owner'])
RETURN group {.*, myRole: membership.role} RETURN group {.*, myRole: membership.role}
${orderBy}
${pagination} ${pagination}
` `
} else { } else {
@ -39,6 +41,7 @@ export default {
WITH group WITH group
WHERE group.groupType IN ['public', 'closed'] WHERE group.groupType IN ['public', 'closed']
RETURN group {.*, myRole: NULL} RETURN group {.*, myRole: NULL}
${orderBy}
${pagination} ${pagination}
` `
} else { } else {
@ -48,6 +51,7 @@ export default {
WITH group, membership WITH group, membership
WHERE (group.groupType IN ['public', 'closed']) OR (group.groupType = 'hidden' AND membership.role IN ['usual', 'admin', 'owner']) WHERE (group.groupType IN ['public', 'closed']) OR (group.groupType = 'hidden' AND membership.role IN ['usual', 'admin', 'owner'])
RETURN group {.*, myRole: membership.role} RETURN group {.*, myRole: membership.role}
${orderBy}
${pagination} ${pagination}
` `
} }

View File

@ -59,8 +59,8 @@ describe('NotificationsTable.vue', () => {
wrapper = Wrapper() wrapper = Wrapper()
}) })
it('renders a table', () => { it('renders a grid table', () => {
expect(wrapper.find('.ds-table').exists()).toBe(true) expect(wrapper.find('.notification-grid').exists()).toBe(true)
}) })
describe('renders 4 columns', () => { describe('renders 4 columns', () => {
@ -84,7 +84,7 @@ describe('NotificationsTable.vue', () => {
describe('Post', () => { describe('Post', () => {
let firstRowNotification let firstRowNotification
beforeEach(() => { beforeEach(() => {
firstRowNotification = wrapper.findAll('tbody tr').at(0) firstRowNotification = wrapper.findAll('.notification-grid-row').at(0)
}) })
it('renders the author', () => { it('renders the author', () => {
@ -117,7 +117,7 @@ describe('NotificationsTable.vue', () => {
describe('Comment', () => { describe('Comment', () => {
let secondRowNotification let secondRowNotification
beforeEach(() => { beforeEach(() => {
secondRowNotification = wrapper.findAll('tbody tr').at(1) secondRowNotification = wrapper.findAll('.notification-grid-row').at(1)
}) })
it('renders the author', () => { it('renders the author', () => {

View File

@ -1,62 +1,108 @@
<template> <template>
<ds-table v-if="notifications && notifications.length" :data="notifications" :fields="fields"> <div class="notification-grid" v-if="notifications && notifications.length">
<template #icon="scope"> <ds-grid>
<base-icon <ds-grid-item v-if="!isMobile" column-span="fullWidth">
v-if="scope.row.from.post" <ds-grid class="header-grid">
name="comment" <ds-grid-item v-for="field in fields" :key="field.label" class="ds-table-head-col">
v-tooltip="{ content: $t('notifications.comment'), placement: 'right' }" {{ field.label }}
/> </ds-grid-item>
<base-icon </ds-grid>
v-else </ds-grid-item>
name="bookmark" <ds-grid-item
v-tooltip="{ content: $t('notifications.post'), placement: 'right' }" v-for="notification in notifications"
/> :key="notification.id"
</template> column-span="fullWidth"
<template #user="scope"> class="notification-grid-row"
<ds-space margin-bottom="base">
<client-only>
<user-teaser
:user="scope.row.from.author"
:date-time="scope.row.from.createdAt"
:class="{ 'notification-status': scope.row.read }"
/>
</client-only>
</ds-space>
<ds-text :class="{ 'notification-status': scope.row.read, reason: true }">
{{ $t(`notifications.reason.${scope.row.reason}`) }}
</ds-text>
</template>
<template #post="scope">
<nuxt-link
class="notification-mention-post"
:class="{ 'notification-status': scope.row.read }"
:to="{
name: 'post-id-slug',
params: params(scope.row.from),
hash: hashParam(scope.row.from),
}"
@click.native="markNotificationAsRead(scope.row.from.id)"
> >
<b>{{ scope.row.from.title || scope.row.from.post.title | truncate(50) }}</b> <ds-grid>
</nuxt-link> <ds-grid-item>
</template> <ds-flex class="user-section">
<template #content="scope"> <ds-flex-item :width="{ base: '20%' }">
<b :class="{ 'notification-status': scope.row.read }"> <div>
{{ scope.row.from.contentExcerpt | removeHtml }} <base-card :wide-content="true">
</b> <base-icon
</template> v-if="notification.from.post"
</ds-table> name="comment"
v-tooltip="{ content: $t('notifications.comment'), placement: 'right' }"
/>
<base-icon
v-else
name="bookmark"
v-tooltip="{ content: $t('notifications.post'), placement: 'right' }"
/>
</base-card>
</div>
</ds-flex-item>
<ds-flex-item>
<div>
<base-card :wide-content="true">
<ds-space margin-bottom="base">
<client-only>
<user-teaser
:user="notification.from.author"
:date-time="notification.from.createdAt"
:class="{ 'notification-status': notification.read }"
/>
</client-only>
</ds-space>
<ds-text :class="{ 'notification-status': notification.read, reason: true }">
{{ $t(`notifications.reason.${notification.reason}`) }}
</ds-text>
</base-card>
</div>
</ds-flex-item>
</ds-flex>
</ds-grid-item>
<ds-grid-item>
<ds-flex class="content-section" :direction="{ base: 'column', xs: 'row' }">
<ds-flex-item>
<base-card :wide-content="true">
<nuxt-link
class="notification-mention-post"
:class="{ 'notification-status': notification.read }"
:to="{
name: 'post-id-slug',
params: params(notification.from),
hash: hashParam(notification.from),
}"
@click.native="markNotificationAsRead(notification.from.id)"
>
<b>
{{ notification.from.title || notification.from.post.title | truncate(50) }}
</b>
</nuxt-link>
</base-card>
</ds-flex-item>
<ds-flex-item>
<base-card :wide-content="true">
<b :class="{ 'notification-status': notification.read }">
{{ notification.from.contentExcerpt | removeHtml }}
</b>
</base-card>
</ds-flex-item>
</ds-flex>
</ds-grid-item>
</ds-grid>
</ds-grid-item>
</ds-grid>
</div>
<hc-empty v-else icon="alert" :message="$t('notifications.empty')" /> <hc-empty v-else icon="alert" :message="$t('notifications.empty')" />
</template> </template>
<script> <script>
import UserTeaser from '~/components/UserTeaser/UserTeaser' import UserTeaser from '~/components/UserTeaser/UserTeaser'
import HcEmpty from '~/components/Empty/Empty' import HcEmpty from '~/components/Empty/Empty'
import BaseCard from '../_new/generic/BaseCard/BaseCard.vue'
import mobile from '~/mixins/mobile'
const maxMobileWidth = 768 // at this point the table breaks down
export default { export default {
components: { components: {
UserTeaser, UserTeaser,
HcEmpty, HcEmpty,
BaseCard,
}, },
mixins: [mobile(maxMobileWidth)],
props: { props: {
notifications: { type: Array, default: () => [] }, notifications: { type: Array, default: () => [] },
}, },
@ -106,4 +152,39 @@ export default {
.notification-status { .notification-status {
opacity: $opacity-soft; opacity: $opacity-soft;
} }
/* fix to override flex-wrap style of ds flex component */
.notification-grid .content-section {
flex-wrap: nowrap;
}
.notification-grid .ds-grid.header-grid {
grid-template-columns: 1fr 4fr 3fr 3fr !important;
}
.notification-grid-row {
border-top: 1px dotted #e5e3e8;
}
.notification-grid .base-card {
border-radius: 0;
box-shadow: none;
padding: 16px 4px;
}
/* dirty fix to override broken styleguide inline-styles */
.notification-grid .ds-grid {
grid-template-columns: 5fr 6fr !important;
grid-auto-rows: auto !important;
grid-template-rows: 1fr;
gap: 0px !important;
}
@media screen and (max-width: 768px) {
.notification-grid .ds-grid {
grid-template-columns: 1fr !important;
}
.notification-grid .content-section {
border-top: 1px dotted #e5e3e8;
}
.notification-grid-row {
box-shadow: 0px 12px 26px -4px rgb(0 0 0 / 10%);
margin-top: 5px;
border-top: none;
}
}
</style> </style>

View File

@ -15,7 +15,13 @@
<img :src="post.image | proxyApiUrl" class="image" /> <img :src="post.image | proxyApiUrl" class="image" />
</template> </template>
<client-only> <client-only>
<user-teaser :user="post.author" :group="post.group" :date-time="post.createdAt" /> <div class="post-user-row">
<user-teaser :user="post.author" :group="post.group" :date-time="post.createdAt" />
<hc-ribbon
:class="[isPinned ? '--pinned' : '', post.image ? 'post-ribbon-w-img' : 'post-ribbon']"
:text="isPinned ? $t('post.pinned') : $t('post.name')"
/>
</div>
</client-only> </client-only>
<h2 class="title hyphenate-text">{{ post.title }}</h2> <h2 class="title hyphenate-text">{{ post.title }}</h2>
<!-- TODO: replace editor content with tiptap render view --> <!-- TODO: replace editor content with tiptap render view -->
@ -73,10 +79,6 @@
</client-only> </client-only>
</footer> </footer>
</base-card> </base-card>
<hc-ribbon
:class="{ '--pinned': isPinned }"
:text="isPinned ? $t('post.pinned') : $t('post.name')"
/>
</nuxt-link> </nuxt-link>
</template> </template>
@ -192,19 +194,38 @@ export default {
display: block; display: block;
height: 100%; height: 100%;
color: $text-color-base; color: $text-color-base;
}
> .ribbon { .post-user-row {
position: relative;
> .post-ribbon-w-img {
position: absolute; position: absolute;
top: 50%; // 14px (~height of ribbon element) + 24px(=margin of hero image)
right: -7px; top: -38px;
// 7px+24px(=padding of parent)
right: -31px;
}
> .post-ribbon {
position: absolute;
// 14px (~height of ribbon element) + 24px(=margin of hero image)
top: -24px;
// 7px(=offset)+24px(=margin of parent)
right: -31px;
} }
} }
.post-teaser > .base-card { .post-teaser > .base-card {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
overflow: visible;
height: 100%; height: 100%;
> .hero-image {
border-top-left-radius: 5px;
border-top-right-radius: 5px;
}
&.--blur-image > .hero-image > .image { &.--blur-image > .hero-image > .image {
filter: blur($blur-radius); filter: blur($blur-radius);
} }

View File

@ -134,15 +134,15 @@ describe('PostIndex', () => {
}) })
describe('donation-info', () => { describe('donation-info', () => {
it('shows donation-info on default', () => { it('hides donation-info on default', () => {
wrapper = Wrapper() wrapper = Wrapper()
expect(wrapper.find('.top-info-bar').exists()).toBe(true) expect(wrapper.find('.top-info-bar').exists()).toBe(false)
}) })
it('hides donation-info if not "showDonations"', async () => { it('shows donation-info if "showDonations"', async () => {
wrapper = Wrapper() wrapper = Wrapper()
await wrapper.setData({ showDonations: false }) await wrapper.setData({ showDonations: true })
expect(wrapper.find('.top-info-bar').exists()).toBe(false) expect(wrapper.find('.top-info-bar').exists()).toBe(true)
}) })
}) })
}) })

View File

@ -152,7 +152,7 @@ export default {
hideByScroll: false, hideByScroll: false,
revScrollpos: 0, revScrollpos: 0,
showFilter: false, showFilter: false,
showDonations: true, showDonations: false,
goal: 15000, goal: 15000,
progress: 7000, progress: 7000,
posts: [], posts: [],