Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phase out transitional CustomInput component #783

Merged
merged 19 commits into from
Feb 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
8808c2b
refactor(client): replace CustomInput in profile.js
LordSputnik Feb 18, 2022
24ad782
refactor(client): replace CustomInput in revision.js
LordSputnik Feb 18, 2022
22342fe
refactor(client): replace CustomInput in search-field.js
LordSputnik Feb 18, 2022
74829aa
refactor(client): replace CustomInput in drag-and-drop.js
LordSputnik Feb 18, 2022
c2eb29f
refactor(client): replace CustomInput in deletion.js
LordSputnik Feb 18, 2022
b07b826
refactor(client): replace CustomInput in registration-details.js
LordSputnik Feb 18, 2022
d52846b
refactor(client): replace CustomInput in userCollection.js
LordSputnik Feb 19, 2022
505c70e
refactor(client): replace CustomInput in add-to-collection-modal.js
LordSputnik Feb 19, 2022
985939b
refactor(client): replace CustomInput in entity editor alias editor
LordSputnik Feb 20, 2022
39e0a16
refactor(client): replace CustomInput in new-date-field.js
LordSputnik Feb 20, 2022
d94b3c1
refactor(client): replace CustomInput in numeric-field.tsx
LordSputnik Feb 20, 2022
dac56fe
refactor(client): replace CustomInput in identifier editor
LordSputnik Feb 20, 2022
6b87ba9
refactor(client): replace CustomInput in annotation-section.js
LordSputnik Feb 20, 2022
065721f
refactor(client): replace CustomInput in entity-search-field-option.js
LordSputnik Feb 20, 2022
5992204
refactor(client): replace CustomInput in disambiguation-field.js
LordSputnik Feb 20, 2022
d2a6a4d
refactor(client): replace CustomInput in submission-section.js
LordSputnik Feb 20, 2022
a3ffc9b
refactor(client): replace CustomInput in entity-specific entity edito…
LordSputnik Feb 20, 2022
cccabb3
refactor(client): replace CustomInput in entity merge form
LordSputnik Feb 20, 2022
58c6ec4
refactor(client): remove now-unused CustomInput component
LordSputnik Feb 20, 2022
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
44 changes: 31 additions & 13 deletions src/client/components/forms/deletion.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
*/

import * as bootstrap from 'react-bootstrap';
import {faExclamationTriangle, faTimesCircle, faTrashAlt} from '@fortawesome/free-solid-svg-icons';
import CustomInput from '../../input';
import {faExclamationTriangle, faQuestionCircle, faTimesCircle, faTrashAlt} from '@fortawesome/free-solid-svg-icons';
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
import LoadingSpinner from '../loading-spinner';
import PropTypes from 'prop-types';
Expand All @@ -28,7 +27,7 @@ import {kebabCase as _kebabCase} from 'lodash';
import request from 'superagent';


const {Alert, Button, Col, Row, Card} = bootstrap;
const {Alert, Button, Col, Form, Row, OverlayTrigger, Tooltip, Card} = bootstrap;

class EntityDeletionForm extends React.Component {
constructor(props) {
Expand Down Expand Up @@ -124,6 +123,12 @@ class EntityDeletionForm extends React.Component {
</ValidationLabel>
);

const deletionTooltip = (
<Tooltip>
Please explain why you are deleting this entity. This is required.
</Tooltip>
);

return (
<div id="deletion-form">
<h1>Delete Entity</h1>
Expand Down Expand Up @@ -174,16 +179,29 @@ class EntityDeletionForm extends React.Component {
&nbsp;to select it to be merged instead.
</p>
<hr/>
<CustomInput
help="* A note is required"
label={noteLabel}
rows="5"
tooltipText="Please explain why you are deleting this entity. This is required."
type="textarea"
value={note}
wrapperClassName="margin-top-1"
onChange={this.handleNoteChange}
/>
<Form.Group>
<Form.Label>
{noteLabel}
<OverlayTrigger
delay={50}
overlay={deletionTooltip}
>
<FontAwesomeIcon
className="margin-left-0-5"
icon={faQuestionCircle}
/>
</OverlayTrigger>
</Form.Label>
<div className="margin-top-1">
<Form.Control
as="textarea"
rows="5"
value={note}
onChange={this.handleNoteChange}
/>
<Form.Text muted>* A note is required</Form.Text>
</div>
</Form.Group>
{errorComponent}
</Card.Body>
<Card.Footer>
Expand Down
37 changes: 20 additions & 17 deletions src/client/components/forms/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import * as bootstrap from 'react-bootstrap';
import * as utilsHelper from '../../helpers/utils';
import * as validators from '../../helpers/react-validators';
import CustomInput from '../../input';
import LoadingSpinner from '../loading-spinner';
import PropTypes from 'prop-types';
import React from 'react';
Expand All @@ -30,7 +29,7 @@ import SelectWrapper from '../input/select-wrapper';
import ValidationLabel from '../../entity-editor/common/validation-label';


const {Alert, Button, Col, Card, Row} = bootstrap;
const {Alert, Button, Col, Card, Form, Row} = bootstrap;
const {injectDefaultAliasName} = utilsHelper;

class ProfileForm extends React.Component {
Expand Down Expand Up @@ -162,21 +161,25 @@ class ProfileForm extends React.Component {
Edit your public profile
</Card.Header>
<Card.Body>
<CustomInput
defaultValue={name}
help="required"
label={nameLabel}
name="name"
type="text"
onChange={this.handleValueChange}
/>
<CustomInput
defaultValue={bio}
label="Bio"
name="bio"
type="textarea"
onChange={this.handleValueChange}
/>
<Form.Group>
<Form.Label>{nameLabel}</Form.Label>
<Form.Control
defaultValue={name}
name="name"
type="text"
onChange={this.handleValueChange}
/>
<Form.Text muted>required</Form.Text>
</Form.Group>
<Form.Group>
<Form.Label>Bio</Form.Label>
<Form.Control
as="textarea"
defaultValue={bio}
name="bio"
onChange={this.handleValueChange}
/>
</Form.Group>
{titleOptions.length > 0 &&
<SelectWrapper
base={ReactSelect}
Expand Down
34 changes: 18 additions & 16 deletions src/client/components/forms/registration-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import * as bootstrap from 'react-bootstrap';
import * as validators from '../../helpers/react-validators';
import CustomInput from '../../input';
import LoadingSpinner from '../loading-spinner';
import PropTypes from 'prop-types';
import React from 'react';
Expand All @@ -29,7 +28,7 @@ import SelectWrapper from '../input/select-wrapper';
import request from 'superagent';


const {Alert, Button, Col, Row} = bootstrap;
const {Alert, Button, Col, Form, Row} = bootstrap;

class RegistrationForm extends React.Component {
constructor(props) {
Expand All @@ -50,7 +49,7 @@ class RegistrationForm extends React.Component {

const gender = this.gender.getValue();
const data = {
displayName: this.displayName.getValue(),
displayName: this.displayName.value,
gender: gender ? parseInt(gender, 10) : null
};

Expand All @@ -74,7 +73,7 @@ class RegistrationForm extends React.Component {
}

isValid() {
return !this.displayName || this.displayName.getValue().length > 0;
return !this.displayName || this.displayName.value.length > 0;
}

handleChange() {
Expand Down Expand Up @@ -117,18 +116,21 @@ class RegistrationForm extends React.Component {
name is correct. This is the name that
other editors will get to know you by.
</p>
<CustomInput
className="form-control"
defaultValue={this.props.name}
groupClassName="row"
label="Display Name"
labelClassName="col-lg-4 col-form-label"
placeholder="Display Name"
ref={(ref) => this.displayName = ref}
type="text"
wrapperClassName="col-lg-4"
onChange={this.handleChange}
/>
<Form.Group className="row">
<Form.Label className="col-lg-4 col-form-label">
Display Name
</Form.Label>
<div className="col-lg-4">
<Form.Control
defaultValue={this.props.name}
placeholder="Display Name"
/* eslint-disable-next-line react/jsx-no-bind */
ref={(ref) => this.displayName = ref}
type="text"
onChange={this.handleChange}
/>
</div>
</Form.Group>
<p>
And, optionally, set a gender
that will be displayed on your profile
Expand Down
37 changes: 20 additions & 17 deletions src/client/components/forms/userCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import * as bootstrap from 'react-bootstrap';
import {faPlus, faSave, faTimes, faTrashAlt} from '@fortawesome/free-solid-svg-icons';
import {trim, uniqBy} from 'lodash';
import CustomInput from '../../input';
import DeleteOrRemoveCollaborationModal from '../pages/parts/delete-or-remove-collaboration-modal';
import EntitySearchFieldOption from '../../entity-editor/common/entity-search-field-option';
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
Expand All @@ -32,7 +31,7 @@ import classNames from 'classnames';
import request from 'superagent';


const {Alert, Button, Col, Row} = bootstrap;
const {Alert, Button, Col, Form, Row} = bootstrap;

class UserCollectionForm extends React.Component {
constructor(props) {
Expand Down Expand Up @@ -68,8 +67,8 @@ class UserCollectionForm extends React.Component {
}

const collaborators = this.getCleanedCollaborators();
const description = this.description.getValue();
const name = trim(this.name.getValue());
const description = this.description.value;
const name = trim(this.name.value);
const privacy = this.privacy.getValue();
const entityType = this.entityType.getValue();

Expand Down Expand Up @@ -100,7 +99,7 @@ class UserCollectionForm extends React.Component {
}

isValid() {
return trim(this.name.getValue()).length && this.entityType.getValue();
return trim(this.name.value).length && this.entityType.getValue();
}

getCleanedCollaborators() {
Expand Down Expand Up @@ -194,18 +193,22 @@ class UserCollectionForm extends React.Component {
className="padding-sides-0"
onSubmit={this.handleSubmit}
>
<CustomInput
defaultValue={initialName}
label="Name"
ref={(ref) => this.name = ref}
type="text"
/>
<CustomInput
defaultValue={initialDescription}
label="Description"
ref={(ref) => this.description = ref}
type="textarea"
/>
<Form.Group>
<Form.Label>Name</Form.Label>
<Form.Control
defaultValue={initialName}
ref={(ref) => this.name = ref}
type="text"
/>
</Form.Group>
<Form.Group>
<Form.Label>Description</Form.Label>
<Form.Control
as="textarea"
defaultValue={initialDescription}
ref={(ref) => this.description = ref}
/>
</Form.Group>
<SelectWrapper
base={ReactSelect}
defaultValue={initialType}
Expand Down
19 changes: 8 additions & 11 deletions src/client/components/input/drag-and-drop.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@
*/

import * as bootstrap from 'react-bootstrap';
import CustomInput from '../../input';
import PropTypes from 'prop-types';
import React from 'react';


const {Card} = bootstrap;
const {Card, Form} = bootstrap;

class DragAndDrop extends React.Component {
constructor() {
Expand Down Expand Up @@ -69,10 +68,6 @@ class DragAndDrop extends React.Component {
this.addChild(data);
}

getValue() {
return this.target.getValue();
}

render() {
return (
<Card
Expand All @@ -88,11 +83,13 @@ class DragAndDrop extends React.Component {
variant="top"
/>
<Card.Body className="text-center">
<CustomInput
name={this.props.name}
type="hidden"
value={this.state.achievement.id}
/>
<Form.Group>
<Form.Control
name={this.props.name}
type="hidden"
value={this.state.achievement.id}
/>
</Form.Group>
<div className="h3">
{this.state.achievement.name}
</div>
Expand Down
33 changes: 18 additions & 15 deletions src/client/components/pages/parts/add-to-collection-modal.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as bootstrap from 'react-bootstrap';
import {faPlus, faTimes} from '@fortawesome/free-solid-svg-icons';
import CustomInput from '../../../input';
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
import PropTypes from 'prop-types';
import React from 'react';
Expand All @@ -10,7 +9,7 @@ import _ from 'lodash';
import request from 'superagent';


const {Alert, Col, Button, Modal} = bootstrap;
const {Alert, Col, Button, Form, Modal} = bootstrap;

class AddToCollectionModal extends React.Component {
constructor(props) {
Expand Down Expand Up @@ -140,8 +139,8 @@ class AddToCollectionModal extends React.Component {
return;
}

const description = this.description.getValue();
const name = this.name.getValue();
const description = this.description.value;
const name = this.name.value;
const privacy = this.privacy.getValue();
const {entityType} = this.props;

Expand Down Expand Up @@ -175,7 +174,7 @@ class AddToCollectionModal extends React.Component {
}

isValid() {
return _.trim(this.name.getValue()).length && this.privacy.getValue();
return _.trim(this.name.value).length && this.privacy.getValue();
}

/* eslint-disable react/jsx-no-bind */
Expand Down Expand Up @@ -236,16 +235,20 @@ class AddToCollectionModal extends React.Component {
<form
className="padding-sides-0 addToCollectionModal-body"
>
<CustomInput
label="Name"
ref={(ref) => this.name = ref}
type="text"
/>
<CustomInput
label="Description"
ref={(ref) => this.description = ref}
type="textarea"
/>
<Form.Group>
<Form.Label>Name</Form.Label>
<Form.Control
ref={(ref) => this.name = ref}
type="text"
/>
</Form.Group>
<Form.Group>
<Form.Label>Description</Form.Label>
<Form.Control
as="textarea"
ref={(ref) => this.description = ref}
/>
</Form.Group>
<SelectWrapper
base={ReactSelect}
idAttribute="name"
Expand Down
Loading