[MM-52823] Migration of "components/admin_console/custom_url_schemes_setting.jsx" and tests to typescript (#23468)
Этот коммит содержится в:
@@ -36,7 +36,7 @@ import ExternalLink from 'components/external_link';
|
|||||||
|
|
||||||
import OpenIdConvert from './openid_convert';
|
import OpenIdConvert from './openid_convert';
|
||||||
import Audits from './audits';
|
import Audits from './audits';
|
||||||
import CustomURLSchemesSetting from './custom_url_schemes_setting.jsx';
|
import CustomURLSchemesSetting from './custom_url_schemes_setting';
|
||||||
import CustomEnableDisableGuestAccountsSetting from './custom_enable_disable_guest_accounts_setting';
|
import CustomEnableDisableGuestAccountsSetting from './custom_enable_disable_guest_accounts_setting';
|
||||||
import LicenseSettings from './license_settings';
|
import LicenseSettings from './license_settings';
|
||||||
import PermissionSchemesSettings from './permission_schemes_settings';
|
import PermissionSchemesSettings from './permission_schemes_settings';
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// See LICENSE.txt for license information.
|
// See LICENSE.txt for license information.
|
||||||
|
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import React from 'react';
|
import React, {ChangeEvent, PureComponent} from 'react';
|
||||||
|
|
||||||
import * as Utils from 'utils/utils';
|
import * as Utils from 'utils/utils';
|
||||||
import {t} from 'utils/i18n';
|
import {t} from 'utils/i18n';
|
||||||
@@ -11,7 +11,20 @@ import LocalizedInput from 'components/localized_input/localized_input';
|
|||||||
|
|
||||||
import Setting from './setting';
|
import Setting from './setting';
|
||||||
|
|
||||||
export default class CustomURLSchemesSetting extends React.PureComponent {
|
type Props = {
|
||||||
|
id: string;
|
||||||
|
value: string[];
|
||||||
|
onChange: (id: string, valueAsArray: string[]) => void;
|
||||||
|
disabled: boolean;
|
||||||
|
setByEnv: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
type State = {
|
||||||
|
value: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class CustomURLSchemesSetting extends
|
||||||
|
PureComponent<Props, State> {
|
||||||
static get propTypes() {
|
static get propTypes() {
|
||||||
return {
|
return {
|
||||||
id: PropTypes.string.isRequired,
|
id: PropTypes.string.isRequired,
|
||||||
@@ -22,7 +35,7 @@ export default class CustomURLSchemesSetting extends React.PureComponent {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props: Props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
@@ -30,15 +43,15 @@ export default class CustomURLSchemesSetting extends React.PureComponent {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
stringToArray = (str) => {
|
stringToArray = (str: string): string[] => {
|
||||||
return str.split(',').map((s) => s.trim()).filter(Boolean);
|
return str.split(',').map((s) => s.trim()).filter(Boolean);
|
||||||
};
|
};
|
||||||
|
|
||||||
arrayToString = (arr) => {
|
arrayToString = (arr: string[]): string => {
|
||||||
return arr.join(',');
|
return arr.join(',');
|
||||||
};
|
};
|
||||||
|
|
||||||
handleChange = (e) => {
|
handleChange = (e: ChangeEvent<HTMLInputElement>): void => {
|
||||||
const valueAsArray = this.stringToArray(e.target.value);
|
const valueAsArray = this.stringToArray(e.target.value);
|
||||||
|
|
||||||
this.props.onChange(this.props.id, valueAsArray);
|
this.props.onChange(this.props.id, valueAsArray);
|
||||||
Ссылка в новой задаче
Block a user