This repository has been archived by the owner on Mar 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PLT-4853 adding purge cache button to the UI. (#4811)
* PLT_4853 adding purge cache button to the UI. * Fixing loc stuff
- Loading branch information
1 parent
aa8d590
commit dc5f25f
Showing
4 changed files
with
127 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <div/>; | ||
} | ||
|
||
let testMessage = null; | ||
if (this.state.fail) { | ||
testMessage = ( | ||
<div className='alert alert-warning'> | ||
<i className='fa fa-warning'/> | ||
<FormattedMessage | ||
id='admin.purge.purgeFail' | ||
defaultMessage='Purging unsuccessful: {error}' | ||
values={{ | ||
error: this.state.fail | ||
}} | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
const helpText = ( | ||
<FormattedMessage | ||
id='admin.purge.purgeDescription' | ||
defaultMessage='This will purge all the in-memory caches for things like sessions, accounts, channels, etc. Deployments using High Availability will attempt to purge all the servers in the cluster. Purging the caches may adversly impact performance.' | ||
/> | ||
); | ||
|
||
let contents = null; | ||
if (this.state.loading) { | ||
contents = ( | ||
<span> | ||
<span className='fa fa-refresh icon--rotate'/> | ||
<FormattedMessage | ||
id='admin.purge.loading' | ||
defaultMessage='Loading...' | ||
/> | ||
</span> | ||
); | ||
} else { | ||
contents = ( | ||
<FormattedMessage | ||
id='admin.purge.button' | ||
defaultMessage='Purge All Caches' | ||
/> | ||
); | ||
} | ||
|
||
return ( | ||
<div className='form-group reload-config'> | ||
<div className='col-sm-offset-4 col-sm-8'> | ||
<div> | ||
<button | ||
className='btn btn-default' | ||
onClick={this.handlePurge} | ||
> | ||
{contents} | ||
</button> | ||
{testMessage} | ||
</div> | ||
<div className='help-text'> | ||
{helpText} | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters