Replace React.PropTypes with usage of the prop-types package

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski 2019-07-31 12:19:29 +01:00
parent 06bb18bda5
commit 1087e04bb5
16 changed files with 64 additions and 46 deletions

View file

@ -1,5 +1,6 @@
/* /*
Copyright 2015, 2016 OpenMarket Ltd Copyright 2015, 2016 OpenMarket Ltd
Copyright 2019 Michael Telatynski <7t3chguy@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -14,15 +15,14 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
'use strict'; import React from 'react';
import PropTypes from 'prop-types';
const React = require('react');
import { _t } from '../../languageHandler'; import { _t } from '../../languageHandler';
module.exports = React.createClass({ module.exports = React.createClass({
displayName: 'CompatibilityPage', displayName: 'CompatibilityPage',
propTypes: { propTypes: {
onAccept: React.PropTypes.func, onAccept: PropTypes.func,
}, },
getDefaultProps: function() { getDefaultProps: function() {

View file

@ -3,6 +3,7 @@ Copyright 2015, 2016 OpenMarket Ltd
Copyright 2017 Vector Creations Ltd Copyright 2017 Vector Creations Ltd
Copyright 2017 New Vector Ltd Copyright 2017 New Vector Ltd
Copyright 2018 New Vector Ltd Copyright 2018 New Vector Ltd
Copyright 2019 Michael Telatynski <7t3chguy@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -30,9 +31,9 @@ import GroupStore from '../../stores/GroupStore';
export default class RightPanel extends React.Component { export default class RightPanel extends React.Component {
static get propTypes() { static get propTypes() {
return { return {
roomId: React.PropTypes.string, // if showing panels for a given room, this is set roomId: PropTypes.string, // if showing panels for a given room, this is set
groupId: React.PropTypes.string, // if showing panels for a given group, this is set groupId: PropTypes.string, // if showing panels for a given group, this is set
user: React.PropTypes.object, user: PropTypes.object,
}; };
} }

View file

@ -1,5 +1,6 @@
/* /*
Copyright 2015, 2016 OpenMarket Ltd Copyright 2015, 2016 OpenMarket Ltd
Copyright 2019 Michael Telatynski <7t3chguy@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -25,6 +26,7 @@ const sdk = require('../../index');
const dis = require('../../dispatcher'); const dis = require('../../dispatcher');
import { linkifyAndSanitizeHtml } from '../../HtmlUtils'; import { linkifyAndSanitizeHtml } from '../../HtmlUtils';
import PropTypes from 'prop-types';
import Promise from 'bluebird'; import Promise from 'bluebird';
import { _t } from '../../languageHandler'; import { _t } from '../../languageHandler';
import { instanceForInstanceId, protocolNameForInstanceId } from '../../utils/DirectoryUtils'; import { instanceForInstanceId, protocolNameForInstanceId } from '../../utils/DirectoryUtils';
@ -41,8 +43,8 @@ module.exports = React.createClass({
displayName: 'RoomDirectory', displayName: 'RoomDirectory',
propTypes: { propTypes: {
config: React.PropTypes.object, config: PropTypes.object,
onFinished: React.PropTypes.func.isRequired, onFinished: PropTypes.func.isRequired,
}, },
getDefaultProps: function() { getDefaultProps: function() {
@ -65,7 +67,7 @@ module.exports = React.createClass({
}, },
childContextTypes: { childContextTypes: {
matrixClient: React.PropTypes.object, matrixClient: PropTypes.object,
}, },
getChildContext: function() { getChildContext: function() {

View file

@ -1,5 +1,6 @@
/* /*
Copyright 2019 New Vector Ltd Copyright 2019 New Vector Ltd
Copyright 2019 Michael Telatynski <7t3chguy@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -15,6 +16,7 @@ limitations under the License.
*/ */
import React from "react"; import React from "react";
import PropTypes from "prop-types";
import Matrix from "matrix-js-sdk"; import Matrix from "matrix-js-sdk";
import MatrixClientPeg from "../../MatrixClientPeg"; import MatrixClientPeg from "../../MatrixClientPeg";
import sdk from "../../index"; import sdk from "../../index";
@ -24,7 +26,7 @@ import { _t } from '../../languageHandler';
export default class UserView extends React.Component { export default class UserView extends React.Component {
static get propTypes() { static get propTypes() {
return { return {
userId: React.PropTypes.string, userId: PropTypes.string,
}; };
} }

View file

@ -1,6 +1,7 @@
/* /*
Copyright 2017 OpenMarket Ltd Copyright 2017 OpenMarket Ltd
Copyright 2018 New Vector Ltd Copyright 2018 New Vector Ltd
Copyright 2019 Michael Telatynski <7t3chguy@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,6 +17,7 @@ limitations under the License.
*/ */
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types';
import sdk from '../../../index'; import sdk from '../../../index';
import SdkConfig from '../../../SdkConfig'; import SdkConfig from '../../../SdkConfig';
import Modal from '../../../Modal'; import Modal from '../../../Modal';
@ -200,5 +202,5 @@ export default class BugReportDialog extends React.Component {
} }
BugReportDialog.propTypes = { BugReportDialog.propTypes = {
onFinished: React.PropTypes.func.isRequired, onFinished: PropTypes.func.isRequired,
}; };

View file

@ -1,5 +1,6 @@
/* /*
Copyright 2016 Aviral Dasgupta Copyright 2016 Aviral Dasgupta
Copyright 2019 Michael Telatynski <7t3chguy@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -15,6 +16,7 @@
*/ */
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types';
import sdk from '../../../index'; import sdk from '../../../index';
import request from 'browser-request'; import request from 'browser-request';
import { _t } from '../../../languageHandler'; import { _t } from '../../../languageHandler';
@ -99,7 +101,7 @@ export default class ChangelogDialog extends React.Component {
} }
ChangelogDialog.propTypes = { ChangelogDialog.propTypes = {
version: React.PropTypes.string.isRequired, version: PropTypes.string.isRequired,
newVersion: React.PropTypes.string.isRequired, newVersion: PropTypes.string.isRequired,
onFinished: React.PropTypes.func.isRequired, onFinished: PropTypes.func.isRequired,
}; };

View file

@ -1,6 +1,7 @@
/* /*
Copyright 2017 Vector Creations Ltd Copyright 2017 Vector Creations Ltd
Copyright 2018 New Vector Ltd Copyright 2018 New Vector Ltd
Copyright 2019 Michael Telatynski <7t3chguy@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,6 +17,7 @@ limitations under the License.
*/ */
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types';
import sdk from '../../../index'; import sdk from '../../../index';
import { _t } from '../../../languageHandler'; import { _t } from '../../../languageHandler';
import Modal from '../../../Modal'; import Modal from '../../../Modal';
@ -63,7 +65,7 @@ const WarmFuzzy = function(props) {
export default React.createClass({ export default React.createClass({
displayName: 'SetPasswordDialog', displayName: 'SetPasswordDialog',
propTypes: { propTypes: {
onFinished: React.PropTypes.func.isRequired, onFinished: PropTypes.func.isRequired,
}, },
getInitialState: function() { getInitialState: function() {

View file

@ -1,5 +1,6 @@
/* /*
Copyright 2016 OpenMarket Ltd Copyright 2016 OpenMarket Ltd
Copyright 2019 Michael Telatynski <7t3chguy@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -15,6 +16,7 @@ limitations under the License.
*/ */
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types';
import MatrixClientPeg from '../../../MatrixClientPeg'; import MatrixClientPeg from '../../../MatrixClientPeg';
import {instanceForInstanceId} from '../../../utils/DirectoryUtils'; import {instanceForInstanceId} from '../../../utils/DirectoryUtils';
@ -241,10 +243,10 @@ export default class NetworkDropdown extends React.Component {
} }
NetworkDropdown.propTypes = { NetworkDropdown.propTypes = {
onOptionChange: React.PropTypes.func.isRequired, onOptionChange: PropTypes.func.isRequired,
protocols: React.PropTypes.object, protocols: PropTypes.object,
// The room directory config. May have a 'servers' key that is a list of server names to include in the dropdown // The room directory config. May have a 'servers' key that is a list of server names to include in the dropdown
config: React.PropTypes.object, config: PropTypes.object,
}; };
NetworkDropdown.defaultProps = { NetworkDropdown.defaultProps = {

View file

@ -1,5 +1,6 @@
/* /*
Copyright 2017 Vector Creations Ltd Copyright 2017 Vector Creations Ltd
Copyright 2019 Michael Telatynski <7t3chguy@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -58,7 +59,7 @@ class MenuOption extends React.Component {
MenuOption.propTypes = { MenuOption.propTypes = {
children: PropTypes.oneOfType([ children: PropTypes.oneOfType([
PropTypes.arrayOf(React.PropTypes.node), PropTypes.arrayOf(PropTypes.node),
PropTypes.node, PropTypes.node,
]), ]),
highlighted: PropTypes.bool, highlighted: PropTypes.bool,

View file

@ -17,7 +17,8 @@ limitations under the License.
'use strict'; 'use strict';
const React = require('react'); import React from 'react';
import PropTypes from 'prop-types';
const MatrixClientPeg = require('../../../MatrixClientPeg'); const MatrixClientPeg = require('../../../MatrixClientPeg');
@ -30,19 +31,19 @@ import { _t } from '../../../languageHandler';
export default class ImageView extends React.Component { export default class ImageView extends React.Component {
static propTypes = { static propTypes = {
src: React.PropTypes.string.isRequired, // the source of the image being displayed src: PropTypes.string.isRequired, // the source of the image being displayed
name: React.PropTypes.string, // the main title ('name') for the image name: PropTypes.string, // the main title ('name') for the image
link: React.PropTypes.string, // the link (if any) applied to the name of the image link: PropTypes.string, // the link (if any) applied to the name of the image
width: React.PropTypes.number, // width of the image src in pixels width: PropTypes.number, // width of the image src in pixels
height: React.PropTypes.number, // height of the image src in pixels height: PropTypes.number, // height of the image src in pixels
fileSize: React.PropTypes.number, // size of the image src in bytes fileSize: PropTypes.number, // size of the image src in bytes
onFinished: React.PropTypes.func.isRequired, // callback when the lightbox is dismissed onFinished: PropTypes.func.isRequired, // callback when the lightbox is dismissed
// the event (if any) that the Image is displaying. Used for event-specific stuff like // the event (if any) that the Image is displaying. Used for event-specific stuff like
// redactions, senders, timestamps etc. Other descriptors are taken from the explicit // redactions, senders, timestamps etc. Other descriptors are taken from the explicit
// properties above, which let us use lightboxes to display images which aren't associated // properties above, which let us use lightboxes to display images which aren't associated
// with events. // with events.
mxEvent: React.PropTypes.object, mxEvent: PropTypes.object,
}; };
constructor(props) { constructor(props) {

View file

@ -1,6 +1,7 @@
/* /*
Copyright 2015, 2016 OpenMarket Ltd Copyright 2015, 2016 OpenMarket Ltd
Copyright 2019 New Vector Ltd Copyright 2019 New Vector Ltd
Copyright 2019 Michael Telatynski <7t3chguy@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -18,6 +19,7 @@ limitations under the License.
import React from 'react'; import React from 'react';
import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom';
import PropTypes from 'prop-types';
import dis from '../../../dispatcher'; import dis from '../../../dispatcher';
import classNames from 'classnames'; import classNames from 'classnames';
@ -28,15 +30,15 @@ module.exports = React.createClass({
propTypes: { propTypes: {
// Class applied to the element used to position the tooltip // Class applied to the element used to position the tooltip
className: React.PropTypes.string, className: PropTypes.string,
// Class applied to the tooltip itself // Class applied to the tooltip itself
tooltipClassName: React.PropTypes.string, tooltipClassName: PropTypes.string,
// Whether the tooltip is visible or hidden. // Whether the tooltip is visible or hidden.
// The hidden state allows animating the tooltip away via CSS. // The hidden state allows animating the tooltip away via CSS.
// Defaults to visible if unset. // Defaults to visible if unset.
visible: React.PropTypes.bool, visible: PropTypes.bool,
// the react element to put into the tooltip // the react element to put into the tooltip
label: React.PropTypes.node, label: PropTypes.node,
}, },
getDefaultProps() { getDefaultProps() {

View file

@ -25,7 +25,7 @@ module.exports = React.createClass({
propTypes: { propTypes: {
onChange: PropTypes.func, onChange: PropTypes.func,
selected_users: PropTypes.arrayOf(React.PropTypes.string), selected_users: PropTypes.arrayOf(PropTypes.string),
}, },
getDefaultProps: function() { getDefaultProps: function() {

View file

@ -1,5 +1,6 @@
/* /*
Copyright 2015, 2016 OpenMarket Ltd Copyright 2015, 2016 OpenMarket Ltd
Copyright 2019 Michael Telatynski <7t3chguy@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -14,9 +15,8 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
'use strict';
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types';
import sdk from '../../../index'; import sdk from '../../../index';
import Modal from '../../../Modal'; import Modal from '../../../Modal';
import PlatformPeg from '../../../PlatformPeg'; import PlatformPeg from '../../../PlatformPeg';
@ -33,9 +33,9 @@ function checkVersion(ver) {
export default React.createClass({ export default React.createClass({
propTypes: { propTypes: {
version: React.PropTypes.string.isRequired, version: PropTypes.string.isRequired,
newVersion: React.PropTypes.string.isRequired, newVersion: PropTypes.string.isRequired,
releaseNotes: React.PropTypes.string, releaseNotes: PropTypes.string,
}, },
displayReleaseNotes: function(releaseNotes) { displayReleaseNotes: function(releaseNotes) {

View file

@ -1,5 +1,5 @@
/* /*
Copyright 2017 Michael Telatynski <7t3chguy@gmail.com> Copyright 2017, 2019 Michael Telatynski <7t3chguy@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -14,19 +14,18 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
'use strict';
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types';
import { _t } from '../../../languageHandler'; import { _t } from '../../../languageHandler';
import PlatformPeg from '../../../PlatformPeg'; import PlatformPeg from '../../../PlatformPeg';
import AccessibleButton from '../../../components/views/elements/AccessibleButton'; import AccessibleButton from '../../../components/views/elements/AccessibleButton';
export default React.createClass({ export default React.createClass({
propTypes: { propTypes: {
status: React.PropTypes.string.isRequired, status: PropTypes.string.isRequired,
// Currently for error detail but will be usable for download progress // Currently for error detail but will be usable for download progress
// once that is a thing that squirrel passes through electron. // once that is a thing that squirrel passes through electron.
detail: React.PropTypes.string, detail: PropTypes.string,
}, },
getDefaultProps: function() { getDefaultProps: function() {

View file

@ -2,6 +2,7 @@
Copyright 2015, 2016 OpenMarket Ltd Copyright 2015, 2016 OpenMarket Ltd
Copyright 2017 New Vector Ltd Copyright 2017 New Vector Ltd
Copyright 2019 The Matrix.org Foundation C.I.C. Copyright 2019 The Matrix.org Foundation C.I.C.
Copyright 2019 Michael Telatynski <7t3chguy@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -131,7 +132,7 @@ module.exports = withMatrixClient(React.createClass({
onHeightChanged: PropTypes.func, onHeightChanged: PropTypes.func,
/* a list of read-receipts we should show. Each object has a 'roomMember' and 'ts'. */ /* a list of read-receipts we should show. Each object has a 'roomMember' and 'ts'. */
readReceipts: PropTypes.arrayOf(React.PropTypes.object), readReceipts: PropTypes.arrayOf(PropTypes.object),
/* opaque readreceipt info for each userId; used by ReadReceiptMarker /* opaque readreceipt info for each userId; used by ReadReceiptMarker
* to manage its animations. Should be an empty object when the room * to manage its animations. Should be an empty object when the room

View file

@ -18,6 +18,7 @@ import SettingsStore from "../../../src/settings/SettingsStore";
const React = require('react'); const React = require('react');
const ReactDOM = require("react-dom"); const ReactDOM = require("react-dom");
import PropTypes from "prop-types";
const TestUtils = require('react-addons-test-utils'); const TestUtils = require('react-addons-test-utils');
const expect = require('expect'); const expect = require('expect');
import sinon from 'sinon'; import sinon from 'sinon';
@ -40,7 +41,7 @@ const room = new Matrix.Room();
// wrap MessagePanel with a component which provides the MatrixClient in the context. // wrap MessagePanel with a component which provides the MatrixClient in the context.
const WrappedMessagePanel = React.createClass({ const WrappedMessagePanel = React.createClass({
childContextTypes: { childContextTypes: {
matrixClient: React.PropTypes.object, matrixClient: PropTypes.object,
}, },
getChildContext: function() { getChildContext: function() {