From 6b657cd66e33f9abeb5fafb03ab54fdb59b3c9c9 Mon Sep 17 00:00:00 2001 From: Clem Coll1n Date: Mon, 19 Oct 2020 21:39:10 +0200 Subject: [PATCH] [MM-20582] Migrate 'components/admin_console/team_channel_settings/channel' module and associated tests to TypeScript --- ...sx.snap => channel_settings.test.tsx.snap} | 0 ...ngs.test.jsx => channel_settings.test.tsx} | 2 +- ...nnel_settings.jsx => channel_settings.tsx} | 21 ++++++++++++------- .../channel/{index.js => index.ts} | 4 +++- .../channel/list/channel_list.tsx | 3 ++- 5 files changed, 19 insertions(+), 11 deletions(-) rename components/admin_console/team_channel_settings/channel/__snapshots__/{channel_settings.test.jsx.snap => channel_settings.test.tsx.snap} (100%) rename components/admin_console/team_channel_settings/channel/{channel_settings.test.jsx => channel_settings.test.tsx} (89%) rename components/admin_console/team_channel_settings/channel/{channel_settings.jsx => channel_settings.tsx} (83%) rename components/admin_console/team_channel_settings/channel/{index.js => index.ts} (81%) diff --git a/components/admin_console/team_channel_settings/channel/__snapshots__/channel_settings.test.jsx.snap b/components/admin_console/team_channel_settings/channel/__snapshots__/channel_settings.test.tsx.snap similarity index 100% rename from components/admin_console/team_channel_settings/channel/__snapshots__/channel_settings.test.jsx.snap rename to components/admin_console/team_channel_settings/channel/__snapshots__/channel_settings.test.tsx.snap diff --git a/components/admin_console/team_channel_settings/channel/channel_settings.test.jsx b/components/admin_console/team_channel_settings/channel/channel_settings.test.tsx similarity index 89% rename from components/admin_console/team_channel_settings/channel/channel_settings.test.jsx rename to components/admin_console/team_channel_settings/channel/channel_settings.test.tsx index 179228e00a04..2dfaa2fb7ef5 100644 --- a/components/admin_console/team_channel_settings/channel/channel_settings.test.jsx +++ b/components/admin_console/team_channel_settings/channel/channel_settings.test.tsx @@ -4,7 +4,7 @@ import React from 'react'; import {shallow} from 'enzyme'; -import {ChannelsSettings} from './channel_settings.jsx'; +import {ChannelsSettings} from './channel_settings'; describe('admin_console/team_channel_settings/channel/ChannelSettings', () => { test('should match snapshot', () => { diff --git a/components/admin_console/team_channel_settings/channel/channel_settings.jsx b/components/admin_console/team_channel_settings/channel/channel_settings.tsx similarity index 83% rename from components/admin_console/team_channel_settings/channel/channel_settings.jsx rename to components/admin_console/team_channel_settings/channel/channel_settings.tsx index f33eaa0be4e4..9fffca2eff9a 100644 --- a/components/admin_console/team_channel_settings/channel/channel_settings.jsx +++ b/components/admin_console/team_channel_settings/channel/channel_settings.tsx @@ -2,19 +2,24 @@ // See LICENSE.txt for license information. import React from 'react'; -import PropTypes from 'prop-types'; import {FormattedMessage} from 'react-intl'; import {t} from 'utils/i18n'; import ChannelsList from 'components/admin_console/team_channel_settings/channel/list'; import AdminPanel from 'components/widgets/admin_console/admin_panel'; -export class ChannelsSettings extends React.PureComponent { - static propTypes = { - siteName: PropTypes.string.isRequired, - }; +interface Props { + siteName?: string, +} + +export interface ChannelSettingsState { + startCount: number, + endCount: number, + total: number, +} - constructor(props) { +export class ChannelsSettings extends React.PureComponent { + constructor(props: Props) { super(props); this.state = { startCount: 0, @@ -23,8 +28,8 @@ export class ChannelsSettings extends React.PureComponent { }; } - onPageChangedCallback = ({startCount, endCount, total}) => { - this.setState({startCount, endCount, total}); + onPageChangedCallback = (state: ChannelSettingsState) => { + this.setState({...state}); } render = () => { diff --git a/components/admin_console/team_channel_settings/channel/index.js b/components/admin_console/team_channel_settings/channel/index.ts similarity index 81% rename from components/admin_console/team_channel_settings/channel/index.js rename to components/admin_console/team_channel_settings/channel/index.ts index 107e293f81b7..d2426bf0e733 100644 --- a/components/admin_console/team_channel_settings/channel/index.js +++ b/components/admin_console/team_channel_settings/channel/index.ts @@ -4,9 +4,11 @@ import {getConfig} from 'mattermost-redux/selectors/entities/general'; import {connect} from 'react-redux'; +import {GlobalState} from 'mattermost-redux/types/store'; + import {ChannelsSettings} from './channel_settings'; -function mapStateToProps(state) { +function mapStateToProps(state: GlobalState) { const config = getConfig(state); const siteName = config.SiteName; diff --git a/components/admin_console/team_channel_settings/channel/list/channel_list.tsx b/components/admin_console/team_channel_settings/channel/list/channel_list.tsx index 28c44ff0484a..867575eda27d 100644 --- a/components/admin_console/team_channel_settings/channel/list/channel_list.tsx +++ b/components/admin_console/team_channel_settings/channel/list/channel_list.tsx @@ -23,6 +23,7 @@ import LockIcon from 'components/widgets/icons/lock_icon'; import ArchiveIcon from 'components/widgets/icons/archive_icon'; import './channel_list.scss'; +import {ChannelSettingsState} from "../channel_settings"; interface ChannelListProps { actions: { searchAllChannels: (term: string, opts: ChannelSearchOpts) => Promise<{ data: any }>; @@ -31,7 +32,7 @@ interface ChannelListProps { data: ChannelWithTeamData[]; total: number; removeGroup?: () => void; - onPageChangedCallback?: () => void; + onPageChangedCallback?: (state: ChannelSettingsState) => void; emptyListTextId?: string; emptyListTextDefaultMessage?: string; isDisabled?: boolean;