Skip to content

Commit

Permalink
Avoid errors if onAdd and onRemove Dropdown functions are not defined
Browse files Browse the repository at this point in the history
  • Loading branch information
willemarcel authored and dakotabenjamin committed Jul 9, 2021
1 parent 3e74d78 commit a0d303a
Show file tree
Hide file tree
Showing 14 changed files with 3 additions and 34 deletions.
4 changes: 2 additions & 2 deletions frontend/src/components/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class DropdownContent extends React.PureComponent {
for (let x = 0; x < value.length; x++) {
if (value[x].label === label) {
isRemove = true;
this.props.onRemove(ourObj);
this.props.onRemove && this.props.onRemove(ourObj);
this.props.onChange(value.slice(0, x).concat(value.slice(x + 1)));
}
}
Expand All @@ -38,7 +38,7 @@ class DropdownContent extends React.PureComponent {
newArray = [];
}
newArray.push(ourObj);
this.props.onAdd(ourObj);
this.props.onAdd && this.props.onAdd(ourObj);
this.props.onChange(newArray);
}
}
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/components/header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,6 @@ class Header extends React.Component {
<>
<NotificationBell />
<Dropdown
onAdd={() => {}}
onRemove={() => {}}
onChange={this.onUserMenuSelect}
value={[]}
display={<UserDisplay username={this.props.userDetails.username} />}
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/components/localeSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ function LocaleSelect({ userPreferences, setLocale, className }) {
};
return (
<Dropdown
onAdd={() => {}}
onRemove={() => {}}
onChange={onLocaleSelect}
value={getActiveLanguageNames()}
options={supportedLocales}
Expand Down
4 changes: 1 addition & 3 deletions frontend/src/components/notifications/notificationOrderBy.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function NotificationOrderBySelector(props) {
sort: 'ASC',
},
];
const onSortSelect = arr => {
const onSortSelect = (arr) => {
if (arr.length === 1) {
props.setQuery(
{
Expand All @@ -54,8 +54,6 @@ export function NotificationOrderBySelector(props) {
};
return (
<Dropdown
onAdd={() => {}}
onRemove={() => {}}
onChange={onSortSelect}
value={`${props.allQueryParams.orderBy}.${props.allQueryParams.orderByType}` || []}
options={options}
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/components/projects/orderBy.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ export function OrderBySelector(props) {
};
return (
<Dropdown
onAdd={() => {}}
onRemove={() => {}}
onChange={onSortSelect}
value={`${props.allQueryParams.orderBy}.${props.allQueryParams.orderByType}` || []}
options={options}
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/components/projects/projectNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ export const ProjetListViewToggle = (props) => {
const DifficultyDropdown = (props) => {
return (
<Dropdown
onAdd={() => {}}
onRemove={() => {}}
onChange={(n) => {
const value = n && n[0] && n[0].value;
props.setQuery(
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/components/projects/projectsActionFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ export const ProjectsActionFilter = ({ setQuery, fullProjectsQuery }) => {

return (
<Dropdown
onAdd={() => {}}
onRemove={() => {}}
onChange={(n) => {
const value = n && n[0] && n[0].value;
// clean the action query param if it was set on the URL,
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/components/taskSelection/actionSidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -582,8 +582,6 @@ export function ReopenEditor({ project, action, editor, callEditor }: Object) {
display={<FormattedMessage {...messages.reloadEditor} />}
className="bg-white b--grey-light ba pa2 di"
onChange={callEditor}
onAdd={() => {}}
onRemove={() => {}}
toTop={true}
/>
</div>
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/components/taskSelection/footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,6 @@ const TaskSelectionFooter = ({ defaultUserEditor, project, tasks, taskAction, se
className="bg-white bn"
toTop={true}
onChange={updateEditor}
onAdd={() => {}}
onRemove={() => {}}
/>
</div>
<div className="w-30-ns w-60 fl tr">
Expand Down
5 changes: 0 additions & 5 deletions frontend/src/components/taskSelection/taskActivity.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,6 @@ export const TaskDataDropdown = ({ history, changesetComment, bbox }: Object) =>
if (history && history.taskHistory && history.taskHistory.length > 0) {
return (
<Dropdown
onAdd={() => {}}
onRemove={() => {}}
onChange={() => {}}
value={null}
options={[
{ label: <FormattedMessage {...messages.taskOnOSMCha} />, href: osmchaLink },
Expand Down Expand Up @@ -396,8 +393,6 @@ function EditorDropdown({ project, taskId, bbox }: Object) {
display={<FormattedMessage {...messages.openEditor} />}
className="bg-white b--grey-light ba pa2 dib v-mid"
onChange={loadTaskOnEditor}
onAdd={() => {}}
onRemove={() => {}}
/>
);
}
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/components/taskSelection/taskList.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,6 @@ export function TaskList({
</div>
<div className="w-60-l w-50-m w-100 dib pv1">
<Dropdown
onAdd={() => {}}
onRemove={() => {}}
onChange={updateSortingOption}
value={sortBy || 'date'}
options={sortingOptions}
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/components/user/forms/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ function _EditorDropdown(props) {

return (
<Dropdown
onAdd={() => {}}
onRemove={() => {}}
onChange={onEditorSelect}
value={value}
options={getEditors()}
Expand Down
4 changes: 0 additions & 4 deletions frontend/src/components/user/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ const RoleFilter = ({ filters, setFilters, updateFilters }) => {
return (
<div>
<Dropdown
onAdd={() => {}}
onRemove={() => {}}
onChange={(n) => {
const value = n && n[0] && n[0].value;
updateFilters('role', value);
Expand All @@ -96,8 +94,6 @@ const MapperLevelFilter = ({ filters, setFilters, updateFilters }) => {
return (
<div>
<Dropdown
onAdd={() => {}}
onRemove={() => {}}
onChange={(n) => {
const value = n && n[0] && n[0].value;
updateFilters('level', value);
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/views/projectEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,6 @@ export default function ProjectEdit({ id }) {
</div>
<span className="db">
<Dropdown
onAdd={() => {}}
onRemove={() => {}}
value={null}
options={[
{
Expand Down

0 comments on commit a0d303a

Please sign in to comment.