diff --git a/api4/brand.go b/api4/brand.go index ac69f623bf..de81b8a3b4 100644 --- a/api4/brand.go +++ b/api4/brand.go @@ -23,6 +23,7 @@ func getBrandImage(c *Context, w http.ResponseWriter, r *http.Request) { // No permission check required if img, err := app.GetBrandImage(); err != nil { + w.WriteHeader(http.StatusNotFound) w.Write(nil) } else { w.Header().Set("Content-Type", "image/png") diff --git a/api4/brand_test.go b/api4/brand_test.go index 98a5395745..6ecb41a833 100644 --- a/api4/brand_test.go +++ b/api4/brand_test.go @@ -13,27 +13,15 @@ func TestGetBrandImage(t *testing.T) { defer TearDown() Client := th.Client - data, resp := Client.GetBrandImage() - CheckNoError(t, resp) - - if len(data) != 0 { - t.Fatal("no image uploaded - should be empty") - } + _, resp := Client.GetBrandImage() + CheckNotFoundStatus(t, resp) Client.Logout() - data, resp = Client.GetBrandImage() - CheckNoError(t, resp) + _, resp = Client.GetBrandImage() + CheckNotFoundStatus(t, resp) - if len(data) != 0 { - t.Fatal("no image uploaded - should be empty") - } - - data, resp = th.SystemAdminClient.GetBrandImage() - CheckNoError(t, resp) - - if len(data) != 0 { - t.Fatal("no image uploaded - should be empty") - } + _, resp = th.SystemAdminClient.GetBrandImage() + CheckNotFoundStatus(t, resp) } func TestUploadBrandImage(t *testing.T) { diff --git a/api4/compliance.go b/api4/compliance.go index cabac6e21a..733abeecf8 100644 --- a/api4/compliance.go +++ b/api4/compliance.go @@ -20,7 +20,7 @@ func InitCompliance() { BaseRoutes.Compliance.Handle("/reports", ApiSessionRequired(createComplianceReport)).Methods("POST") BaseRoutes.Compliance.Handle("/reports", ApiSessionRequired(getComplianceReports)).Methods("GET") BaseRoutes.Compliance.Handle("/reports/{report_id:[A-Za-z0-9]+}", ApiSessionRequired(getComplianceReport)).Methods("GET") - BaseRoutes.Compliance.Handle("/reports/{report_id:[A-Za-z0-9]+}/download", ApiSessionRequired(downloadComplianceReport)).Methods("GET") + BaseRoutes.Compliance.Handle("/reports/{report_id:[A-Za-z0-9]+}/download", ApiSessionRequiredTrustRequester(downloadComplianceReport)).Methods("GET") } func createComplianceReport(c *Context, w http.ResponseWriter, r *http.Request) { diff --git a/api4/system.go b/api4/system.go index 3a077283c1..465f4e71d1 100644 --- a/api4/system.go +++ b/api4/system.go @@ -52,13 +52,17 @@ func getSystemPing(c *Context, w http.ResponseWriter, r *http.Request) { } func testEmail(c *Context, w http.ResponseWriter, r *http.Request) { + cfg := model.ConfigFromJson(r.Body) + if cfg == nil { + cfg = utils.Cfg + } if !app.SessionHasPermissionTo(c.Session, model.PERMISSION_MANAGE_SYSTEM) { c.SetPermissionError(model.PERMISSION_MANAGE_SYSTEM) return } - err := app.TestEmail(c.Session.UserId, utils.Cfg) + err := app.TestEmail(c.Session.UserId, cfg) if err != nil { c.Err = err return diff --git a/api4/user.go b/api4/user.go index d06dd28822..69bea945ac 100644 --- a/api4/user.go +++ b/api4/user.go @@ -27,7 +27,7 @@ func InitUser() { BaseRoutes.Users.Handle("/autocomplete", ApiSessionRequired(autocompleteUsers)).Methods("GET") BaseRoutes.User.Handle("", ApiSessionRequired(getUser)).Methods("GET") - BaseRoutes.User.Handle("/image", ApiSessionRequired(getProfileImage)).Methods("GET") + BaseRoutes.User.Handle("/image", ApiSessionRequiredTrustRequester(getProfileImage)).Methods("GET") BaseRoutes.User.Handle("/image", ApiSessionRequired(setProfileImage)).Methods("POST") BaseRoutes.User.Handle("", ApiSessionRequired(updateUser)).Methods("PUT") BaseRoutes.User.Handle("/patch", ApiSessionRequired(patchUser)).Methods("PUT") diff --git a/webapp/actions/admin_actions.jsx b/webapp/actions/admin_actions.jsx index 9a522caf95..04d0d65bb7 100644 --- a/webapp/actions/admin_actions.jsx +++ b/webapp/actions/admin_actions.jsx @@ -2,201 +2,154 @@ // See License.txt for license information. import Client from 'client/web_client.jsx'; -import * as AsyncClient from 'utils/async_client.jsx'; import {browserHistory} from 'react-router/es6'; -// Redux actions import store from 'stores/redux_store.jsx'; const dispatch = store.dispatch; const getState = store.getState; -import {getUser} from 'mattermost-redux/actions/users'; +import {updateUserMfa, updateUserPassword} from 'mattermost-redux/actions/users'; +import * as AdminActions from 'mattermost-redux/actions/admin'; export function saveConfig(config, success, error) { - Client.saveConfig( - config, - () => { - if (success) { - success(); - } - }, - (err) => { - if (error) { - error(err); + AdminActions.updateConfig(config)(dispatch, getState).then( + (data) => { + if (data && success) { + success(data); + } else if (data == null && error) { + const serverError = getState().requests.admin.updateConfig.error; + error({id: serverError.server_error_id, ...serverError}); } } ); } export function reloadConfig(success, error) { - Client.reloadConfig( - () => { - AsyncClient.getConfig(); - if (success) { - success(); - } - }, - (err) => { - if (error) { - error(err); + AdminActions.reloadConfig()(dispatch, getState).then( + (data) => { + if (data && success) { + AdminActions.getConfig()(dispatch, getState); + success(data); + } else if (data == null && error) { + const serverError = getState().requests.admin.reloadConfig.error; + error({id: serverError.server_error_id, ...serverError}); } } ); } export function adminResetMfa(userId, success, error) { - Client.adminResetMfa( - userId, - () => { - getUser(userId)(dispatch, getState); - - if (success) { - success(); - } - }, - (err) => { - if (error) { - error(err); + updateUserMfa(userId, false)(dispatch, getState).then( + (data) => { + if (data && success) { + success(data); + } else if (data == null && error) { + const serverError = getState().requests.users.updateUser.error; + error({id: serverError.server_error_id, ...serverError}); } } ); } export function getClusterStatus(success, error) { - Client.getClusterStatus( + AdminActions.getClusterStatus()(dispatch, getState).then( (data) => { - if (success) { + if (data && success) { success(data); - } - }, - (err) => { - AsyncClient.dispatchError(err, 'getClusterStatus'); - if (error) { - error(err); - } - } - ); -} - -export function saveComplianceReports(job, success, error) { - Client.saveComplianceReports( - job, - () => { - if (success) { - success(); - } - }, - (err) => { - if (error) { - error(err); + } else if (data == null && error) { + const serverError = getState().requests.admin.getClusterStatus.error; + error({id: serverError.server_error_id, ...serverError}); } } ); } export function testEmail(config, success, error) { - Client.testEmail( - config, - () => { - if (success) { - success(); - } - }, - (err) => { - if (error) { - error(err); + AdminActions.testEmail(config)(dispatch, getState).then( + (data) => { + if (data && success) { + success(data); + } else if (data == null && error) { + const serverError = getState().requests.admin.testEmail.error; + error({id: serverError.server_error_id, ...serverError}); } } ); } export function ldapTest(success, error) { - Client.ldapTest( - () => { - if (success) { - success(); - } - }, - (err) => { - if (error) { - error(err); + AdminActions.testLdap()(dispatch, getState).then( + (data) => { + if (data && success) { + success(data); + } else if (data == null && error) { + const serverError = getState().requests.admin.testLdap.error; + error({id: serverError.server_error_id, ...serverError}); } } ); } export function invalidateAllCaches(success, error) { - Client.invalidateAllCaches( - () => { - if (success) { - success(); - } - }, - (err) => { - if (error) { - error(err); + AdminActions.invalidateCaches()(dispatch, getState).then( + (data) => { + if (data && success) { + success(data); + } else if (data == null && error) { + const serverError = getState().requests.admin.invalidateCaches.error; + error({id: serverError.server_error_id, ...serverError}); } } ); } export function recycleDatabaseConnection(success, error) { - Client.recycleDatabaseConnection( - () => { - if (success) { - success(); - } - }, - (err) => { - if (error) { - error(err); + AdminActions.recycleDatabase()(dispatch, getState).then( + (data) => { + if (data && success) { + success(data); + } else if (data == null && error) { + const serverError = getState().requests.admin.recycleDatabase.error; + error({id: serverError.server_error_id, ...serverError}); } } ); } export function adminResetPassword(userId, password, success, error) { - Client.adminResetPassword( - userId, - password, - () => { - if (success) { - success(); - } - }, - (err) => { - if (error) { - error(err); + updateUserPassword(userId, '', password)(dispatch, getState).then( + (data) => { + if (data && success) { + success(data); + } else if (data == null && error) { + const serverError = getState().requests.users.updateUser.error; + error({id: serverError.server_error_id, ...serverError}); } } ); } export function samlCertificateStatus(success, error) { - Client.samlCertificateStatus( + AdminActions.getSamlCertificateStatus()(dispatch, getState).then( (data) => { - if (success) { + if (data && success) { success(data); - } - }, - (err) => { - if (error) { - error(err); + } else if (data == null && error) { + const serverError = getState().requests.admin.getSamlCertificateStatus.error; + error({id: serverError.server_error_id, ...serverError}); } } ); } export function ldapSyncNow(success, error) { - Client.ldapSyncNow( - () => { - if (success) { - success(); - } - }, - (err) => { - if (error) { - error(err); + AdminActions.syncLdap()(dispatch, getState).then( + (data) => { + if (data && success) { + success(data); + } else if (data == null && error) { + const serverError = getState().requests.admin.syncLdap.error; + error({id: serverError.server_error_id, ...serverError}); } } ); @@ -316,16 +269,13 @@ export function regenerateOAuthAppSecret(oauthAppId, success, error) { } export function uploadBrandImage(brandImage, success, error) { - Client.uploadBrandImage( - brandImage, - () => { - if (success) { - success(); - } - }, - (err) => { - if (error) { - error(err); + AdminActions.uploadBrandImage(brandImage)(dispatch, getState).then( + (data) => { + if (data && success) { + success(data); + } else if (data == null && error) { + const serverError = getState().requests.admin.uploadBrandImage.error; + error({id: serverError.server_error_id, ...serverError}); } } ); @@ -362,33 +312,79 @@ export function removeLicenseFile(success, error) { ); } -export function uploadCertificateFile(certificateFile, success, error) { - Client.uploadCertificateFile( - certificateFile, - () => { - if (success) { - success(); - } - }, - (err) => { - if (error) { - error(err); +export function uploadPublicSamlCertificate(file, success, error) { + AdminActions.uploadPublicSamlCertificate(file)(dispatch, getState).then( + (data) => { + if (data && success) { + success(data); + } else if (data == null && error) { + const serverError = getState().requests.admin.uploadPublicSamlCertificate.error; + error({id: serverError.server_error_id, ...serverError}); } } ); } -export function removeCertificateFile(certificateId, success, error) { - Client.removeCertificateFile( - certificateId, - () => { - if (success) { - success(); - } - }, - (err) => { - if (error) { - error(err); +export function uploadPrivateSamlCertificate(file, success, error) { + AdminActions.uploadPrivateSamlCertificate(file)(dispatch, getState).then( + (data) => { + if (data && success) { + success(data); + } else if (data == null && error) { + const serverError = getState().requests.admin.uploadPrivateSamlCertificate.error; + error({id: serverError.server_error_id, ...serverError}); + } + } + ); +} + +export function uploadIdpSamlCertificate(file, success, error) { + AdminActions.uploadIdpSamlCertificate(file)(dispatch, getState).then( + (data) => { + if (data && success) { + success(data); + } else if (data == null && error) { + const serverError = getState().requests.admin.uploadIdpSamlCertificate.error; + error({id: serverError.server_error_id, ...serverError}); + } + } + ); +} + +export function removePublicSamlCertificate(success, error) { + AdminActions.removePublicSamlCertificate()(dispatch, getState).then( + (data) => { + if (data && success) { + success(data); + } else if (data == null && error) { + const serverError = getState().requests.admin.removePublicSamlCertificate.error; + error({id: serverError.server_error_id, ...serverError}); + } + } + ); +} + +export function removePrivateSamlCertificate(success, error) { + AdminActions.removePrivateSamlCertificate()(dispatch, getState).then( + (data) => { + if (data && success) { + success(data); + } else if (data == null && error) { + const serverError = getState().requests.admin.removePrivateSamlCertificate.error; + error({id: serverError.server_error_id, ...serverError}); + } + } + ); +} + +export function removeIdpSamlCertificate(success, error) { + AdminActions.removeIdpSamlCertificate()(dispatch, getState).then( + (data) => { + if (data && success) { + success(data); + } else if (data == null && error) { + const serverError = getState().requests.admin.removeIdpSamlCertificate.error; + error({id: serverError.server_error_id, ...serverError}); } } ); diff --git a/webapp/components/admin_console/admin_console.jsx b/webapp/components/admin_console/admin_console.jsx index b8250bab21..99256d7d4f 100644 --- a/webapp/components/admin_console/admin_console.jsx +++ b/webapp/components/admin_console/admin_console.jsx @@ -6,46 +6,37 @@ import PropTypes from 'prop-types'; import 'bootstrap'; import AnnouncementBar from 'components/announcement_bar'; -import AdminStore from 'stores/admin_store.jsx'; -import * as AsyncClient from 'utils/async_client.jsx'; - import AdminSidebar from './admin_sidebar.jsx'; export default class AdminConsole extends React.Component { - static get propTypes() { - return { - children: PropTypes.node.isRequired - }; - } + static propTypes = { - constructor(props) { - super(props); + /* + * Children components to render + */ + children: PropTypes.node.isRequired, - this.handleConfigChange = this.handleConfigChange.bind(this); + /* + * Object representing the config file + */ + config: PropTypes.object.isRequired, - this.state = { - config: AdminStore.getConfig() - }; + actions: PropTypes.shape({ + + /* + * Function to get the config file + */ + getConfig: PropTypes.func.isRequired + }).isRequired } componentWillMount() { - AdminStore.addConfigChangeListener(this.handleConfigChange); - AsyncClient.getConfig(); - } - - componentWillUnmount() { - AdminStore.removeConfigChangeListener(this.handleConfigChange); - } - - handleConfigChange() { - this.setState({ - config: AdminStore.getConfig() - }); + this.props.actions.getConfig(); } render() { - const config = this.state.config; - if (!config) { + const config = this.props.config; + if (Object.keys(config).length === 0) { return
; } if (config && Object.keys(config).length === 0 && config.constructor === 'Object') { @@ -59,7 +50,7 @@ export default class AdminConsole extends React.Component { // not every page in the system console will need the config, but the vast majority will const children = React.cloneElement(this.props.children, { - config: this.state.config + config }); return (
diff --git a/webapp/components/admin_console/admin_settings.jsx b/webapp/components/admin_console/admin_settings.jsx index 180e6e5b92..2411fbdb88 100644 --- a/webapp/components/admin_console/admin_settings.jsx +++ b/webapp/components/admin_console/admin_settings.jsx @@ -1,11 +1,8 @@ -import PropTypes from 'prop-types'; - // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See License.txt for license information. import React from 'react'; - -import * as AsyncClient from 'utils/async_client.jsx'; +import PropTypes from 'prop-types'; import FormError from 'components/form_error.jsx'; import SaveButton from 'components/admin_console/save_button.jsx'; @@ -13,10 +10,12 @@ import SaveButton from 'components/admin_console/save_button.jsx'; import {saveConfig} from 'actions/admin_actions.jsx'; export default class AdminSettings extends React.Component { - static get propTypes() { - return { - config: PropTypes.object - }; + static propTypes = { + + /* + * Object representing the config file + */ + config: PropTypes.object } constructor(props) { @@ -58,10 +57,8 @@ export default class AdminSettings extends React.Component { saveConfig( config, - () => { - AsyncClient.getConfig((savedConfig) => { - this.setState(this.getStateFromConfig(savedConfig)); - }); + (savedConfig) => { + this.setState(this.getStateFromConfig(savedConfig)); this.setState({ saveNeeded: false, diff --git a/webapp/components/admin_console/admin_sidebar_header.jsx b/webapp/components/admin_console/admin_sidebar_header.jsx index 87a1170dcc..3011869176 100644 --- a/webapp/components/admin_console/admin_sidebar_header.jsx +++ b/webapp/components/admin_console/admin_sidebar_header.jsx @@ -4,7 +4,7 @@ import $ from 'jquery'; import AdminNavbarDropdown from './admin_navbar_dropdown.jsx'; import UserStore from 'stores/user_store.jsx'; -import Client from 'client/web_client.jsx'; +import {Client4} from 'mattermost-redux/client'; import {FormattedMessage} from 'react-intl'; @@ -14,12 +14,10 @@ export default class SidebarHeader extends React.Component { constructor(props) { super(props); - this.toggleDropdown = this.toggleDropdown.bind(this); - this.state = {}; } - toggleDropdown(e) { + toggleDropdown = (e) => { e.preventDefault(); if (this.refs.dropdown.blockToggle) { @@ -42,7 +40,7 @@ export default class SidebarHeader extends React.Component { profilePicture = ( this.setState({loadingAudits: false}) + ); } - componentWillUnmount() { - AdminStore.removeAuditChangeListener(this.onAuditListenerChange); - } - - onAuditListenerChange() { - this.setState({ - audits: AdminStore.getAudits() - }); - } - - reload() { - AdminStore.saveAudits(null); - this.setState({ - audits: null - }); - - AsyncClient.getServerAudits(); + reload = () => { + this.setState({loadingAudits: true}); + this.props.actions.getAudits().then( + () => this.setState({loadingAudits: false}) + ); } render() { - var content = null; + let content = null; if (global.window.mm_license.IsLicensed !== 'true') { return
; } - if (this.state.audits === null) { + if (this.state.loadingAudits) { content = ; } else { content = (
{ - $(ReactDOM.findDOMNode(this.refs.upload)).button('complete'); + $(this.refs.upload).button('complete'); this.setState({ brandImageExists: true, @@ -96,7 +105,7 @@ export default class BrandImageSetting extends React.Component { }); }, (err) => { - $(ReactDOM.findDOMNode(this.refs.upload)).button('reset'); + $(this.refs.upload).button('reset'); this.setState({ uploading: false, @@ -130,7 +139,7 @@ export default class BrandImageSetting extends React.Component { img = ( ' + Utils.localizeMessage('admin.team.uploading', 'Uploading..')} data-complete-text={' ' + Utils.localizeMessage('admin.team.uploaded', 'Uploaded!')} > diff --git a/webapp/components/admin_console/cluster_settings.jsx b/webapp/components/admin_console/cluster_settings.jsx index 895a87ce1b..14bc46240c 100644 --- a/webapp/components/admin_console/cluster_settings.jsx +++ b/webapp/components/admin_console/cluster_settings.jsx @@ -11,9 +11,10 @@ import {FormattedMessage, FormattedHTMLMessage} from 'react-intl'; import SettingsGroup from './settings_group.jsx'; import ClusterTableContainer from './cluster_table_container.jsx'; -import AdminStore from 'stores/admin_store.jsx'; import * as Utils from 'utils/utils.jsx'; +import {Client4} from 'mattermost-redux/client'; + export default class ClusterSettings extends AdminSettings { constructor(props) { super(props); @@ -74,7 +75,7 @@ export default class ClusterSettings extends AdminSettings { var configLoadedFromCluster = null; - if (AdminStore.getClusterId()) { + if (Client4.clusterId) { configLoadedFromCluster = (
diff --git a/webapp/components/admin_console/compliance_reports.jsx b/webapp/components/admin_console/compliance_reports/compliance_reports.jsx similarity index 78% rename from webapp/components/admin_console/compliance_reports.jsx rename to webapp/components/admin_console/compliance_reports/compliance_reports.jsx index 567a6ca041..af361bace1 100644 --- a/webapp/components/admin_console/compliance_reports.jsx +++ b/webapp/components/admin_console/compliance_reports/compliance_reports.jsx @@ -1,92 +1,96 @@ // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. // See License.txt for license information. -import $ from 'jquery'; -import LoadingScreen from '../loading_screen.jsx'; -import * as Utils from '../../utils/utils.jsx'; -import AdminStore from '../../stores/admin_store.jsx'; -import UserStore from '../../stores/user_store.jsx'; +import LoadingScreen from 'components/loading_screen.jsx'; -import Client from 'client/web_client.jsx'; -import * as AsyncClient from '../../utils/async_client.jsx'; -import {saveComplianceReports} from 'actions/admin_actions.jsx'; - -import {FormattedMessage, FormattedDate, FormattedTime} from 'react-intl'; +import * as Utils from 'utils/utils.jsx'; +import UserStore from 'stores/user_store.jsx'; +import {Client4} from 'mattermost-redux/client'; import React from 'react'; -import ReactDOM from 'react-dom'; +import PropTypes from 'prop-types'; +import {FormattedMessage, FormattedDate, FormattedTime} from 'react-intl'; + +export default class ComplianceReports extends React.PureComponent { + static propTypes = { + + /* + * Set if compliance reports are enabled in the config + */ + enabled: PropTypes.bool.isRequired, + + /* + * Array of reports to render + */ + reports: PropTypes.arrayOf(PropTypes.object).isRequired, + + /* + * Error message to display + */ + serverError: PropTypes.string, + + actions: PropTypes.shape({ + + /* + * Function to get compliance reports + */ + getComplianceReports: PropTypes.func.isRequired, + + /* + * Function to save compliance reports + */ + createComplianceReport: PropTypes.func.isRequired + }).isRequired + } -export default class ComplianceReports extends React.Component { constructor(props) { super(props); - this.onComplianceReportsListenerChange = this.onComplianceReportsListenerChange.bind(this); - this.reload = this.reload.bind(this); - this.runReport = this.runReport.bind(this); - this.getDateTime = this.getDateTime.bind(this); - this.state = { - enabled: AdminStore.getConfig().ComplianceSettings.Enable, - reports: AdminStore.getComplianceReports(), - serverError: null + loadingReports: true }; } componentDidMount() { - AdminStore.addComplianceReportsChangeListener(this.onComplianceReportsListenerChange); - - if (global.window.mm_license.IsLicensed !== 'true' || !this.state.enabled) { + if (global.window.mm_license.IsLicensed !== 'true' || !this.props.enabled) { return; } - AsyncClient.getComplianceReports(); + this.props.actions.getComplianceReports().then( + () => this.setState({loadingReports: false}) + ); } - componentWillUnmount() { - AdminStore.removeComplianceReportsChangeListener(this.onComplianceReportsListenerChange); + reload = () => { + this.setState({loadingReports: true}); + + this.props.actions.getComplianceReports().then( + () => this.setState({loadingReports: false}) + ); } - onComplianceReportsListenerChange() { - this.setState({ - reports: AdminStore.getComplianceReports() - }); - } - - reload() { - AdminStore.saveComplianceReports(null); - this.setState({ - reports: null, - serverError: null - }); - - AsyncClient.getComplianceReports(); - } - - runReport(e) { + runReport = (e) => { e.preventDefault(); - $('#run-button').button('loading'); - var job = {}; - job.desc = ReactDOM.findDOMNode(this.refs.desc).value; - job.emails = ReactDOM.findDOMNode(this.refs.emails).value; - job.keywords = ReactDOM.findDOMNode(this.refs.keywords).value; - job.start_at = Date.parse(ReactDOM.findDOMNode(this.refs.from).value); - job.end_at = Date.parse(ReactDOM.findDOMNode(this.refs.to).value); + this.setState({runningReport: true}); - saveComplianceReports( - job, - () => { - ReactDOM.findDOMNode(this.refs.emails).value = ''; - ReactDOM.findDOMNode(this.refs.keywords).value = ''; - ReactDOM.findDOMNode(this.refs.desc).value = ''; - ReactDOM.findDOMNode(this.refs.from).value = ''; - ReactDOM.findDOMNode(this.refs.to).value = ''; - this.reload(); - $('#run-button').button('reset'); - }, - (err) => { - this.setState({serverError: err.message}); - $('#run-button').button('reset'); + const job = {}; + job.desc = this.refs.desc.value; + job.emails = this.refs.emails.value; + job.keywords = this.refs.keywords.value; + job.start_at = Date.parse(this.refs.from.value); + job.end_at = Date.parse(this.refs.to.value); + + this.props.actions.createComplianceReport(job).then( + (data) => { + if (data) { + this.refs.emails.value = ''; + this.refs.keywords.value = ''; + this.refs.desc.value = ''; + this.refs.from.value = ''; + this.refs.to.value = ''; + } + this.setState({runningReport: false}); } ); } @@ -112,21 +116,20 @@ export default class ComplianceReports extends React.Component { } render() { - var content = null; - - if (global.window.mm_license.IsLicensed !== 'true' || !this.state.enabled) { + if (global.window.mm_license.IsLicensed !== 'true' || !this.props.enabled) { return
; } - if (this.state.reports === null) { + let content = null; + if (this.state.loadingReports) { content = ; } else { var list = []; - for (var i = 0; i < this.state.reports.length; i++) { - const report = this.state.reports[i]; + for (var i = 0; i < this.props.reports.length; i++) { + const report = this.props.reports[i]; - var params = ''; + let params = ''; if (report.type === 'adhoc') { params = ( @@ -152,10 +155,10 @@ export default class ComplianceReports extends React.Component { ); } - var download = ''; + let download = ''; if (report.status === 'finished') { download = ( - + {report.status} @@ -177,8 +180,8 @@ export default class ComplianceReports extends React.Component { ); } - var user = report.user_id; - var profile = UserStore.getProfile(report.user_id); + let user = report.user_id; + const profile = UserStore.getProfile(report.user_id); if (profile) { user = profile.email; } @@ -256,13 +259,13 @@ export default class ComplianceReports extends React.Component { } let serverError = ''; - if (this.state.serverError) { + if (this.props.serverError) { serverError = (
- +
); } @@ -372,6 +375,7 @@ export default class ComplianceReports extends React.Component {