Move "global switchoff" code from plugin to core

This commit is contained in:
Fabian Neumann
2018-05-11 11:28:58 +02:00
parent fab15daacd
commit 48fc3ab5db
24 changed files with 105 additions and 150 deletions
@@ -1,23 +0,0 @@
{
"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"] }]
}
}
@@ -1,48 +0,0 @@
import React from 'react';
import ConfigureCard from 'coral-framework/components/ConfigureCard';
import MarkdownEditor from 'coral-framework/components/MarkdownEditor';
import t from 'coral-framework/services/i18n';
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;
@@ -1,12 +0,0 @@
import { gql } from 'react-apollo';
import GlobalSwitchoff from '../components/GlobalSwitchoff';
import { withFragments } from 'plugin-api/beta/client/hocs';
export default withFragments({
settings: gql`
fragment TalkPlugin_GlobalSwitchoff_settings on Settings {
globalSwitchoffEnable
globalSwitchoffMessage
}
`,
})(GlobalSwitchoff);
@@ -1,9 +0,0 @@
import GlobalSwitchoff from './containers/GlobalSwitchoff';
import translations from './translations.yml';
export default {
translations,
slots: {
adminStreamSettings: [GlobalSwitchoff],
},
};
@@ -1,8 +0,0 @@
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.'
@@ -1,13 +0,0 @@
const { readFileSync } = require('fs');
const path = require('path');
const hooks = require('./server/hooks');
const resolvers = require('./server/resolvers');
module.exports = {
typeDefs: readFileSync(
path.join(__dirname, 'server/typeDefs.graphql'),
'utf8'
),
hooks,
resolvers,
};
@@ -1,13 +0,0 @@
module.exports = {
RootMutation: {
updateSettings: {
async pre(_, { input }) {
input.metadata = {
...input.metadata,
globalSwitchoffEnable: input.globalSwitchoffEnable,
};
delete input.globalSwitchoffEnable;
},
},
},
};
@@ -1 +0,0 @@
module.exports = {};
@@ -1,10 +0,0 @@
const { get } = require('lodash');
module.exports = {
Settings: {
globalSwitchoffEnable: settings =>
get(settings, 'metadata.globalSwitchoffEnable', false),
globalSwitchoffMessage: settings =>
get(settings, 'metadata.globalSwitchoffMessage', ''),
},
};
@@ -1,10 +0,0 @@
type Settings {
globalSwitchoffEnable: Boolean
globalSwitchoffMessage: String
}
input UpdateSettingsInput {
globalSwitchoffEnable: Boolean
globalSwitchoffMessage: String
}