diff --git a/webapp/channels/src/components/admin_console/admin_settings.tsx b/webapp/channels/src/components/admin_console/admin_settings.tsx index 3af43880bd..c92c258974 100644 --- a/webapp/channels/src/components/admin_console/admin_settings.tsx +++ b/webapp/channels/src/components/admin_console/admin_settings.tsx @@ -173,8 +173,8 @@ export default abstract class AdminSettings { - const n = parseInt(str, 10); + protected parseIntZeroOrMin = (str: string | number, minimumValue = 1) => { + const n = typeof str === 'string' ? parseInt(str, 10) : str; if (isNaN(n) || n < 0) { return 0; @@ -186,8 +186,8 @@ export default abstract class AdminSettings { - const n = parseInt(str, 10); + protected parseIntNonZero = (str: string | number, defaultValue?: number, minimumValue = 1) => { + const n = typeof str === 'string' ? parseInt(str, 10) : str; if (isNaN(n) || n < minimumValue) { if (defaultValue) { diff --git a/webapp/channels/src/components/admin_console/cluster_settings.jsx b/webapp/channels/src/components/admin_console/cluster_settings.jsx index 8a90f6af95..c01208fc1b 100644 --- a/webapp/channels/src/components/admin_console/cluster_settings.jsx +++ b/webapp/channels/src/components/admin_console/cluster_settings.jsx @@ -14,7 +14,7 @@ import ExternalLink from 'components/external_link'; import AdminSettings from './admin_settings'; import BooleanSetting from './boolean_setting'; -import ClusterTableContainer from './cluster_table_container.jsx'; +import ClusterTableContainer from './cluster_table_container'; import SettingsGroup from './settings_group'; import TextSetting from './text_setting'; import DocLinks from 'utils/constants'; diff --git a/webapp/channels/src/components/admin_console/cluster_table.tsx b/webapp/channels/src/components/admin_console/cluster_table.tsx index eca9ddaa26..d97252dc4a 100644 --- a/webapp/channels/src/components/admin_console/cluster_table.tsx +++ b/webapp/channels/src/components/admin_console/cluster_table.tsx @@ -1,7 +1,7 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import React, {CSSProperties} from 'react'; +import React, {CSSProperties, MouseEvent, PureComponent} from 'react'; import {FormattedMessage} from 'react-intl'; import * as Utils from 'utils/utils'; import statusGreen from 'images/status_green.png'; @@ -16,7 +16,7 @@ type Props = { hostname: string; ipaddress: string; }>; - reload: () => void; + reload: (e: MouseEvent) => void; } type Style = { @@ -25,7 +25,7 @@ type Style = { warning: CSSProperties; } -export default class ClusterTable extends React.PureComponent { +export default class ClusterTable extends PureComponent { render() { let versionMismatch = ( { + interval: NodeJS.Timeout | null; + + constructor(props: null) { super(props); this.interval = null; @@ -21,7 +28,7 @@ export default class ClusterTableContainer extends React.PureComponent { load = () => { getClusterStatus( - (data) => { + (data: ClusterInfo[]) => { this.setState({ clusterInfos: data, }); @@ -43,7 +50,7 @@ export default class ClusterTableContainer extends React.PureComponent { } } - reload = (e) => { + reload = (e: MouseEvent) => { if (e) { e.preventDefault(); } diff --git a/webapp/channels/src/components/admin_console/session_length_settings.jsx b/webapp/channels/src/components/admin_console/session_length_settings.tsx similarity index 90% rename from webapp/channels/src/components/admin_console/session_length_settings.jsx rename to webapp/channels/src/components/admin_console/session_length_settings.tsx index 6c78f4239c..8ddd1ab8be 100644 --- a/webapp/channels/src/components/admin_console/session_length_settings.jsx +++ b/webapp/channels/src/components/admin_console/session_length_settings.tsx @@ -4,16 +4,32 @@ import React from 'react'; import {FormattedMessage} from 'react-intl'; +import {AdminConfig, ClientLicense, ServiceSettings} from '@mattermost/types/config'; + import FormattedMarkdownMessage from 'components/formatted_markdown_message'; import * as Utils from 'utils/utils'; -import AdminSettings from './admin_settings'; +import AdminSettings, {BaseState, BaseProps} from './admin_settings'; import BooleanSetting from './boolean_setting'; import SettingsGroup from './settings_group'; import TextSetting from './text_setting'; -export default class SessionLengthSettings extends AdminSettings { - getConfigFromState = (config) => { +interface State extends BaseState { + extendSessionLengthWithActivity: ServiceSettings['ExtendSessionLengthWithActivity']; + sessionLengthWebInHours: ServiceSettings['SessionLengthWebInHours']; + sessionLengthMobileInHours: ServiceSettings['SessionLengthMobileInHours']; + sessionLengthSSOInHours: ServiceSettings['SessionLengthSSOInHours']; + sessionCacheInMinutes: ServiceSettings['SessionCacheInMinutes']; + sessionIdleTimeoutInMinutes: ServiceSettings['SessionIdleTimeoutInMinutes']; + sessionIdleTimeoutMobileInMinutes: ClientLicense['SessionIdleTimeoutMobileInMinutes']; +} + +interface Props extends BaseProps { + license: ClientLicense; +} + +export default class SessionLengthSettings extends AdminSettings { + getConfigFromState = (config: AdminConfig) => { const MINIMUM_IDLE_TIMEOUT = 5; config.ServiceSettings.ExtendSessionLengthWithActivity = this.state.extendSessionLengthWithActivity; @@ -26,7 +42,7 @@ export default class SessionLengthSettings extends AdminSettings { return config; }; - getStateFromConfig(config) { + getStateFromConfig(config: AdminConfig) { return { extendSessionLengthWithActivity: config.ServiceSettings.ExtendSessionLengthWithActivity, sessionLengthWebInHours: config.ServiceSettings.SessionLengthWebInHours, @@ -94,6 +110,7 @@ export default class SessionLengthSettings extends AdminSettings { sessionTimeoutSetting = ( - } + />} placeholder={Utils.localizeMessage('admin.service.sessionHoursEx', 'E.g.: "720"')} helpText={sessionLengthMobileHelpText} value={this.state.sessionLengthMobileInHours} onChange={this.handleChange} setByEnv={this.isSetByEnv('ServiceSettings.SessionLengthMobileInHours')} disabled={this.props.isDisabled} + type='number' /> - } + />} placeholder={Utils.localizeMessage('admin.service.sessionHoursEx', 'E.g.: "720"')} helpText={sessionLengthSSOHelpText} value={this.state.sessionLengthSSOInHours} onChange={this.handleChange} setByEnv={this.isSetByEnv('ServiceSettings.SessionLengthSSOInHours')} disabled={this.props.isDisabled} + type='number' /> - } + />} placeholder={Utils.localizeMessage('admin.service.sessionMinutesEx', 'E.g.: "10"')} helpText={ - } + />} value={this.state.sessionCacheInMinutes} onChange={this.handleChange} setByEnv={this.isSetByEnv('ServiceSettings.SessionCacheInMinutes')} disabled={this.props.isDisabled} + type='number' /> {sessionTimeoutSetting}