mirror of
https://github.com/Unleash/unleash.git
synced 2025-06-04 01:18:20 +02:00
Merge pull request #108 from Unleash/fix_lint_warns
chore(lint) Added propTypes to all components
This commit is contained in:
commit
5bed56a49c
@ -10,6 +10,7 @@ The latest version of this document is always available in
|
|||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
- Move metrics poller to seperate class
|
- Move metrics poller to seperate class
|
||||||
- Bugfix: CreatedAt set when creating new toggle
|
- Bugfix: CreatedAt set when creating new toggle
|
||||||
|
- chore(lint): Added propTypes to all components
|
||||||
|
|
||||||
## [3.0.0-alpha.6]
|
## [3.0.0-alpha.6]
|
||||||
- Bugfix: actions should always throw errors
|
- Bugfix: actions should always throw errors
|
||||||
|
@ -6,7 +6,9 @@ import renderer from 'react-test-renderer';
|
|||||||
jest.mock('react-mdl');
|
jest.mock('react-mdl');
|
||||||
|
|
||||||
test('renders correctly if no application', () => {
|
test('renders correctly if no application', () => {
|
||||||
const tree = renderer.create(<ClientApplications fetchApplication={jest.fn()} />).toJSON();
|
const tree = renderer
|
||||||
|
.create(<ClientApplications fetchApplication={jest.fn()} storeApplicationMetaData={jest.fn()} />)
|
||||||
|
.toJSON();
|
||||||
|
|
||||||
expect(tree).toMatchSnapshot();
|
expect(tree).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/* eslint react/no-multi-comp:off */
|
/* eslint react/no-multi-comp:off */
|
||||||
import React, { Component, PureComponent } from 'react';
|
import React, { Component, PureComponent } from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
import { Link } from 'react-router';
|
import { Link } from 'react-router';
|
||||||
import {
|
import {
|
||||||
@ -23,6 +24,13 @@ import { IconLink, shorten, styles as commonStyles } from '../common';
|
|||||||
import { formatFullDateTime } from '../common/util';
|
import { formatFullDateTime } from '../common/util';
|
||||||
|
|
||||||
class StatefulTextfield extends Component {
|
class StatefulTextfield extends Component {
|
||||||
|
static propTypes = {
|
||||||
|
value: PropTypes.string,
|
||||||
|
label: PropTypes.string,
|
||||||
|
rows: PropTypes.number,
|
||||||
|
onBlur: PropTypes.func.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = { value: props.value };
|
this.state = { value: props.value };
|
||||||
@ -47,6 +55,13 @@ class StatefulTextfield extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ClientApplications extends PureComponent {
|
class ClientApplications extends PureComponent {
|
||||||
|
static propTypes = {
|
||||||
|
fetchApplication: PropTypes.func.isRequired,
|
||||||
|
appName: PropTypes.string,
|
||||||
|
application: PropTypes.object,
|
||||||
|
storeApplicationMetaData: PropTypes.func.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = { activeTab: 0 };
|
this.state = { activeTab: 0 };
|
||||||
|
@ -1,8 +1,14 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
import { ProgressBar, Card } from 'react-mdl';
|
import { ProgressBar, Card } from 'react-mdl';
|
||||||
import { AppsLinkList, styles as commonStyles } from '../common';
|
import { AppsLinkList, styles as commonStyles } from '../common';
|
||||||
|
|
||||||
class ClientStrategies extends Component {
|
class ClientStrategies extends Component {
|
||||||
|
static propTypes = {
|
||||||
|
applications: PropTypes.array,
|
||||||
|
fetchAll: PropTypes.func.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.props.fetchAll();
|
this.props.fetchAll();
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,16 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
import { Link } from 'react-router';
|
import { Link } from 'react-router';
|
||||||
import { DataTable, TableHeader, IconButton, Icon, Card } from 'react-mdl';
|
import { DataTable, TableHeader, IconButton, Icon, Card } from 'react-mdl';
|
||||||
import { styles as commonStyles } from '../common';
|
import { styles as commonStyles } from '../common';
|
||||||
|
|
||||||
class ArchiveList extends Component {
|
class ArchiveList extends Component {
|
||||||
|
static propTypes = {
|
||||||
|
archive: PropTypes.array,
|
||||||
|
fetchArchive: PropTypes.func,
|
||||||
|
revive: PropTypes.func,
|
||||||
|
};
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.props.fetchArchive();
|
this.props.fetchArchive();
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
import { Link } from 'react-router';
|
import { Link } from 'react-router';
|
||||||
import { List, ListItem, ListItemContent, Button, Icon, Switch, MenuItem } from 'react-mdl';
|
import { List, ListItem, ListItemContent, Button, Icon, Switch, MenuItem } from 'react-mdl';
|
||||||
import styles from './common.scss';
|
import styles from './common.scss';
|
||||||
@ -25,6 +26,9 @@ export const AppsLinkList = ({ apps }) => (
|
|||||||
))}
|
))}
|
||||||
</List>
|
</List>
|
||||||
);
|
);
|
||||||
|
AppsLinkList.propTypes = {
|
||||||
|
apps: PropTypes.array.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
export const HeaderTitle = ({ title, actions, subtitle }) => (
|
export const HeaderTitle = ({ title, actions, subtitle }) => (
|
||||||
<div
|
<div
|
||||||
@ -43,6 +47,11 @@ export const HeaderTitle = ({ title, actions, subtitle }) => (
|
|||||||
{actions && <div style={{ flex: '1', textAlign: 'right' }}>{actions}</div>}
|
{actions && <div style={{ flex: '1', textAlign: 'right' }}>{actions}</div>}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
HeaderTitle.propTypes = {
|
||||||
|
title: PropTypes.string,
|
||||||
|
subtitle: PropTypes.string,
|
||||||
|
actions: PropTypes.any,
|
||||||
|
};
|
||||||
|
|
||||||
export const DataTableHeader = ({ title, actions }) => (
|
export const DataTableHeader = ({ title, actions }) => (
|
||||||
<div className={styles.dataTableHeader}>
|
<div className={styles.dataTableHeader}>
|
||||||
@ -52,6 +61,10 @@ export const DataTableHeader = ({ title, actions }) => (
|
|||||||
{actions && <div className={styles.actions}>{actions}</div>}
|
{actions && <div className={styles.actions}>{actions}</div>}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
DataTableHeader.propTypes = {
|
||||||
|
title: PropTypes.string,
|
||||||
|
actions: PropTypes.any,
|
||||||
|
};
|
||||||
|
|
||||||
export const FormButtons = ({ submitText = 'Create', onCancel }) => (
|
export const FormButtons = ({ submitText = 'Create', onCancel }) => (
|
||||||
<div>
|
<div>
|
||||||
@ -65,6 +78,10 @@ export const FormButtons = ({ submitText = 'Create', onCancel }) => (
|
|||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
FormButtons.propTypes = {
|
||||||
|
submitText: PropTypes.string,
|
||||||
|
onCancel: PropTypes.func.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
export const SwitchWithLabel = ({ onChange, checked, children, ...switchProps }) => (
|
export const SwitchWithLabel = ({ onChange, checked, children, ...switchProps }) => (
|
||||||
<span className={styles.switchWithLabel}>
|
<span className={styles.switchWithLabel}>
|
||||||
@ -74,6 +91,10 @@ export const SwitchWithLabel = ({ onChange, checked, children, ...switchProps })
|
|||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
|
SwitchWithLabel.propTypes = {
|
||||||
|
checked: PropTypes.bool,
|
||||||
|
onChange: PropTypes.func,
|
||||||
|
};
|
||||||
|
|
||||||
export const TogglesLinkList = ({ toggles }) => (
|
export const TogglesLinkList = ({ toggles }) => (
|
||||||
<List style={{ textAlign: 'left' }} className={styles.truncate}>
|
<List style={{ textAlign: 'left' }} className={styles.truncate}>
|
||||||
@ -89,6 +110,9 @@ export const TogglesLinkList = ({ toggles }) => (
|
|||||||
))}
|
))}
|
||||||
</List>
|
</List>
|
||||||
);
|
);
|
||||||
|
TogglesLinkList.propTypes = {
|
||||||
|
toggles: PropTypes.array,
|
||||||
|
};
|
||||||
|
|
||||||
export function getIcon(type) {
|
export function getIcon(type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@ -110,6 +134,10 @@ export const IconLink = ({ url, icon }) => (
|
|||||||
<Icon name={icon} />
|
<Icon name={icon} />
|
||||||
</a>
|
</a>
|
||||||
);
|
);
|
||||||
|
IconLink.propTypes = {
|
||||||
|
url: PropTypes.string,
|
||||||
|
icon: PropTypes.string,
|
||||||
|
};
|
||||||
|
|
||||||
export const DropdownButton = ({ label, id }) => (
|
export const DropdownButton = ({ label, id }) => (
|
||||||
<Button id={id} className={styles.dropdownButton}>
|
<Button id={id} className={styles.dropdownButton}>
|
||||||
@ -117,6 +145,10 @@ export const DropdownButton = ({ label, id }) => (
|
|||||||
<Icon name="arrow_drop_down" className="mdl-color-text--grey-600" />
|
<Icon name="arrow_drop_down" className="mdl-color-text--grey-600" />
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
|
DropdownButton.propTypes = {
|
||||||
|
label: PropTypes.string,
|
||||||
|
id: PropTypes.string,
|
||||||
|
};
|
||||||
|
|
||||||
export const MenuItemWithIcon = ({ icon, label, disabled, ...menuItemProps }) => (
|
export const MenuItemWithIcon = ({ icon, label, disabled, ...menuItemProps }) => (
|
||||||
<MenuItem disabled={disabled} style={{ display: 'flex', alignItems: 'center' }} {...menuItemProps}>
|
<MenuItem disabled={disabled} style={{ display: 'flex', alignItems: 'center' }} {...menuItemProps}>
|
||||||
@ -124,6 +156,11 @@ export const MenuItemWithIcon = ({ icon, label, disabled, ...menuItemProps }) =>
|
|||||||
{label}
|
{label}
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
);
|
);
|
||||||
|
MenuItemWithIcon.propTypes = {
|
||||||
|
icon: PropTypes.string,
|
||||||
|
label: PropTypes.string,
|
||||||
|
disabled: PropTypes.bool,
|
||||||
|
};
|
||||||
|
|
||||||
const badNumbers = [NaN, Infinity, -Infinity];
|
const badNumbers = [NaN, Infinity, -Infinity];
|
||||||
export function calc(value, total, decimal) {
|
export function calc(value, total, decimal) {
|
||||||
|
@ -104,11 +104,14 @@ AddFeatureToggleComponent.propTypes = {
|
|||||||
setValue: PropTypes.func.isRequired,
|
setValue: PropTypes.func.isRequired,
|
||||||
addStrategy: PropTypes.func.isRequired,
|
addStrategy: PropTypes.func.isRequired,
|
||||||
removeStrategy: PropTypes.func.isRequired,
|
removeStrategy: PropTypes.func.isRequired,
|
||||||
|
moveStrategy: PropTypes.func.isRequired,
|
||||||
updateStrategy: PropTypes.func.isRequired,
|
updateStrategy: PropTypes.func.isRequired,
|
||||||
onSubmit: PropTypes.func.isRequired,
|
onSubmit: PropTypes.func.isRequired,
|
||||||
onCancel: PropTypes.func.isRequired,
|
onCancel: PropTypes.func.isRequired,
|
||||||
validateName: PropTypes.func.isRequired,
|
validateName: PropTypes.func.isRequired,
|
||||||
editmode: PropTypes.bool,
|
editmode: PropTypes.bool,
|
||||||
|
initCallRequired: PropTypes.bool,
|
||||||
|
init: PropTypes.func,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default AddFeatureToggleComponent;
|
export default AddFeatureToggleComponent;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
import { Slider } from 'react-mdl';
|
import { Slider } from 'react-mdl';
|
||||||
|
|
||||||
const labelStyle = {
|
const labelStyle = {
|
||||||
@ -8,7 +9,7 @@ const labelStyle = {
|
|||||||
fontSize: '12px',
|
fontSize: '12px',
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ({ name, value, onChange }) => (
|
const InputPercentage = ({ name, value, onChange }) => (
|
||||||
<div style={{ marginBottom: '20px' }}>
|
<div style={{ marginBottom: '20px' }}>
|
||||||
<div style={labelStyle}>
|
<div style={labelStyle}>
|
||||||
{name}: {value}%
|
{name}: {value}%
|
||||||
@ -16,3 +17,11 @@ export default ({ name, value, onChange }) => (
|
|||||||
<Slider min={0} max={100} defaultValue={value} value={value} onChange={onChange} label={name} />
|
<Slider min={0} max={100} defaultValue={value} value={value} onChange={onChange} label={name} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
InputPercentage.propTypes = {
|
||||||
|
name: PropTypes.string,
|
||||||
|
value: PropTypes.number,
|
||||||
|
onChange: PropTypes.func.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default InputPercentage;
|
||||||
|
@ -13,6 +13,7 @@ export default class FeatureListComponent extends React.PureComponent {
|
|||||||
featureMetrics: PropTypes.object.isRequired,
|
featureMetrics: PropTypes.object.isRequired,
|
||||||
fetchFeatureToggles: PropTypes.func.isRequired,
|
fetchFeatureToggles: PropTypes.func.isRequired,
|
||||||
updateSetting: PropTypes.func.isRequired,
|
updateSetting: PropTypes.func.isRequired,
|
||||||
|
toggleFeature: PropTypes.func.isRequired,
|
||||||
settings: PropTypes.object,
|
settings: PropTypes.object,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -17,6 +17,9 @@ const StrategyChipItem = ({ strategy }) => (
|
|||||||
</Link>
|
</Link>
|
||||||
</Chip>
|
</Chip>
|
||||||
);
|
);
|
||||||
|
StrategyChipItem.propTypes = {
|
||||||
|
strategy: PropTypes.object.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
// TODO what about "missing" strategies here?
|
// TODO what about "missing" strategies here?
|
||||||
const StrategiesList = ({ strategies }) => (
|
const StrategiesList = ({ strategies }) => (
|
||||||
@ -25,6 +28,9 @@ const StrategiesList = ({ strategies }) => (
|
|||||||
{strategies.map((strategy, i) => <StrategyChipItem key={i} strategy={strategy} />)}
|
{strategies.map((strategy, i) => <StrategyChipItem key={i} strategy={strategy} />)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
StrategiesList.propTypes = {
|
||||||
|
strategies: PropTypes.array.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
export default class MetricComponent extends React.Component {
|
export default class MetricComponent extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
|
@ -1,9 +1,15 @@
|
|||||||
import React, { PureComponent } from 'react';
|
import React, { PureComponent } from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
import { Card } from 'react-mdl';
|
import { Card } from 'react-mdl';
|
||||||
import HistoryList from './history-list-container';
|
import HistoryList from './history-list-container';
|
||||||
import { styles as commonStyles } from '../common';
|
import { styles as commonStyles } from '../common';
|
||||||
|
|
||||||
class History extends PureComponent {
|
class History extends PureComponent {
|
||||||
|
static propTypes = {
|
||||||
|
fetchHistory: PropTypes.func.isRequired,
|
||||||
|
history: PropTypes.array.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.props.fetchHistory();
|
this.props.fetchHistory();
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
import HistoryItemDiff from './history-item-diff';
|
import HistoryItemDiff from './history-item-diff';
|
||||||
import HistoryItemJson from './history-item-json';
|
import HistoryItemJson from './history-item-json';
|
||||||
import { Table, TableHeader } from 'react-mdl';
|
import { Table, TableHeader } from 'react-mdl';
|
||||||
@ -8,6 +9,13 @@ import { formatFullDateTime } from '../common/util';
|
|||||||
import styles from './history.scss';
|
import styles from './history.scss';
|
||||||
|
|
||||||
class HistoryList extends Component {
|
class HistoryList extends Component {
|
||||||
|
static propTypes = {
|
||||||
|
title: PropTypes.string,
|
||||||
|
history: PropTypes.array,
|
||||||
|
settings: PropTypes.object,
|
||||||
|
updateSetting: PropTypes.func.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
toggleShowDiff() {
|
toggleShowDiff() {
|
||||||
this.props.updateSetting('showData', !this.props.settings.showData);
|
this.props.updateSetting('showData', !this.props.settings.showData);
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,8 @@ import HistoryList from './history-list-container';
|
|||||||
class HistoryListToggle extends Component {
|
class HistoryListToggle extends Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
toggleName: PropTypes.string.isRequired,
|
toggleName: PropTypes.string.isRequired,
|
||||||
|
history: PropTypes.array,
|
||||||
|
fetchHistoryForToggle: PropTypes.func.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
@ -66,6 +66,11 @@ const Parameter = ({ set, input = {}, index }) => (
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
Parameter.propTypes = {
|
||||||
|
input: PropTypes.object,
|
||||||
|
set: PropTypes.func,
|
||||||
|
index: PropTypes.number,
|
||||||
|
};
|
||||||
|
|
||||||
const EditHeader = () => (
|
const EditHeader = () => (
|
||||||
<div>
|
<div>
|
||||||
@ -90,6 +95,12 @@ const Parameters = ({ input = [], count = 0, updateInList }) => (
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Parameters.propTypes = {
|
||||||
|
input: PropTypes.array,
|
||||||
|
updateInList: PropTypes.func.isRequired,
|
||||||
|
count: PropTypes.number,
|
||||||
|
};
|
||||||
|
|
||||||
class AddStrategy extends Component {
|
class AddStrategy extends Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
input: PropTypes.object,
|
input: PropTypes.object,
|
||||||
|
@ -6,6 +6,12 @@ import { List, ListItem, ListItemContent, IconButton, Grid, Cell } from 'react-m
|
|||||||
import { HeaderTitle } from '../common';
|
import { HeaderTitle } from '../common';
|
||||||
|
|
||||||
class StrategiesListComponent extends Component {
|
class StrategiesListComponent extends Component {
|
||||||
|
static propTypes = {
|
||||||
|
strategies: PropTypes.array.isRequired,
|
||||||
|
fetchStrategies: PropTypes.func.isRequired,
|
||||||
|
removeStrategy: PropTypes.func.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
static contextTypes = {
|
static contextTypes = {
|
||||||
router: PropTypes.object,
|
router: PropTypes.object,
|
||||||
};
|
};
|
||||||
|
@ -5,6 +5,7 @@ import styles from './user.scss';
|
|||||||
export default class ShowUserComponent extends React.Component {
|
export default class ShowUserComponent extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
profile: PropTypes.object,
|
profile: PropTypes.object,
|
||||||
|
fetchUser: PropTypes.func.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
Loading…
Reference in New Issue
Block a user