From 64a86bd32f82b8c9c943c38949f6f7e105bcd54e Mon Sep 17 00:00:00 2001 From: Corey Hulen Date: Wed, 21 Dec 2016 14:31:24 -0800 Subject: PLT-4853 adding purge cache button to the UI. (#4811) * PLT_4853 adding purge cache button to the UI. * Fixing loc stuff --- .../admin_console/configuration_settings.jsx | 2 + webapp/components/admin_console/purge_caches.jsx | 112 +++++++++++++++++++++ 2 files changed, 114 insertions(+) create mode 100644 webapp/components/admin_console/purge_caches.jsx (limited to 'webapp/components/admin_console') diff --git a/webapp/components/admin_console/configuration_settings.jsx b/webapp/components/admin_console/configuration_settings.jsx index 4653a5df9..a5e5abe87 100644 --- a/webapp/components/admin_console/configuration_settings.jsx +++ b/webapp/components/admin_console/configuration_settings.jsx @@ -10,6 +10,7 @@ import {FormattedMessage, FormattedHTMLMessage} from 'react-intl'; import SettingsGroup from './settings_group.jsx'; import TextSetting from './text_setting.jsx'; import ReloadConfigButton from './reload_config.jsx'; +import PurgeCachesButton from './purge_caches.jsx'; import WebserverModeDropdownSetting from './webserver_mode_dropdown_setting.jsx'; import {ConnectionSecurityDropdownSettingWebserver} from './connection_security_dropdown_setting.jsx'; import BooleanSetting from './boolean_setting.jsx'; @@ -252,6 +253,7 @@ export default class ConfigurationSettings extends AdminSettings { disabled={false} /> + ); } diff --git a/webapp/components/admin_console/purge_caches.jsx b/webapp/components/admin_console/purge_caches.jsx new file mode 100644 index 000000000..a999f090e --- /dev/null +++ b/webapp/components/admin_console/purge_caches.jsx @@ -0,0 +1,112 @@ +// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +import React from 'react'; + +import Client from 'client/web_client.jsx'; + +import {FormattedMessage} from 'react-intl'; + +export default class PurgeCachesButton extends React.Component { + constructor(props) { + super(props); + + this.handlePurge = this.handlePurge.bind(this); + + this.state = { + loading: false, + fail: null + }; + } + + handlePurge(e) { + e.preventDefault(); + + this.setState({ + loading: true, + fail: null + }); + + Client.invalidateAllCaches( + () => { + this.setState({ + loading: false + }); + }, + (err) => { + this.setState({ + loading: false, + fail: err.message + ' - ' + err.detailed_error + }); + } + ); + } + + render() { + if (global.window.mm_license.IsLicensed !== 'true') { + return
; + } + + let testMessage = null; + if (this.state.fail) { + testMessage = ( +
+ + +
+ ); + } + + const helpText = ( + + ); + + let contents = null; + if (this.state.loading) { + contents = ( + + + + + ); + } else { + contents = ( + + ); + } + + return ( +
+
+
+ + {testMessage} +
+
+ {helpText} +
+
+
+ ); + } +} -- cgit v1.2.3-1-g7c22