mirror of
https://github.com/wassname/talk.git
synced 2026-07-05 22:19:12 +08:00
Adds subscriber plugin
This commit is contained in:
@@ -26,5 +26,6 @@ plugins/*
|
||||
!plugins/talk-plugin-toxic-comments
|
||||
!plugins/talk-plugin-remember-sort
|
||||
!plugins/talk-plugin-deep-reply-count
|
||||
!plugins/talk-plugin-subscriber
|
||||
|
||||
node_modules
|
||||
|
||||
@@ -43,5 +43,6 @@ plugins/*
|
||||
!plugins/talk-plugin-toxic-comments
|
||||
!plugins/talk-plugin-remember-sort
|
||||
!plugins/talk-plugin-deep-reply-count
|
||||
!plugins/talk-plugin-subscriber
|
||||
|
||||
**/node_modules/*
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"presets": [
|
||||
"es2015"
|
||||
],
|
||||
"plugins": [
|
||||
"add-module-exports",
|
||||
"transform-class-properties",
|
||||
"transform-decorators-legacy",
|
||||
"transform-object-assign",
|
||||
"transform-object-rest-spread",
|
||||
"transform-async-to-generator",
|
||||
"transform-react-jsx"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"env": {
|
||||
"browser": true,
|
||||
"es6": true,
|
||||
"mocha": true
|
||||
},
|
||||
"parserOptions": {
|
||||
"sourceType": "module",
|
||||
"ecmaFeatures": {
|
||||
"experimentalObjectRestSpread": true,
|
||||
"jsx": true
|
||||
}
|
||||
},
|
||||
"parser": "babel-eslint",
|
||||
"plugins": [
|
||||
"react"
|
||||
],
|
||||
"rules": {
|
||||
"react/jsx-uses-react": "error",
|
||||
"react/jsx-uses-vars": "error",
|
||||
"no-console": ["warn", { "allow": ["warn", "error"] }]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
.badge {
|
||||
background-color: #616161;
|
||||
color: white;
|
||||
display: inline-block;
|
||||
margin: 0px 5px;
|
||||
padding: 5px 5px;
|
||||
border-radius: 2px;
|
||||
font-size: 12px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.6px;
|
||||
font-weight: bold;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import React from 'react';
|
||||
import styles from './SubscriberBadge.css';
|
||||
import {t} from 'plugin-api/beta/client/services';
|
||||
|
||||
export default () =>(
|
||||
<span className={styles.badge}>
|
||||
{t('talk-plugin-subscriber.subscriber')}
|
||||
</span>
|
||||
);
|
||||
@@ -0,0 +1,24 @@
|
||||
import React from 'react';
|
||||
import SubscriberBadge from '../components/SubscriberBadge';
|
||||
import {compose, gql} from 'react-apollo';
|
||||
import {withFragments, excludeIf} from 'plugin-api/beta/client/hocs';
|
||||
|
||||
const isSubscriber = (tags = []) => tags.some((t) => t.tag.name === 'SUBSCRIBER');
|
||||
|
||||
const enhance = compose(
|
||||
withFragments({
|
||||
comment: gql`
|
||||
fragment TalkSubscriberBadge_SubscriberBadge_comment on Comment {
|
||||
user {
|
||||
tags {
|
||||
tag {
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
}`
|
||||
}),
|
||||
excludeIf(({comment}) => !isSubscriber(comment.user.tags))
|
||||
);
|
||||
|
||||
export default enhance(SubscriberBadge);
|
||||
@@ -0,0 +1,10 @@
|
||||
import SubscriberBadge from './containers/SubscriberBadge';
|
||||
import translations from './translations.yml';
|
||||
import {gql} from 'react-apollo';
|
||||
|
||||
export default {
|
||||
translations,
|
||||
slots: {
|
||||
commentAuthorTags: [SubscriberBadge]
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,6 @@
|
||||
en:
|
||||
talk-plugin-subscriber:
|
||||
subscriber: "Subscriber"
|
||||
es:
|
||||
talk-plugin-subscriber:
|
||||
subscriber: "Subscriptor"
|
||||
@@ -0,0 +1,14 @@
|
||||
module.exports = {
|
||||
tags: [
|
||||
{
|
||||
name: 'SUBSCRIBER',
|
||||
permissions: {
|
||||
public: true,
|
||||
self: false,
|
||||
roles: []
|
||||
},
|
||||
models: ['USERS'],
|
||||
created_at: new Date()
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "@coralproject/talk-plugin-subscriber",
|
||||
"version": "0.1.0",
|
||||
"description": "A Recipe to display a user badge",
|
||||
"main": "index.js",
|
||||
"author": "The Coral Project Team <coral@mozillafoundation.org>",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"moment": "^2.18.1"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
moment@^2.18.1:
|
||||
version "2.18.1"
|
||||
resolved "https://registry.yarnpkg.com/moment/-/moment-2.18.1.tgz#c36193dd3ce1c2eed2adb7c802dbbc77a81b1c0f"
|
||||
|
||||
momentjs@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/momentjs/-/momentjs-2.0.0.tgz#73df904b4fa418f6e3c605e831cef6ed5518ebd4"
|
||||
Reference in New Issue
Block a user