|
|
@@ -7,6 +7,8 @@ import { createSubscribedElement } from '../../UnstatedUtils';
|
|
|
import { toastSuccess, toastError } from '../../../util/apiNotification';
|
|
|
|
|
|
import AppContainer from '../../../services/AppContainer';
|
|
|
+import AdminAppContainer from '../../../services/AdminAppContainer';
|
|
|
+import AdminUpdateButtonRow from '../Common/AdminUpdateButtonRow';
|
|
|
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
|
const logger = loggerFactory('growi:app:pluginSetting');
|
|
|
@@ -16,21 +18,15 @@ class PluginSetting extends React.Component {
|
|
|
constructor(props) {
|
|
|
super(props);
|
|
|
|
|
|
- this.state = {
|
|
|
- // TODO GW-690 fetch from db
|
|
|
- isEnabledPlugins: true,
|
|
|
- };
|
|
|
-
|
|
|
- this.onClickSubmit = this.onClickSubmit.bind(this);
|
|
|
- this.switchIsEnabledPlugins = this.switchIsEnabledPlugins.bind(this);
|
|
|
+ this.submitHandler = this.submitHandler.bind(this);
|
|
|
}
|
|
|
|
|
|
- async onClickSubmit() {
|
|
|
- const { t } = this.props;
|
|
|
+ async submitHandler() {
|
|
|
+ const { t, adminAppContainer } = this.props;
|
|
|
|
|
|
try {
|
|
|
- // TODO GW-690 post apiV3
|
|
|
- toastSuccess(t('app_setting.update', { target: 'Plugin Setting' }));
|
|
|
+ await adminAppContainer.updatePluginSettingHandler();
|
|
|
+ toastSuccess(t('app_setting.updated_plugin_setting'));
|
|
|
}
|
|
|
catch (err) {
|
|
|
toastError(err);
|
|
|
@@ -38,18 +34,12 @@ class PluginSetting extends React.Component {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- switchIsEnabledPlugins() {
|
|
|
- this.setState({ isEnabledPlugins: !this.state.isEnabledPlugins });
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
render() {
|
|
|
- const { t } = this.props;
|
|
|
+ const { t, adminAppContainer } = this.props;
|
|
|
|
|
|
return (
|
|
|
<React.Fragment>
|
|
|
-
|
|
|
- <p className="well">{ t('app_setting.Enable plugin loading') }</p>
|
|
|
+ <p className="well">{t('app_setting.Enable plugin loading')}</p>
|
|
|
|
|
|
<div className="row mb-5">
|
|
|
<div className="col-xs-offset-3 col-xs-6 text-left">
|
|
|
@@ -57,22 +47,17 @@ class PluginSetting extends React.Component {
|
|
|
<input
|
|
|
id="isEnabledPlugins"
|
|
|
type="checkbox"
|
|
|
- checked={this.state.isEnabledPlugins}
|
|
|
- onChange={this.switchIsEnabledPlugins}
|
|
|
+ checked={adminAppContainer.isEnabledPlugins}
|
|
|
+ onChange={(e) => {
|
|
|
+ adminAppContainer.changeIsEnabledPlugins(e.target.checked);
|
|
|
+ }}
|
|
|
/>
|
|
|
- <label htmlFor="isEnabledPlugins">
|
|
|
- { t('app_setting.Load plugins') }
|
|
|
- </label>
|
|
|
+ <label htmlFor="isEnabledPlugins">{t('app_setting.Load plugins')}</label>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
- <div className="row my-3">
|
|
|
- <div className="col-xs-offset-4 col-xs-5">
|
|
|
- <div className="btn btn-primary" onClick={this.onClickSubmit}>{ t('Update') }</div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-
|
|
|
+ <AdminUpdateButtonRow onClick={this.submitHandler} disabled={adminAppContainer.state.retrieveError != null} />
|
|
|
</React.Fragment>
|
|
|
);
|
|
|
}
|
|
|
@@ -83,12 +68,13 @@ class PluginSetting extends React.Component {
|
|
|
* Wrapper component for using unstated
|
|
|
*/
|
|
|
const PluginSettingWrapper = (props) => {
|
|
|
- return createSubscribedElement(PluginSetting, props, [AppContainer]);
|
|
|
+ return createSubscribedElement(PluginSetting, props, [AppContainer, AdminAppContainer]);
|
|
|
};
|
|
|
|
|
|
PluginSetting.propTypes = {
|
|
|
t: PropTypes.func.isRequired, // i18next
|
|
|
appContainer: PropTypes.instanceOf(AppContainer).isRequired,
|
|
|
+ adminAppContainer: PropTypes.instanceOf(AdminAppContainer).isRequired,
|
|
|
};
|
|
|
|
|
|
export default withTranslation()(PluginSettingWrapper);
|