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

Commit

Permalink
Merge pull request #3263 from matrix-org/t3chguy/prop-types
Browse files Browse the repository at this point in the history
Replace React.PropTypes with usage of the `prop-types` package
  • Loading branch information
t3chguy authored Jul 31, 2019
2 parents 85076e4 + 201d7fb commit 4694a9b
Show file tree
Hide file tree
Showing 16 changed files with 65 additions and 47 deletions.
8 changes: 4 additions & 4 deletions src/components/structures/CompatibilityPage.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
Copyright 2015, 2016 OpenMarket Ltd
Copyright 2019 Michael Telatynski <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -14,15 +15,14 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

'use strict';

const React = require('react');
import React from 'react';
import PropTypes from 'prop-types';
import { _t } from '../../languageHandler';

module.exports = React.createClass({
displayName: 'CompatibilityPage',
propTypes: {
onAccept: React.PropTypes.func,
onAccept: PropTypes.func,
},

getDefaultProps: function() {
Expand Down
7 changes: 4 additions & 3 deletions src/components/structures/RightPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Copyright 2015, 2016 OpenMarket Ltd
Copyright 2017 Vector Creations Ltd
Copyright 2017 New Vector Ltd
Copyright 2018 New Vector Ltd
Copyright 2019 Michael Telatynski <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -30,9 +31,9 @@ import GroupStore from '../../stores/GroupStore';
export default class RightPanel extends React.Component {
static get propTypes() {
return {
roomId: React.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
user: React.PropTypes.object,
roomId: PropTypes.string, // if showing panels for a given room, this is set
groupId: PropTypes.string, // if showing panels for a given group, this is set
user: PropTypes.object,
};
}

Expand Down
8 changes: 5 additions & 3 deletions src/components/structures/RoomDirectory.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
Copyright 2015, 2016 OpenMarket Ltd
Copyright 2019 Michael Telatynski <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -25,6 +26,7 @@ const sdk = require('../../index');
const dis = require('../../dispatcher');

import { linkifyAndSanitizeHtml } from '../../HtmlUtils';
import PropTypes from 'prop-types';
import Promise from 'bluebird';
import { _t } from '../../languageHandler';
import { instanceForInstanceId, protocolNameForInstanceId } from '../../utils/DirectoryUtils';
Expand All @@ -41,8 +43,8 @@ module.exports = React.createClass({
displayName: 'RoomDirectory',

propTypes: {
config: React.PropTypes.object,
onFinished: React.PropTypes.func.isRequired,
config: PropTypes.object,
onFinished: PropTypes.func.isRequired,
},

getDefaultProps: function() {
Expand All @@ -65,7 +67,7 @@ module.exports = React.createClass({
},

childContextTypes: {
matrixClient: React.PropTypes.object,
matrixClient: PropTypes.object,
},

getChildContext: function() {
Expand Down
4 changes: 3 additions & 1 deletion src/components/structures/UserView.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
Copyright 2019 New Vector Ltd
Copyright 2019 Michael Telatynski <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -15,6 +16,7 @@ limitations under the License.
*/

import React from "react";
import PropTypes from "prop-types";
import Matrix from "matrix-js-sdk";
import MatrixClientPeg from "../../MatrixClientPeg";
import sdk from "../../index";
Expand All @@ -24,7 +26,7 @@ import { _t } from '../../languageHandler';
export default class UserView extends React.Component {
static get propTypes() {
return {
userId: React.PropTypes.string,
userId: PropTypes.string,
};
}

Expand Down
4 changes: 3 additions & 1 deletion src/components/views/dialogs/BugReportDialog.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
Copyright 2017 OpenMarket Ltd
Copyright 2018 New Vector Ltd
Copyright 2019 Michael Telatynski <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -16,6 +17,7 @@ limitations under the License.
*/

import React from 'react';
import PropTypes from 'prop-types';
import sdk from '../../../index';
import SdkConfig from '../../../SdkConfig';
import Modal from '../../../Modal';
Expand Down Expand Up @@ -200,5 +202,5 @@ export default class BugReportDialog extends React.Component {
}

BugReportDialog.propTypes = {
onFinished: React.PropTypes.func.isRequired,
onFinished: PropTypes.func.isRequired,
};
8 changes: 5 additions & 3 deletions src/components/views/dialogs/ChangelogDialog.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
Copyright 2016 Aviral Dasgupta
Copyright 2019 Michael Telatynski <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -15,6 +16,7 @@
*/

import React from 'react';
import PropTypes from 'prop-types';
import sdk from '../../../index';
import request from 'browser-request';
import { _t } from '../../../languageHandler';
Expand Down Expand Up @@ -99,7 +101,7 @@ export default class ChangelogDialog extends React.Component {
}

ChangelogDialog.propTypes = {
version: React.PropTypes.string.isRequired,
newVersion: React.PropTypes.string.isRequired,
onFinished: React.PropTypes.func.isRequired,
version: PropTypes.string.isRequired,
newVersion: PropTypes.string.isRequired,
onFinished: PropTypes.func.isRequired,
};
4 changes: 3 additions & 1 deletion src/components/views/dialogs/SetPasswordDialog.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
Copyright 2017 Vector Creations Ltd
Copyright 2018 New Vector Ltd
Copyright 2019 Michael Telatynski <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -16,6 +17,7 @@ limitations under the License.
*/

import React from 'react';
import PropTypes from 'prop-types';
import sdk from '../../../index';
import { _t } from '../../../languageHandler';
import Modal from '../../../Modal';
Expand Down Expand Up @@ -63,7 +65,7 @@ const WarmFuzzy = function(props) {
export default React.createClass({
displayName: 'SetPasswordDialog',
propTypes: {
onFinished: React.PropTypes.func.isRequired,
onFinished: PropTypes.func.isRequired,
},

getInitialState: function() {
Expand Down
8 changes: 5 additions & 3 deletions src/components/views/directory/NetworkDropdown.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
Copyright 2016 OpenMarket Ltd
Copyright 2019 Michael Telatynski <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -15,6 +16,7 @@ limitations under the License.
*/

import React from 'react';
import PropTypes from 'prop-types';
import MatrixClientPeg from '../../../MatrixClientPeg';
import {instanceForInstanceId} from '../../../utils/DirectoryUtils';

Expand Down Expand Up @@ -241,10 +243,10 @@ export default class NetworkDropdown extends React.Component {
}

NetworkDropdown.propTypes = {
onOptionChange: React.PropTypes.func.isRequired,
protocols: React.PropTypes.object,
onOptionChange: PropTypes.func.isRequired,
protocols: PropTypes.object,
// 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 = {
Expand Down
3 changes: 2 additions & 1 deletion src/components/views/elements/Dropdown.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
Copyright 2017 Vector Creations Ltd
Copyright 2019 Michael Telatynski <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -58,7 +59,7 @@ class MenuOption extends React.Component {

MenuOption.propTypes = {
children: PropTypes.oneOfType([
PropTypes.arrayOf(React.PropTypes.node),
PropTypes.arrayOf(PropTypes.node),
PropTypes.node,
]),
highlighted: PropTypes.bool,
Expand Down
19 changes: 10 additions & 9 deletions src/components/views/elements/ImageView.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ limitations under the License.

'use strict';

const React = require('react');
import React from 'react';
import PropTypes from 'prop-types';

const MatrixClientPeg = require('../../../MatrixClientPeg');

Expand All @@ -30,19 +31,19 @@ import { _t } from '../../../languageHandler';

export default class ImageView extends React.Component {
static propTypes = {
src: React.PropTypes.string.isRequired, // the source of the image being displayed
name: React.PropTypes.string, // the main title ('name') for the image
link: React.PropTypes.string, // the link (if any) applied to the name of the image
width: React.PropTypes.number, // width of the image src in pixels
height: React.PropTypes.number, // height of the image src in pixels
fileSize: React.PropTypes.number, // size of the image src in bytes
onFinished: React.PropTypes.func.isRequired, // callback when the lightbox is dismissed
src: PropTypes.string.isRequired, // the source of the image being displayed
name: PropTypes.string, // the main title ('name') for the image
link: PropTypes.string, // the link (if any) applied to the name of the image
width: PropTypes.number, // width of the image src in pixels
height: PropTypes.number, // height of the image src in pixels
fileSize: PropTypes.number, // size of the image src in bytes
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
// 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
// with events.
mxEvent: React.PropTypes.object,
mxEvent: PropTypes.object,
};

constructor(props) {
Expand Down
10 changes: 6 additions & 4 deletions src/components/views/elements/Tooltip.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
Copyright 2015, 2016 OpenMarket Ltd
Copyright 2019 New Vector Ltd
Copyright 2019 Michael Telatynski <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -18,6 +19,7 @@ limitations under the License.

import React from 'react';
import ReactDOM from 'react-dom';
import PropTypes from 'prop-types';
import dis from '../../../dispatcher';
import classNames from 'classnames';

Expand All @@ -28,15 +30,15 @@ module.exports = React.createClass({

propTypes: {
// Class applied to the element used to position the tooltip
className: React.PropTypes.string,
className: PropTypes.string,
// Class applied to the tooltip itself
tooltipClassName: React.PropTypes.string,
tooltipClassName: PropTypes.string,
// Whether the tooltip is visible or hidden.
// The hidden state allows animating the tooltip away via CSS.
// Defaults to visible if unset.
visible: React.PropTypes.bool,
visible: PropTypes.bool,
// the react element to put into the tooltip
label: React.PropTypes.node,
label: PropTypes.node,
},

getDefaultProps() {
Expand Down
2 changes: 1 addition & 1 deletion src/components/views/elements/UserSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module.exports = React.createClass({

propTypes: {
onChange: PropTypes.func,
selected_users: PropTypes.arrayOf(React.PropTypes.string),
selected_users: PropTypes.arrayOf(PropTypes.string),
},

getDefaultProps: function() {
Expand Down
10 changes: 5 additions & 5 deletions src/components/views/globals/NewVersionBar.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
Copyright 2015, 2016 OpenMarket Ltd
Copyright 2019 Michael Telatynski <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -14,9 +15,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

'use strict';

import React from 'react';
import PropTypes from 'prop-types';
import sdk from '../../../index';
import Modal from '../../../Modal';
import PlatformPeg from '../../../PlatformPeg';
Expand All @@ -33,9 +33,9 @@ function checkVersion(ver) {

export default React.createClass({
propTypes: {
version: React.PropTypes.string.isRequired,
newVersion: React.PropTypes.string.isRequired,
releaseNotes: React.PropTypes.string,
version: PropTypes.string.isRequired,
newVersion: PropTypes.string.isRequired,
releaseNotes: PropTypes.string,
},

displayReleaseNotes: function(releaseNotes) {
Expand Down
9 changes: 4 additions & 5 deletions src/components/views/globals/UpdateCheckBar.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2017 Michael Telatynski <[email protected]>
Copyright 2017, 2019 Michael Telatynski <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -14,19 +14,18 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

'use strict';

import React from 'react';
import PropTypes from 'prop-types';
import { _t } from '../../../languageHandler';
import PlatformPeg from '../../../PlatformPeg';
import AccessibleButton from '../../../components/views/elements/AccessibleButton';

export default React.createClass({
propTypes: {
status: React.PropTypes.string.isRequired,
status: PropTypes.string.isRequired,
// Currently for error detail but will be usable for download progress
// once that is a thing that squirrel passes through electron.
detail: React.PropTypes.string,
detail: PropTypes.string,
},

getDefaultProps: function() {
Expand Down
3 changes: 2 additions & 1 deletion src/components/views/rooms/EventTile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Copyright 2015, 2016 OpenMarket Ltd
Copyright 2017 New Vector Ltd
Copyright 2019 The Matrix.org Foundation C.I.C.
Copyright 2019 Michael Telatynski <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -131,7 +132,7 @@ module.exports = withMatrixClient(React.createClass({
onHeightChanged: PropTypes.func,

/* 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
* to manage its animations. Should be an empty object when the room
Expand Down
Loading

0 comments on commit 4694a9b

Please sign in to comment.