MM-52827, MM-52840 : Migrate "components/admin_console/session_length_settings.jsx" & "components/admin_console/cluster_table_container.jsx" to Typescript (#23509)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
2bb6830242
Коммит
fcb322b8f2
@@ -173,8 +173,8 @@ export default abstract class AdminSettings <Props extends BaseProps, State exte
|
|||||||
return n;
|
return n;
|
||||||
};
|
};
|
||||||
|
|
||||||
private parseIntZeroOrMin = (str: string, minimumValue = 1) => {
|
protected parseIntZeroOrMin = (str: string | number, minimumValue = 1) => {
|
||||||
const n = parseInt(str, 10);
|
const n = typeof str === 'string' ? parseInt(str, 10) : str;
|
||||||
|
|
||||||
if (isNaN(n) || n < 0) {
|
if (isNaN(n) || n < 0) {
|
||||||
return 0;
|
return 0;
|
||||||
@@ -186,8 +186,8 @@ export default abstract class AdminSettings <Props extends BaseProps, State exte
|
|||||||
return n;
|
return n;
|
||||||
};
|
};
|
||||||
|
|
||||||
protected parseIntNonZero = (str: string, defaultValue?: number, minimumValue = 1) => {
|
protected parseIntNonZero = (str: string | number, defaultValue?: number, minimumValue = 1) => {
|
||||||
const n = parseInt(str, 10);
|
const n = typeof str === 'string' ? parseInt(str, 10) : str;
|
||||||
|
|
||||||
if (isNaN(n) || n < minimumValue) {
|
if (isNaN(n) || n < minimumValue) {
|
||||||
if (defaultValue) {
|
if (defaultValue) {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import ExternalLink from 'components/external_link';
|
|||||||
|
|
||||||
import AdminSettings from './admin_settings';
|
import AdminSettings from './admin_settings';
|
||||||
import BooleanSetting from './boolean_setting';
|
import BooleanSetting from './boolean_setting';
|
||||||
import ClusterTableContainer from './cluster_table_container.jsx';
|
import ClusterTableContainer from './cluster_table_container';
|
||||||
import SettingsGroup from './settings_group';
|
import SettingsGroup from './settings_group';
|
||||||
import TextSetting from './text_setting';
|
import TextSetting from './text_setting';
|
||||||
import DocLinks from 'utils/constants';
|
import DocLinks from 'utils/constants';
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||||
// See LICENSE.txt for license information.
|
// See LICENSE.txt for license information.
|
||||||
|
|
||||||
import React, {CSSProperties} from 'react';
|
import React, {CSSProperties, MouseEvent, PureComponent} from 'react';
|
||||||
import {FormattedMessage} from 'react-intl';
|
import {FormattedMessage} from 'react-intl';
|
||||||
import * as Utils from 'utils/utils';
|
import * as Utils from 'utils/utils';
|
||||||
import statusGreen from 'images/status_green.png';
|
import statusGreen from 'images/status_green.png';
|
||||||
@@ -16,7 +16,7 @@ type Props = {
|
|||||||
hostname: string;
|
hostname: string;
|
||||||
ipaddress: string;
|
ipaddress: string;
|
||||||
}>;
|
}>;
|
||||||
reload: () => void;
|
reload: (e: MouseEvent<HTMLButtonElement>) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
type Style = {
|
type Style = {
|
||||||
@@ -25,7 +25,7 @@ type Style = {
|
|||||||
warning: CSSProperties;
|
warning: CSSProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class ClusterTable extends React.PureComponent<Props> {
|
export default class ClusterTable extends PureComponent<Props> {
|
||||||
render() {
|
render() {
|
||||||
let versionMismatch = (
|
let versionMismatch = (
|
||||||
<img
|
<img
|
||||||
|
|||||||
@@ -1,15 +1,22 @@
|
|||||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||||
// See LICENSE.txt for license information.
|
// See LICENSE.txt for license information.
|
||||||
|
|
||||||
import React from 'react';
|
import React, {MouseEvent, PureComponent} from 'react';
|
||||||
|
|
||||||
|
import {ClusterInfo} from '@mattermost/types/admin';
|
||||||
import {getClusterStatus} from 'actions/admin_actions.jsx';
|
import {getClusterStatus} from 'actions/admin_actions.jsx';
|
||||||
import LoadingScreen from '../loading_screen';
|
import LoadingScreen from '../loading_screen';
|
||||||
|
|
||||||
import ClusterTable from './cluster_table';
|
import ClusterTable from './cluster_table';
|
||||||
|
|
||||||
export default class ClusterTableContainer extends React.PureComponent {
|
interface State {
|
||||||
constructor(props) {
|
clusterInfos: ClusterInfo[] | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class ClusterTableContainer extends PureComponent<null, State> {
|
||||||
|
interval: NodeJS.Timeout | null;
|
||||||
|
|
||||||
|
constructor(props: null) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
this.interval = null;
|
this.interval = null;
|
||||||
@@ -21,7 +28,7 @@ export default class ClusterTableContainer extends React.PureComponent {
|
|||||||
|
|
||||||
load = () => {
|
load = () => {
|
||||||
getClusterStatus(
|
getClusterStatus(
|
||||||
(data) => {
|
(data: ClusterInfo[]) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
clusterInfos: data,
|
clusterInfos: data,
|
||||||
});
|
});
|
||||||
@@ -43,7 +50,7 @@ export default class ClusterTableContainer extends React.PureComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
reload = (e) => {
|
reload = (e: MouseEvent<HTMLButtonElement>) => {
|
||||||
if (e) {
|
if (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
@@ -4,16 +4,32 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {FormattedMessage} from 'react-intl';
|
import {FormattedMessage} from 'react-intl';
|
||||||
|
|
||||||
|
import {AdminConfig, ClientLicense, ServiceSettings} from '@mattermost/types/config';
|
||||||
|
|
||||||
import FormattedMarkdownMessage from 'components/formatted_markdown_message';
|
import FormattedMarkdownMessage from 'components/formatted_markdown_message';
|
||||||
import * as Utils from 'utils/utils';
|
import * as Utils from 'utils/utils';
|
||||||
|
|
||||||
import AdminSettings from './admin_settings';
|
import AdminSettings, {BaseState, BaseProps} from './admin_settings';
|
||||||
import BooleanSetting from './boolean_setting';
|
import BooleanSetting from './boolean_setting';
|
||||||
import SettingsGroup from './settings_group';
|
import SettingsGroup from './settings_group';
|
||||||
import TextSetting from './text_setting';
|
import TextSetting from './text_setting';
|
||||||
|
|
||||||
export default class SessionLengthSettings extends AdminSettings {
|
interface State extends BaseState {
|
||||||
getConfigFromState = (config) => {
|
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<Props, State> {
|
||||||
|
getConfigFromState = (config: AdminConfig) => {
|
||||||
const MINIMUM_IDLE_TIMEOUT = 5;
|
const MINIMUM_IDLE_TIMEOUT = 5;
|
||||||
|
|
||||||
config.ServiceSettings.ExtendSessionLengthWithActivity = this.state.extendSessionLengthWithActivity;
|
config.ServiceSettings.ExtendSessionLengthWithActivity = this.state.extendSessionLengthWithActivity;
|
||||||
@@ -26,7 +42,7 @@ export default class SessionLengthSettings extends AdminSettings {
|
|||||||
return config;
|
return config;
|
||||||
};
|
};
|
||||||
|
|
||||||
getStateFromConfig(config) {
|
getStateFromConfig(config: AdminConfig) {
|
||||||
return {
|
return {
|
||||||
extendSessionLengthWithActivity: config.ServiceSettings.ExtendSessionLengthWithActivity,
|
extendSessionLengthWithActivity: config.ServiceSettings.ExtendSessionLengthWithActivity,
|
||||||
sessionLengthWebInHours: config.ServiceSettings.SessionLengthWebInHours,
|
sessionLengthWebInHours: config.ServiceSettings.SessionLengthWebInHours,
|
||||||
@@ -94,6 +110,7 @@ export default class SessionLengthSettings extends AdminSettings {
|
|||||||
sessionTimeoutSetting = (
|
sessionTimeoutSetting = (
|
||||||
<TextSetting
|
<TextSetting
|
||||||
id='sessionIdleTimeoutInMinutes'
|
id='sessionIdleTimeoutInMinutes'
|
||||||
|
type='number'
|
||||||
label={
|
label={
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
id='admin.service.sessionIdleTimeout'
|
id='admin.service.sessionIdleTimeout'
|
||||||
@@ -150,6 +167,7 @@ export default class SessionLengthSettings extends AdminSettings {
|
|||||||
onChange={this.handleChange}
|
onChange={this.handleChange}
|
||||||
setByEnv={this.isSetByEnv('ServiceSettings.SessionLengthWebInHours')}
|
setByEnv={this.isSetByEnv('ServiceSettings.SessionLengthWebInHours')}
|
||||||
disabled={this.props.isDisabled}
|
disabled={this.props.isDisabled}
|
||||||
|
type='number'
|
||||||
/>
|
/>
|
||||||
<TextSetting
|
<TextSetting
|
||||||
id='sessionLengthMobileInHours'
|
id='sessionLengthMobileInHours'
|
||||||
@@ -157,14 +175,14 @@ export default class SessionLengthSettings extends AdminSettings {
|
|||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
id='admin.service.mobileSessionHours'
|
id='admin.service.mobileSessionHours'
|
||||||
defaultMessage='Session Length Mobile (hours):'
|
defaultMessage='Session Length Mobile (hours):'
|
||||||
/>
|
/>}
|
||||||
}
|
|
||||||
placeholder={Utils.localizeMessage('admin.service.sessionHoursEx', 'E.g.: "720"')}
|
placeholder={Utils.localizeMessage('admin.service.sessionHoursEx', 'E.g.: "720"')}
|
||||||
helpText={sessionLengthMobileHelpText}
|
helpText={sessionLengthMobileHelpText}
|
||||||
value={this.state.sessionLengthMobileInHours}
|
value={this.state.sessionLengthMobileInHours}
|
||||||
onChange={this.handleChange}
|
onChange={this.handleChange}
|
||||||
setByEnv={this.isSetByEnv('ServiceSettings.SessionLengthMobileInHours')}
|
setByEnv={this.isSetByEnv('ServiceSettings.SessionLengthMobileInHours')}
|
||||||
disabled={this.props.isDisabled}
|
disabled={this.props.isDisabled}
|
||||||
|
type='number'
|
||||||
/>
|
/>
|
||||||
<TextSetting
|
<TextSetting
|
||||||
id='sessionLengthSSOInHours'
|
id='sessionLengthSSOInHours'
|
||||||
@@ -172,14 +190,14 @@ export default class SessionLengthSettings extends AdminSettings {
|
|||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
id='admin.service.ssoSessionHours'
|
id='admin.service.ssoSessionHours'
|
||||||
defaultMessage='Session Length SSO (hours):'
|
defaultMessage='Session Length SSO (hours):'
|
||||||
/>
|
/>}
|
||||||
}
|
|
||||||
placeholder={Utils.localizeMessage('admin.service.sessionHoursEx', 'E.g.: "720"')}
|
placeholder={Utils.localizeMessage('admin.service.sessionHoursEx', 'E.g.: "720"')}
|
||||||
helpText={sessionLengthSSOHelpText}
|
helpText={sessionLengthSSOHelpText}
|
||||||
value={this.state.sessionLengthSSOInHours}
|
value={this.state.sessionLengthSSOInHours}
|
||||||
onChange={this.handleChange}
|
onChange={this.handleChange}
|
||||||
setByEnv={this.isSetByEnv('ServiceSettings.SessionLengthSSOInHours')}
|
setByEnv={this.isSetByEnv('ServiceSettings.SessionLengthSSOInHours')}
|
||||||
disabled={this.props.isDisabled}
|
disabled={this.props.isDisabled}
|
||||||
|
type='number'
|
||||||
/>
|
/>
|
||||||
<TextSetting
|
<TextSetting
|
||||||
id='sessionCacheInMinutes'
|
id='sessionCacheInMinutes'
|
||||||
@@ -187,19 +205,18 @@ export default class SessionLengthSettings extends AdminSettings {
|
|||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
id='admin.service.sessionCache'
|
id='admin.service.sessionCache'
|
||||||
defaultMessage='Session Cache (minutes):'
|
defaultMessage='Session Cache (minutes):'
|
||||||
/>
|
/>}
|
||||||
}
|
|
||||||
placeholder={Utils.localizeMessage('admin.service.sessionMinutesEx', 'E.g.: "10"')}
|
placeholder={Utils.localizeMessage('admin.service.sessionMinutesEx', 'E.g.: "10"')}
|
||||||
helpText={
|
helpText={
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
id='admin.service.sessionCacheDesc'
|
id='admin.service.sessionCacheDesc'
|
||||||
defaultMessage='The number of minutes to cache a session in memory:'
|
defaultMessage='The number of minutes to cache a session in memory:'
|
||||||
/>
|
/>}
|
||||||
}
|
|
||||||
value={this.state.sessionCacheInMinutes}
|
value={this.state.sessionCacheInMinutes}
|
||||||
onChange={this.handleChange}
|
onChange={this.handleChange}
|
||||||
setByEnv={this.isSetByEnv('ServiceSettings.SessionCacheInMinutes')}
|
setByEnv={this.isSetByEnv('ServiceSettings.SessionCacheInMinutes')}
|
||||||
disabled={this.props.isDisabled}
|
disabled={this.props.isDisabled}
|
||||||
|
type='number'
|
||||||
/>
|
/>
|
||||||
{sessionTimeoutSetting}
|
{sessionTimeoutSetting}
|
||||||
</SettingsGroup>
|
</SettingsGroup>
|
||||||
Ссылка в новой задаче
Block a user