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

Avoid errors if onAdd and onRemove Dropdown functions are not defined #4747

Merged
merged 2 commits into from
Jun 16, 2021
Merged
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
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
2 changes: 1 addition & 1 deletion frontend/src/components/taskSelection/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ export default defineMessages({
},
sortByMostRecentlyUpdate: {
id: 'project.tasks.sorting.date',
defaultMessage: 'Mostly recently updated',
defaultMessage: 'Most recently updated',
},
sortByLeastRecentlyUpdate: {
id: 'project.tasks.sorting.date.reverse',
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: 1 addition & 1 deletion frontend/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@
"project.tasks.status.badImagery": "Unavailable",
"project.tasks.status.split": "Split",
"project.tasks.sorting.id": "Sort by task number",
"project.tasks.sorting.date": "Mostly recently updated",
"project.tasks.sorting.date": "Most recently updated",
"project.tasks.sorting.date.reverse": "Least recently updated",
"project.tasks.filter.all": "All",
"project.tasks.filter.readyToValidate": "Ready for validation",
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