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

Shows number of actions which are pending moderation. #698

Merged
merged 5 commits into from
Nov 14, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 9 additions & 0 deletions app/API/graphql_queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,12 @@ export const loggedInUserUnreadNotificationsCount = gql`
}
}
`

export const loggedInUserPendingModerationCount = gql`
query LoggedInUserUnreadNotificationsCount {
loggedInUser {
id
actions_pending_moderation
}
}
`
22 changes: 19 additions & 3 deletions app/components/App/Sidebar.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import React from 'react'
import { connect } from 'react-redux'
import { Link } from 'react-router'
import { Query } from 'react-apollo'
import { withNamespaces } from 'react-i18next'
import classNames from 'classnames'
import { get } from 'lodash'
import capitalize from 'voca/capitalize'
import { Flex } from '@rebass/grid'

Expand All @@ -15,12 +17,14 @@ import { Facebook } from 'styled-icons/fa-brands/Facebook'

import { LinkExternal } from 'styled-icons/octicons/LinkExternal'

import { loggedInUserPendingModerationCount } from '../../API/graphql_queries'
import { MOBILE_WIDTH_THRESHOLD, MIN_REPUTATION_MODERATION } from '../../constants'
import RawIcon from '../Utils/RawIcon'
import ReputationGuard from '../Utils/ReputationGuard'
import { closeSidebar, toggleSidebar } from '../../state/user_preferences/reducer'
import UserLanguageSelector from '../LoggedInUser/UserLanguageSelector'
import ExternalLinkNewTab from '../Utils/ExternalLinkNewTab'
import Tag from '../Utils/Tag'

@connect((state) => ({ sidebarExpended: state.UserPreferences.sidebarExpended }), {
toggleSidebar,
Expand Down Expand Up @@ -142,9 +146,21 @@ export default class Sidebar extends React.PureComponent {
{capitalize(t('entities.video_plural'))}
</this.MenuListLink>
<ReputationGuard requiredRep={MIN_REPUTATION_MODERATION}>
<this.MenuListLink to="/moderation" iconName="flag">
{t('menu.moderation')}
</this.MenuListLink>
<Query
fetchPolicy="network-only"
pollInterval={25000}
query={loggedInUserPendingModerationCount}
>
{({ data }) => {
const pendingCount = get(data, 'loggedInUser.actions_pending_moderation', 0)
return (
<this.MenuListLink to="/moderation" iconName="flag">
{t('menu.moderation')}
<Tag type="danger">{pendingCount}</Tag>
</this.MenuListLink>
)
}}
</Query>
</ReputationGuard>
</ul>
)
Expand Down
4 changes: 4 additions & 0 deletions app/styles/_components/App/sidebar.sass
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ $border-color: lightgrey

.menu-content
padding: 9px
& .tag
margin: 0 5px

.link-with-icon > i
width: 20px
Expand Down Expand Up @@ -104,6 +106,8 @@ $border-color: lightgrey
width: 100%
&> span
display: none
&> .tag
margin: 0 5px

.connect-register-buttons
margin-bottom: 5px
Expand Down