mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Merge pull request #6116 from Ocelot-Social-Community/6016-feature-refactor-notification-page
feat(webapp): refactor notification page
This commit is contained in:
commit
e36af318ec
@ -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', () => {
|
||||||
|
|||||||
@ -1,8 +1,27 @@
|
|||||||
<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>
|
||||||
|
<ds-grid-item v-if="!isMobile" column-span="fullWidth">
|
||||||
|
<ds-grid class="header-grid">
|
||||||
|
<ds-grid-item v-for="field in fields" :key="field.label" class="ds-table-head-col">
|
||||||
|
{{ field.label }}
|
||||||
|
</ds-grid-item>
|
||||||
|
</ds-grid>
|
||||||
|
</ds-grid-item>
|
||||||
|
<ds-grid-item
|
||||||
|
v-for="notification in notifications"
|
||||||
|
:key="notification.id"
|
||||||
|
column-span="fullWidth"
|
||||||
|
class="notification-grid-row"
|
||||||
|
>
|
||||||
|
<ds-grid>
|
||||||
|
<ds-grid-item>
|
||||||
|
<ds-flex class="user-section">
|
||||||
|
<ds-flex-item :width="{ base: '20%' }">
|
||||||
|
<div>
|
||||||
|
<base-card :wide-content="true">
|
||||||
<base-icon
|
<base-icon
|
||||||
v-if="scope.row.from.post"
|
v-if="notification.from.post"
|
||||||
name="comment"
|
name="comment"
|
||||||
v-tooltip="{ content: $t('notifications.comment'), placement: 'right' }"
|
v-tooltip="{ content: $t('notifications.comment'), placement: 'right' }"
|
||||||
/>
|
/>
|
||||||
@ -11,52 +30,79 @@
|
|||||||
name="bookmark"
|
name="bookmark"
|
||||||
v-tooltip="{ content: $t('notifications.post'), placement: 'right' }"
|
v-tooltip="{ content: $t('notifications.post'), placement: 'right' }"
|
||||||
/>
|
/>
|
||||||
</template>
|
</base-card>
|
||||||
<template #user="scope">
|
</div>
|
||||||
|
</ds-flex-item>
|
||||||
|
<ds-flex-item>
|
||||||
|
<div>
|
||||||
|
<base-card :wide-content="true">
|
||||||
<ds-space margin-bottom="base">
|
<ds-space margin-bottom="base">
|
||||||
<client-only>
|
<client-only>
|
||||||
<user-teaser
|
<user-teaser
|
||||||
:user="scope.row.from.author"
|
:user="notification.from.author"
|
||||||
:date-time="scope.row.from.createdAt"
|
:date-time="notification.from.createdAt"
|
||||||
:class="{ 'notification-status': scope.row.read }"
|
:class="{ 'notification-status': notification.read }"
|
||||||
/>
|
/>
|
||||||
</client-only>
|
</client-only>
|
||||||
</ds-space>
|
</ds-space>
|
||||||
<ds-text :class="{ 'notification-status': scope.row.read, reason: true }">
|
<ds-text :class="{ 'notification-status': notification.read, reason: true }">
|
||||||
{{ $t(`notifications.reason.${scope.row.reason}`) }}
|
{{ $t(`notifications.reason.${notification.reason}`) }}
|
||||||
</ds-text>
|
</ds-text>
|
||||||
</template>
|
</base-card>
|
||||||
<template #post="scope">
|
</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
|
<nuxt-link
|
||||||
class="notification-mention-post"
|
class="notification-mention-post"
|
||||||
:class="{ 'notification-status': scope.row.read }"
|
:class="{ 'notification-status': notification.read }"
|
||||||
:to="{
|
:to="{
|
||||||
name: 'post-id-slug',
|
name: 'post-id-slug',
|
||||||
params: params(scope.row.from),
|
params: params(notification.from),
|
||||||
hash: hashParam(scope.row.from),
|
hash: hashParam(notification.from),
|
||||||
}"
|
}"
|
||||||
@click.native="markNotificationAsRead(scope.row.from.id)"
|
@click.native="markNotificationAsRead(notification.from.id)"
|
||||||
>
|
>
|
||||||
<b>{{ scope.row.from.title || scope.row.from.post.title | truncate(50) }}</b>
|
<b>
|
||||||
</nuxt-link>
|
{{ notification.from.title || notification.from.post.title | truncate(50) }}
|
||||||
</template>
|
|
||||||
<template #content="scope">
|
|
||||||
<b :class="{ 'notification-status': scope.row.read }">
|
|
||||||
{{ scope.row.from.contentExcerpt | removeHtml }}
|
|
||||||
</b>
|
</b>
|
||||||
</template>
|
</nuxt-link>
|
||||||
</ds-table>
|
</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>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user