Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
MM 20404 Migrate 'components/announcement_bar/version_bar' module and…
Browse files Browse the repository at this point in the history
… associated tests to TypeScript (#6976)

* MM-20404

* MM-20404 Migrate 'components/announcement_bar/version_bar' module and associated tests to TypeScript

* fix lint

* MM-20404 Migrate 'components/announcement_bar/version_bar' module and associated tests to TypeScript

* fix linter

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
  • Loading branch information
tianlangwu and mattermod authored Nov 13, 2020
1 parent 8deb1ff commit a23102d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@

import {connect} from 'react-redux';

import VersionBar from './version_bar.jsx';
import {GlobalState} from 'mattermost-redux/types/store';

function mapStateToProps(state) {
import VersionBar from './version_bar';

function mapStateToProps(state:GlobalState) {
return {
serverVersion: state.entities.general.serverVersion,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// See LICENSE.txt for license information.

import React from 'react';
import PropTypes from 'prop-types';

import {FormattedMessage} from 'react-intl';

Expand All @@ -11,20 +10,24 @@ import {AnnouncementBarTypes} from 'utils/constants';

import AnnouncementBar from '../default_announcement_bar';

export default class VersionBar extends React.PureComponent {
static propTypes = {
serverVersion: PropTypes.string,
};
interface Props {
serverVersion: string,
}

interface State {
serverVersionOnAppLoad: string,
}

constructor(props) {
export default class VersionBar extends React.PureComponent <Props, State> {
constructor(props:Props) {
super(props);

this.state = {
serverVersionOnAppLoad: props.serverVersion,
};
}

static getDerivedStateFromProps(props, state) {
static getDerivedStateFromProps(props:Props, state:State) {
if (!state.serverVersionOnAppLoad && props.serverVersion) {
return {
serverVersionOnAppLoad: props.serverVersion,
Expand Down

0 comments on commit a23102d

Please sign in to comment.