From 905efb4d8d33537765297700bbc0ecf8cd5fbe24 Mon Sep 17 00:00:00 2001 From: Junyong Liu Date: Fri, 30 Oct 2020 15:50:42 -0400 Subject: [PATCH 1/5] MM-20404 --- ....test.jsx.snap => version_bar.test.tsx.snap} | 0 .../version_bar/{index.js => index.ts} | 4 ++-- ...ersion_bar.test.jsx => version_bar.test.tsx} | 2 +- .../{version_bar.jsx => version_bar.tsx} | 17 +++++++++++++---- utils/server_version.tsx | 2 +- 5 files changed, 17 insertions(+), 8 deletions(-) rename components/announcement_bar/version_bar/__snapshots__/{version_bar.test.jsx.snap => version_bar.test.tsx.snap} (100%) rename components/announcement_bar/version_bar/{index.js => index.ts} (78%) rename components/announcement_bar/version_bar/{version_bar.test.jsx => version_bar.test.tsx} (98%) rename components/announcement_bar/version_bar/{version_bar.jsx => version_bar.tsx} (82%) diff --git a/components/announcement_bar/version_bar/__snapshots__/version_bar.test.jsx.snap b/components/announcement_bar/version_bar/__snapshots__/version_bar.test.tsx.snap similarity index 100% rename from components/announcement_bar/version_bar/__snapshots__/version_bar.test.jsx.snap rename to components/announcement_bar/version_bar/__snapshots__/version_bar.test.tsx.snap diff --git a/components/announcement_bar/version_bar/index.js b/components/announcement_bar/version_bar/index.ts similarity index 78% rename from components/announcement_bar/version_bar/index.js rename to components/announcement_bar/version_bar/index.ts index cec2391b8acc..c7c7b162de56 100644 --- a/components/announcement_bar/version_bar/index.js +++ b/components/announcement_bar/version_bar/index.ts @@ -3,9 +3,9 @@ import {connect} from 'react-redux'; -import VersionBar from './version_bar.jsx'; +import VersionBar from './version_bar'; -function mapStateToProps(state) { +function mapStateToProps(state:any) { return { serverVersion: state.entities.general.serverVersion, }; diff --git a/components/announcement_bar/version_bar/version_bar.test.jsx b/components/announcement_bar/version_bar/version_bar.test.tsx similarity index 98% rename from components/announcement_bar/version_bar/version_bar.test.jsx rename to components/announcement_bar/version_bar/version_bar.test.tsx index 62fb7215d781..68fdb7bf2a8f 100644 --- a/components/announcement_bar/version_bar/version_bar.test.jsx +++ b/components/announcement_bar/version_bar/version_bar.test.tsx @@ -4,7 +4,7 @@ import React from 'react'; import {shallow} from 'enzyme'; -import VersionBar from 'components/announcement_bar/version_bar/version_bar.jsx'; +import VersionBar from 'components/announcement_bar/version_bar/version_bar'; import AnnouncementBar from 'components/announcement_bar/default_announcement_bar'; describe('components/VersionBar', () => { diff --git a/components/announcement_bar/version_bar/version_bar.jsx b/components/announcement_bar/version_bar/version_bar.tsx similarity index 82% rename from components/announcement_bar/version_bar/version_bar.jsx rename to components/announcement_bar/version_bar/version_bar.tsx index b736f596eb66..ad86fa62b0f4 100644 --- a/components/announcement_bar/version_bar/version_bar.jsx +++ b/components/announcement_bar/version_bar/version_bar.tsx @@ -11,20 +11,29 @@ import {AnnouncementBarTypes} from 'utils/constants'; import AnnouncementBar from '../default_announcement_bar'; -export default class VersionBar extends React.PureComponent { +interface IMyComponentProps { + serverVersion?: any, +} + +interface IMyComponentState { + serverVersionOnAppLoad?: any, +} + +export default class VersionBar extends React.PureComponent { + static propTypes = { serverVersion: PropTypes.string, }; - constructor(props) { + constructor(props:IMyComponentProps) { super(props); this.state = { - serverVersionOnAppLoad: props.serverVersion, + serverVersionOnAppLoad: props.serverVersion, }; } - static getDerivedStateFromProps(props, state) { + static getDerivedStateFromProps(props:IMyComponentProps, state:IMyComponentState) { if (!state.serverVersionOnAppLoad && props.serverVersion) { return { serverVersionOnAppLoad: props.serverVersion, diff --git a/utils/server_version.tsx b/utils/server_version.tsx index fcee4cf581e7..fd7536d76ddb 100644 --- a/utils/server_version.tsx +++ b/utils/server_version.tsx @@ -12,7 +12,7 @@ * 4.7.0.dev.3034fbc5fd566195d1b53e03890e35ff.true * 4.7.1.dev.d131dd02c5e6eec4693d9a0698aff95c.true */ -export function equalServerVersions(a: string, b: string): boolean { +export function equalServerVersions(a?: string, b?: string): boolean { if (a === b) { return true; } From b4071fe4bacbdb18bb4b58984366e769111c21d6 Mon Sep 17 00:00:00 2001 From: Junyong Liu Date: Fri, 30 Oct 2020 15:51:16 -0400 Subject: [PATCH 2/5] MM-20404 Migrate 'components/announcement_bar/version_bar' module and associated tests to TypeScript --- components/announcement_bar/version_bar/version_bar.tsx | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/components/announcement_bar/version_bar/version_bar.tsx b/components/announcement_bar/version_bar/version_bar.tsx index ad86fa62b0f4..6471531832e8 100644 --- a/components/announcement_bar/version_bar/version_bar.tsx +++ b/components/announcement_bar/version_bar/version_bar.tsx @@ -2,7 +2,6 @@ // See LICENSE.txt for license information. import React from 'react'; -import PropTypes from 'prop-types'; import {FormattedMessage} from 'react-intl'; @@ -12,19 +11,15 @@ import {AnnouncementBarTypes} from 'utils/constants'; import AnnouncementBar from '../default_announcement_bar'; interface IMyComponentProps { - serverVersion?: any, + serverVersion?: string, } interface IMyComponentState { - serverVersionOnAppLoad?: any, + serverVersionOnAppLoad?: string, } export default class VersionBar extends React.PureComponent { - static propTypes = { - serverVersion: PropTypes.string, - }; - constructor(props:IMyComponentProps) { super(props); From 6c3c2d1223b82e407aa2f8048d14d152b1b271d9 Mon Sep 17 00:00:00 2001 From: Junyong Liu Date: Fri, 30 Oct 2020 16:23:03 -0400 Subject: [PATCH 3/5] fix lint --- components/announcement_bar/version_bar/version_bar.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/components/announcement_bar/version_bar/version_bar.tsx b/components/announcement_bar/version_bar/version_bar.tsx index 6471531832e8..0090463fa1fe 100644 --- a/components/announcement_bar/version_bar/version_bar.tsx +++ b/components/announcement_bar/version_bar/version_bar.tsx @@ -17,14 +17,13 @@ interface IMyComponentProps { interface IMyComponentState { serverVersionOnAppLoad?: string, } - -export default class VersionBar extends React.PureComponent { +export default class VersionBar extends React.PureComponent { constructor(props:IMyComponentProps) { super(props); this.state = { - serverVersionOnAppLoad: props.serverVersion, + serverVersionOnAppLoad: props.serverVersion, }; } From 3b2e29c85bde2e7f8bb223377c96b3927b5caa37 Mon Sep 17 00:00:00 2001 From: Junyong Liu Date: Mon, 2 Nov 2020 12:11:13 -0500 Subject: [PATCH 4/5] MM-20404 Migrate 'components/announcement_bar/version_bar' module and associated tests to TypeScript --- components/announcement_bar/version_bar/index.ts | 4 ++-- .../announcement_bar/version_bar/version_bar.tsx | 14 +++++++------- utils/server_version.tsx | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/components/announcement_bar/version_bar/index.ts b/components/announcement_bar/version_bar/index.ts index c7c7b162de56..3b034416b421 100644 --- a/components/announcement_bar/version_bar/index.ts +++ b/components/announcement_bar/version_bar/index.ts @@ -2,10 +2,10 @@ // See LICENSE.txt for license information. import {connect} from 'react-redux'; - +import {GlobalState} from 'mattermost-redux/types/store'; import VersionBar from './version_bar'; -function mapStateToProps(state:any) { +function mapStateToProps(state:GlobalState) { return { serverVersion: state.entities.general.serverVersion, }; diff --git a/components/announcement_bar/version_bar/version_bar.tsx b/components/announcement_bar/version_bar/version_bar.tsx index 0090463fa1fe..88b79b79483d 100644 --- a/components/announcement_bar/version_bar/version_bar.tsx +++ b/components/announcement_bar/version_bar/version_bar.tsx @@ -10,16 +10,16 @@ import {AnnouncementBarTypes} from 'utils/constants'; import AnnouncementBar from '../default_announcement_bar'; -interface IMyComponentProps { - serverVersion?: string, +interface Props { + serverVersion: string, } -interface IMyComponentState { - serverVersionOnAppLoad?: string, +interface State { + serverVersionOnAppLoad: string, } -export default class VersionBar extends React.PureComponent { - constructor(props:IMyComponentProps) { +export default class VersionBar extends React.PureComponent { + constructor(props:Props) { super(props); this.state = { @@ -27,7 +27,7 @@ export default class VersionBar extends React.PureComponent Date: Mon, 2 Nov 2020 12:21:35 -0500 Subject: [PATCH 5/5] fix linter --- components/announcement_bar/version_bar/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/announcement_bar/version_bar/index.ts b/components/announcement_bar/version_bar/index.ts index 3b034416b421..47a8a4b034ac 100644 --- a/components/announcement_bar/version_bar/index.ts +++ b/components/announcement_bar/version_bar/index.ts @@ -2,7 +2,9 @@ // See LICENSE.txt for license information. import {connect} from 'react-redux'; + import {GlobalState} from 'mattermost-redux/types/store'; + import VersionBar from './version_bar'; function mapStateToProps(state:GlobalState) {