Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions src/demos/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,9 @@
};

CurrentRecord.propTypes = {
record: PropTypes.object,

Check warning on line 27 in src/demos/App.js

View workflow job for this annotation

GitHub Actions / Tests (16.x)

propType "record" is not required, but has no corresponding defaultProps declaration

Check warning on line 27 in src/demos/App.js

View workflow job for this annotation

GitHub Actions / Tests (18.x)

propType "record" is not required, but has no corresponding defaultProps declaration
};

CurrentRecord.defaultProps = {
record: undefined,
};

class RecordPreviewer extends Component {
render() {
const { record } = this.props;
Expand All @@ -39,13 +35,9 @@
}

RecordPreviewer.propTypes = {
record: PropTypes.object,

Check warning on line 38 in src/demos/App.js

View workflow job for this annotation

GitHub Actions / Tests (16.x)

propType "record" is not required, but has no corresponding defaultProps declaration

Check warning on line 38 in src/demos/App.js

View workflow job for this annotation

GitHub Actions / Tests (18.x)

propType "record" is not required, but has no corresponding defaultProps declaration
};

RecordPreviewer.defaultProps = {
record: undefined,
};

class App extends Component {
constructor(props) {
super(props);
Expand Down
8 changes: 0 additions & 8 deletions src/lib/elements/ErrorMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
/**
* The list of errors (In case of multiple errors. ex: form validation result).
*/
errors: PropTypes.arrayOf(

Check warning on line 72 in src/lib/elements/ErrorMessage.js

View workflow job for this annotation

GitHub Actions / Tests (16.x)

propType "errors" is not required, but has no corresponding defaultProps declaration

Check warning on line 72 in src/lib/elements/ErrorMessage.js

View workflow job for this annotation

GitHub Actions / Tests (18.x)

propType "errors" is not required, but has no corresponding defaultProps declaration
PropTypes.shape({
field: PropTypes.string,
messages: PropTypes.arrayOf(PropTypes.string.isRequired).isRequired,
Expand All @@ -78,19 +78,11 @@
/**
* Custom error header.
*/
header: PropTypes.string,

Check warning on line 81 in src/lib/elements/ErrorMessage.js

View workflow job for this annotation

GitHub Actions / Tests (16.x)

propType "header" is not required, but has no corresponding defaultProps declaration

Check warning on line 81 in src/lib/elements/ErrorMessage.js

View workflow job for this annotation

GitHub Actions / Tests (18.x)

propType "header" is not required, but has no corresponding defaultProps declaration
uiProps: PropTypes.object,

Check warning on line 82 in src/lib/elements/ErrorMessage.js

View workflow job for this annotation

GitHub Actions / Tests (16.x)

propType "uiProps" is not required, but has no corresponding defaultProps declaration

Check warning on line 82 in src/lib/elements/ErrorMessage.js

View workflow job for this annotation

GitHub Actions / Tests (18.x)

propType "uiProps" is not required, but has no corresponding defaultProps declaration
/**
* Single error message (ex: http error response message).
*/
content: PropTypes.string,

Check warning on line 86 in src/lib/elements/ErrorMessage.js

View workflow job for this annotation

GitHub Actions / Tests (16.x)

propType "content" is not required, but has no corresponding defaultProps declaration

Check warning on line 86 in src/lib/elements/ErrorMessage.js

View workflow job for this annotation

GitHub Actions / Tests (18.x)

propType "content" is not required, but has no corresponding defaultProps declaration
icon: PropTypes.string,

Check warning on line 87 in src/lib/elements/ErrorMessage.js

View workflow job for this annotation

GitHub Actions / Tests (16.x)

propType "icon" is not required, but has no corresponding defaultProps declaration

Check warning on line 87 in src/lib/elements/ErrorMessage.js

View workflow job for this annotation

GitHub Actions / Tests (18.x)

propType "icon" is not required, but has no corresponding defaultProps declaration
};

ErrorMessage.defaultProps = {
errors: undefined,
header: undefined,
uiProps: undefined,
icon: undefined,
content: undefined,
};
10 changes: 0 additions & 10 deletions src/lib/elements/GridResponsiveSidebarColumn.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,24 +68,14 @@
}

GridResponsiveSidebarColumn.propTypes = {
width: PropTypes.number,

Check warning on line 71 in src/lib/elements/GridResponsiveSidebarColumn.js

View workflow job for this annotation

GitHub Actions / Tests (16.x)

propType "width" is not required, but has no corresponding defaultProps declaration

Check warning on line 71 in src/lib/elements/GridResponsiveSidebarColumn.js

View workflow job for this annotation

GitHub Actions / Tests (18.x)

propType "width" is not required, but has no corresponding defaultProps declaration
open: PropTypes.bool.isRequired,
onHideClick: PropTypes.func.isRequired,
children: PropTypes.any.isRequired,
mobile: PropTypes.number,

Check warning on line 75 in src/lib/elements/GridResponsiveSidebarColumn.js

View workflow job for this annotation

GitHub Actions / Tests (16.x)

propType "mobile" is not required, but has no corresponding defaultProps declaration

Check warning on line 75 in src/lib/elements/GridResponsiveSidebarColumn.js

View workflow job for this annotation

GitHub Actions / Tests (18.x)

propType "mobile" is not required, but has no corresponding defaultProps declaration
tablet: PropTypes.number,

Check warning on line 76 in src/lib/elements/GridResponsiveSidebarColumn.js

View workflow job for this annotation

GitHub Actions / Tests (16.x)

propType "tablet" is not required, but has no corresponding defaultProps declaration

Check warning on line 76 in src/lib/elements/GridResponsiveSidebarColumn.js

View workflow job for this annotation

GitHub Actions / Tests (18.x)

propType "tablet" is not required, but has no corresponding defaultProps declaration
computer: PropTypes.number,
largeScreen: PropTypes.number,
widescreen: PropTypes.number,
ariaLabel: PropTypes.string,
};

GridResponsiveSidebarColumn.defaultProps = {
width: undefined,
mobile: undefined,
tablet: undefined,
computer: undefined,
widescreen: undefined,
largeScreen: undefined,
ariaLabel: undefined,
};
23 changes: 13 additions & 10 deletions src/lib/elements/Image.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ import axios from "axios";
*/
export class Image extends Component {
async componentDidMount() {
const { fallbackSrc, loadFallbackFirst, src } = this.props;
const {
fallbackSrc = "/static/images/square-placeholder.png",
loadFallbackFirst = false,
src,
} = this.props;
if (loadFallbackFirst) {
try {
await axios.get(src);
Expand Down Expand Up @@ -51,8 +55,14 @@ export class Image extends Component {
};

render() {
const { alt, className, src, fallbackSrc, loadFallbackFirst, ...UIprops } =
this.props;
const {
alt = "No image found",
className = "",
src,
fallbackSrc = "/static/images/square-placeholder.png",
loadFallbackFirst = false,
...UIprops
} = this.props;
const loadingClass = !loadFallbackFirst
? `${className} placeholder`
: `${className} fallback_image`;
Expand Down Expand Up @@ -89,10 +99,3 @@ Image.propTypes = {
alt: PropTypes.string,
loadFallbackFirst: PropTypes.bool,
};

Image.defaultProps = {
className: "",
alt: "No image found",
fallbackSrc: "/static/images/square-placeholder.png",
loadFallbackFirst: false,
};
15 changes: 4 additions & 11 deletions src/lib/elements/accessibility/InvenioPopup.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ export class InvenioPopup extends Component {
render() {
const {
popupId,
size,
size = "small",
trigger,
content,
position,
inverted,
position = "top left",
inverted = false,
ariaLabel,
hoverable,
hoverable = true,
} = this.props;

return (
Expand Down Expand Up @@ -54,10 +54,3 @@ InvenioPopup.propTypes = {
position: PropTypes.string,
size: PropTypes.string,
};

InvenioPopup.defaultProps = {
inverted: false,
position: "top left",
size: "small",
hoverable: true,
};
6 changes: 1 addition & 5 deletions src/lib/elements/bulk_actions/SearchResultsBulkActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import _pickBy from "lodash/pickBy";
export default class SearchResultsBulkActions extends Component {
constructor(props) {
super(props);
const { allSelected } = this.props;
const { allSelected = false } = this.props;
this.state = { allSelectedChecked: allSelected };
}

Expand Down Expand Up @@ -86,7 +86,3 @@ SearchResultsBulkActions.propTypes = {
allSelected: PropTypes.bool,
optionSelectionCallback: PropTypes.func.isRequired,
};

SearchResultsBulkActions.defaultProps = {
allSelected: false,
};
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,3 @@ UserListItemCompact.propTypes = {
id: PropTypes.string.isRequired,
linkToDetailView: PropTypes.string,
};

UserListItemCompact.defaultProps = {
linkToDetailView: undefined,
};
27 changes: 9 additions & 18 deletions src/lib/forms/AccordionField.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class AccordionError extends Component {

render() {
const { errors } = this.state;
const { severityChecks } = this.props;
const { severityChecks = null } = this.props;
if (errors === undefined) {
return null;
}
Expand All @@ -133,14 +133,10 @@ AccordionError.propTypes = {
severityChecks: PropTypes.object,
};

AccordionError.defaultProps = {
severityChecks: null,
};

export class AccordionField extends Component {
constructor(props) {
super(props);
const { active } = this.props;
const { active = true } = this.props;
this.state = { hasError: false, activeIndex: active ? 0 : -1 };
}

Expand All @@ -155,7 +151,12 @@ export class AccordionField extends Component {
};

renderAccordion = (props) => {
const { label, children, includesPaths, severityChecks } = this.props;
const {
label = "",
children = null,
includesPaths = [],
severityChecks = null,
} = this.props;
const { hasError, activeIndex } = this.state;
// Omit props, so they don't get spread into Accordion https://react.semantic-ui.com/modules/accordion/#types-standard
const uiProps = _omit(this.props, [
Expand Down Expand Up @@ -207,7 +208,7 @@ export class AccordionField extends Component {
};

render() {
const { optimized } = this.props;
const { optimized = false } = this.props;
const FormikField = optimized ? FastField : Field;
return <FormikField name="" component={this.renderAccordion} />;
}
Expand All @@ -222,13 +223,3 @@ AccordionField.propTypes = {
ui: PropTypes.object,
severityChecks: PropTypes.object,
};

AccordionField.defaultProps = {
active: true,
includesPaths: [],
label: "",
optimized: false,
children: null,
ui: null,
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zzacharo @kpsherva this ui prop bugs me: it is not used anywhere in the AccordionField, passed straight to Accordion SUI component on line 180. Accordion however doesn't accept ui prop. I guess the intention was to spread the ui props to Accordion like:

const {
      label = "",
      children = null,
      optimized = false,
      includesPaths = [],
      severityChecks = null,
      ...uiProps
    } = this.props;

? This is the common pattern in other components...What do you think? Did I overlook something?

severityChecks: null,
};
24 changes: 7 additions & 17 deletions src/lib/forms/ArrayField.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,16 @@ export class ArrayField extends Component {
...arrayHelpers
} = props;
const {
addButtonLabel,
addButtonClassName,
addButtonLabel = "Add new row",
addButtonClassName = "align-self-end mt-15",
children,
defaultNewValue,
fieldPath,
label,
labelIcon,
helpText,
requiredOptions,
showEmptyValue,
label = "",
labelIcon = "",
helpText = "",
requiredOptions = [],
showEmptyValue = false,
...uiProps
} = this.props;
const hasError = this.hasGroupErrors(errors) ? { error: {} } : {};
Expand Down Expand Up @@ -160,13 +160,3 @@ ArrayField.propTypes = {
requiredOptions: PropTypes.array,
showEmptyValue: PropTypes.bool,
};

ArrayField.defaultProps = {
addButtonLabel: "Add new row",
addButtonClassName: "align-self-end mt-15",
helpText: "",
label: "",
labelIcon: "",
requiredOptions: [],
showEmptyValue: false,
};
4 changes: 0 additions & 4 deletions src/lib/forms/BaseForm/BaseForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,3 @@ BaseForm.propTypes = {
validate: PropTypes.func,
}),
};

BaseForm.defaultProps = {
formik: undefined,
};
9 changes: 2 additions & 7 deletions src/lib/forms/BooleanField.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class BooleanField extends Component {
}

renderFormField = (props) => {
const { fieldPath, label, ...uiProps } = this.props;
const { fieldPath, label = "", ...uiProps } = this.props;
const {
form: { values, handleBlur, errors, initialErrors, initialValues, setFieldValue },
} = props;
Expand All @@ -47,7 +47,7 @@ export class BooleanField extends Component {
);
};
render() {
const { optimized, fieldPath } = this.props;
const { optimized = false, fieldPath } = this.props;
const FormikField = optimized ? FastField : Field;
return (
<FormikField
Expand All @@ -64,8 +64,3 @@ BooleanField.propTypes = {
label: PropTypes.string,
optimized: PropTypes.bool,
};

BooleanField.defaultProps = {
label: "",
optimized: false,
};
11 changes: 2 additions & 9 deletions src/lib/forms/FeedbackLabel.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class FeedbackLabel extends Component {
};

computeErrors = (errors, initialErrors) => {
const { fieldPath, injectedError, hasSubfields } = this.props;
const { fieldPath, injectedError, hasSubfields = false } = this.props;
let error;

if (injectedError) {
Expand Down Expand Up @@ -64,7 +64,7 @@ export class FeedbackLabel extends Component {
};

renderErrors = ({ form: { errors, initialErrors } }) => {
const { fieldPath, pointing } = this.props;
const { fieldPath, pointing = "left" } = this.props;
const { error, errMessage, hasSeverity } = this.computeErrors(
errors,
initialErrors
Expand Down Expand Up @@ -111,10 +111,3 @@ FeedbackLabel.propTypes = {
fieldPath: PropTypes.string,
hasSubfields: PropTypes.bool,
};

FeedbackLabel.defaultProps = {
injectedError: undefined,
pointing: "left",
fieldPath: undefined,
hasSubfields: false,
};
14 changes: 6 additions & 8 deletions src/lib/forms/FieldLabel.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ import { Icon } from "semantic-ui-react";

export class FieldLabel extends Component {
render() {
const { htmlFor, icon, label, className } = this.props;
const {
htmlFor,
icon = "",
label,
className = "field-label-class invenio-field-label",
} = this.props;
return (
<label htmlFor={htmlFor} className={className}>
{icon ? <Icon name={icon} /> : null}
Expand All @@ -28,10 +33,3 @@ FieldLabel.propTypes = {
icon: PropTypes.string,
className: PropTypes.string,
};

FieldLabel.defaultProps = {
className: "field-label-class invenio-field-label",
icon: "",
htmlFor: undefined,
label: undefined,
};
5 changes: 0 additions & 5 deletions src/lib/forms/FilesList.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,3 @@ FilesList.propTypes = {
files: PropTypes.array,
onFileDelete: PropTypes.func,
};

FilesList.defaultProps = {
files: undefined,
onFileDelete: undefined,
};
20 changes: 9 additions & 11 deletions src/lib/forms/GroupField.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@ export class GroupField extends React.Component {
};

renderFormField = (props) => {
const { action, basic, border, children, fieldPath, ...uiProps } = props;
const {
action,
basic = false,
border = false,
children,
fieldPath = "",
...uiProps
} = props;
const errors = getIn(props, "form.errors");
const classNames = ["form-group"];
if (border) {
Expand All @@ -54,7 +61,7 @@ export class GroupField extends React.Component {
};

render() {
const { optimized, fieldPath, ...uiProps } = this.props;
const { optimized = false, fieldPath = "", ...uiProps } = this.props;

const FormikField = optimized ? FastField : Field;
return (
Expand All @@ -77,12 +84,3 @@ GroupField.propTypes = {
basic: PropTypes.bool,
children: PropTypes.any,
};

GroupField.defaultProps = {
border: false,
fieldPath: "",
optimized: false,
action: undefined,
basic: false,
children: undefined,
};
Loading
Loading