mirror of
https://github.com/wassname/talk.git
synced 2026-07-01 10:02:43 +08:00
WIP
This commit is contained in:
@@ -35,6 +35,7 @@ plugins/*
|
||||
!plugins/talk-plugin-facebook-auth
|
||||
!plugins/talk-plugin-featured-comments
|
||||
!plugins/talk-plugin-flag-details
|
||||
!plugins/talk-plugin-global-switchoff
|
||||
!plugins/talk-plugin-google-auth
|
||||
!plugins/talk-plugin-ignore-user
|
||||
!plugins/talk-plugin-like
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
---
|
||||
title: talk-plugin-global-switchoff
|
||||
permalink: /plugin/talk-plugin-global-switchoff/
|
||||
layout: plugin
|
||||
plugin:
|
||||
name: talk-plugin-global-switchoff
|
||||
provides:
|
||||
- Client
|
||||
- Server
|
||||
---
|
||||
|
||||
Add a switch to the settings page that disables commenting globally.
|
||||
|
||||
## Installation
|
||||
|
||||
TBD
|
||||
|
||||
Add `"talk-plugin-global-switchoff"` to the `plugins.json` in your Talk installation.
|
||||
This plugin provides a server and a client side implementation.
|
||||
|
||||
## Server implementation
|
||||
|
||||
### How does this work?
|
||||
|
||||
TODO
|
||||
@@ -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,59 @@
|
||||
import React from 'react';
|
||||
import { gql } from 'react-apollo';
|
||||
import ConfigureCard from 'coral-framework/components/ConfigureCard';
|
||||
import MarkdownEditor from 'coral-framework/components/MarkdownEditor';
|
||||
import t from 'coral-framework/services/i18n';
|
||||
import { withFragments } from 'plugin-api/beta/client/hocs';
|
||||
import cn from 'classnames';
|
||||
import styles from './styles.css';
|
||||
|
||||
const plugin = 'talk-plugin-global-switchoff';
|
||||
|
||||
class GlobalSwitchoff extends React.Component {
|
||||
updateGlobalSwitchoffEnable = () => {
|
||||
const updater = {
|
||||
globalSwitchoffEnable: {
|
||||
$set: !this.props.settings.globalSwitchoffEnable,
|
||||
},
|
||||
};
|
||||
this.props.updatePending({ updater });
|
||||
};
|
||||
|
||||
updateGlobalSwitchoffMessage = () => {};
|
||||
|
||||
render() {
|
||||
const { settings } = this.props;
|
||||
return (
|
||||
<ConfigureCard
|
||||
checked={settings.globalSwitchoffEnable}
|
||||
onCheckbox={this.updateGlobalSwitchoffEnable}
|
||||
title={t(plugin + '.setting_title')}
|
||||
>
|
||||
<p>{t(plugin + '.setting_desc')}</p>
|
||||
<div
|
||||
className={cn(
|
||||
styles.configSettingGlobalSwitchoff,
|
||||
settings.globalSwitchoffEnable ? null : styles.hidden
|
||||
)}
|
||||
>
|
||||
<MarkdownEditor
|
||||
className={styles.descriptionBox}
|
||||
onChange={this.updateGlobalSwitchoffMessage}
|
||||
value={settings.globalSwitchoffMessage}
|
||||
/>
|
||||
</div>
|
||||
</ConfigureCard>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// export default GlobalSwitchoff;
|
||||
|
||||
export default withFragments({
|
||||
settings: gql`
|
||||
fragment TalkPlugin_GlobalSwitchoff_settings on Settings {
|
||||
globalSwitchoffEnable
|
||||
globalSwitchoffMessage
|
||||
}
|
||||
`,
|
||||
})(GlobalSwitchoff);
|
||||
@@ -0,0 +1,9 @@
|
||||
import GlobalSwitchoff from './components/GlobalSwitchoff';
|
||||
import translations from './translations.yml';
|
||||
|
||||
export default {
|
||||
translations,
|
||||
slots: {
|
||||
adminStreamSettings: [GlobalSwitchoff],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,8 @@
|
||||
en:
|
||||
talk-plugin-global-switchoff:
|
||||
setting_title: 'Deactivate commenting globally'
|
||||
setting_desc: 'Write a message that will be displayed while commenting is deactivated.'
|
||||
de:
|
||||
talk-plugin-global-switchoff:
|
||||
setting_title: 'Kommentieren global deaktivieren'
|
||||
setting_desc: 'Verfassen Sie eine Nachricht, die angezeigt wird, solange das Kommentieren deaktiviert ist.'
|
||||
@@ -0,0 +1,11 @@
|
||||
const { readFileSync } = require('fs');
|
||||
const path = require('path');
|
||||
const resolvers = require('./server/resolvers');
|
||||
|
||||
module.exports = {
|
||||
typeDefs: readFileSync(
|
||||
path.join(__dirname, 'server/typeDefs.graphql'),
|
||||
'utf8'
|
||||
),
|
||||
resolvers,
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
module.exports = {};
|
||||
@@ -0,0 +1,10 @@
|
||||
const { get } = require('lodash');
|
||||
|
||||
module.exports = {
|
||||
Settings: {
|
||||
globalSwitchoffEnable: settings =>
|
||||
get(settings, 'globalSwitchoffEnable', false),
|
||||
globalSwitchoffMessage: settings =>
|
||||
get(settings, 'globalSwitchoffMessage', ''),
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
type Settings {
|
||||
globalSwitchoffEnable: Boolean
|
||||
globalSwitchoffMessage: String
|
||||
}
|
||||
|
||||
input UpdateSettingsInput {
|
||||
globalSwitchoffEnable: Boolean
|
||||
globalSwitchoffMessage: String
|
||||
}
|
||||
Reference in New Issue
Block a user