// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import $ from 'jquery'; import PropTypes from 'prop-types'; import React from 'react'; import {FormattedMessage} from 'react-intl'; import * as Utils from 'utils/utils.jsx'; import AdminSidebarCategory from 'components/admin_console/admin_sidebar_category.jsx'; import AdminSidebarHeader from 'components/admin_console/admin_sidebar_header'; import AdminSidebarSection from 'components/admin_console/admin_sidebar_section.jsx'; export default class AdminSidebar extends React.Component { static get contextTypes() { return { router: PropTypes.object.isRequired, }; } static propTypes = { license: PropTypes.object.isRequired, config: PropTypes.object, plugins: PropTypes.object, buildEnterpriseReady: PropTypes.bool, siteName: PropTypes.string, actions: PropTypes.shape({ /* * Function to get installed plugins */ getPlugins: PropTypes.func.isRequired, }).isRequired, } static defaultProps = { plugins: {}, } componentDidMount() { if (this.props.config.PluginSettings.Enable) { this.props.actions.getPlugins(); } this.updateTitle(); if (!Utils.isMobile()) { $('.admin-sidebar .nav-pills__container').perfectScrollbar({ suppressScrollX: true, }); } } componentDidUpdate() { if (!Utils.isMobile()) { $('.admin-sidebar .nav-pills__container').perfectScrollbar({ suppressScrollX: true, }); } } updateTitle = () => { let currentSiteName = ''; if (this.props.siteName) { currentSiteName = ' - ' + this.props.siteName; } document.title = Utils.localizeMessage('sidebar_right_menu.console', 'System Console') + currentSiteName; } render() { let oauthSettings = null; let ldapSettings = null; let samlSettings = null; let clusterSettings = null; let metricsSettings = null; let complianceSettings = null; let mfaSettings = null; let messageExportSettings = null; let complianceSection = null; let license = null; let audits = null; let announcement = null; if (this.props.buildEnterpriseReady) { license = ( } /> ); } if (this.props.license.IsLicensed === 'true') { if (this.props.license.LDAP === 'true') { ldapSettings = ( } /> ); } if (this.props.license.Cluster === 'true') { clusterSettings = ( } /> ); } if (this.props.license.Metrics === 'true') { metricsSettings = ( } /> ); } if (this.props.license.SAML === 'true') { samlSettings = ( } /> ); } if (this.props.license.Compliance === 'true') { complianceSettings = ( } /> ); } if (this.props.license.MFA === 'true') { mfaSettings = ( } /> ); } if (this.props.license.MessageExport === 'true') { messageExportSettings = ( } /> ); } oauthSettings = ( } /> ); announcement = ( } /> ); } else { oauthSettings = ( } /> ); } if (this.props.license.IsLicensed === 'true') { audits = ( } /> ); } let otherCategory = null; if (license || audits) { otherCategory = ( } > {license} {audits} ); } let elasticSearchSettings = null; if (this.props.license.IsLicensed === 'true' && this.props.license.Elasticsearch === 'true') { elasticSearchSettings = ( } /> ); } let dataRetentionSettings = null; if (this.props.license.IsLicensed === 'true' && this.props.license.DataRetention === 'true') { dataRetentionSettings = ( } /> ); } const SHOW_CLIENT_VERSIONS = false; let clientVersions = null; if (SHOW_CLIENT_VERSIONS) { clientVersions = ( } /> ); } if (dataRetentionSettings || messageExportSettings) { complianceSection = ( } > {dataRetentionSettings} {messageExportSettings} ); } const customPlugins = []; if (this.props.config.PluginSettings.Enable) { Object.values(this.props.plugins).forEach((p) => { const hasSettings = p.settings_schema && (p.settings_schema.header || p.settings_schema.footer || p.settings_schema.settings.length > 0); if (!hasSettings) { return; } customPlugins.push( ); }); } return (
    } > } /> } /> } /> } /> } > } > } /> } /> } /> } /> {complianceSettings} } /> {this.props.license.IsLicensed === 'true' && } > {this.props.license.CustomPermissionsSchemes !== 'true' && } />} {this.props.license.CustomPermissionsSchemes === 'true' && } />} } } > } /> {oauthSettings} {ldapSettings} {samlSettings} {mfaSettings} } > } /> } /> } /> } /> } /> {clientVersions} } > } /> } /> } > } /> } /> } > } /> } /> {customPlugins} } > } /> } > } /> {announcement} } /> } /> } /> } /> } /> {complianceSection} } > } /> } /> {elasticSearchSettings} } /> {clusterSettings} {metricsSettings} {otherCategory}
); } }