Skip to content

Commit 810cff0

Browse files
committed
AR-826: fix linting after node upgrade
1 parent ed8a6e4 commit 810cff0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+380
-363
lines changed

src/auth-handler.jsx

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { React, useContext } from "react";
2+
import PropTypes from "prop-types";
23
import Login from "./components/user/login";
34
import UserContext from "./context/user-context";
45

@@ -19,4 +20,8 @@ function AuthHandler({ children }) {
1920
return children;
2021
}
2122

23+
AuthHandler.propTypes = {
24+
children: PropTypes.node.isRequired,
25+
};
26+
2227
export default AuthHandler;

src/components/groups/group-create.jsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ function GroupCreate() {
5050
* @param {object} props The props.
5151
* @param {object} props.target Event target.
5252
*/
53-
function handleInput({ target }) {
53+
const handleInput = ({ target }) => {
5454
const localFormStateObject = { ...formStateObject };
5555
localFormStateObject[target.id] = target.value;
5656
setFormStateObject(localFormStateObject);
57-
}
57+
};
5858

5959
/** Handles submit. */
60-
function handleSubmit() {
60+
const handleSubmit = () => {
6161
const saveData = {
6262
title: formStateObject.title,
6363
description: formStateObject.description,
@@ -68,7 +68,7 @@ function GroupCreate() {
6868
PostV1ScreenGroups({
6969
screenGroupScreenGroupInput: JSON.stringify(saveData),
7070
});
71-
}
71+
};
7272

7373
return (
7474
<GroupForm

src/components/groups/group-edit.jsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,14 @@ function GroupEdit() {
8080
* @param {object} props The props.
8181
* @param {object} props.target Event target.
8282
*/
83-
function handleInput({ target }) {
83+
const handleInput = ({ target }) => {
8484
const localFormStateObject = { ...formStateObject };
8585
localFormStateObject[target.id] = target.value;
8686
setFormStateObject(localFormStateObject);
87-
}
87+
};
8888

8989
/** Handles submit. */
90-
function handleSubmit() {
90+
const handleSubmit = () => {
9191
setSavingGroup(true);
9292
setLoadingMessage(t("loading-messages.saving-group"));
9393
const saveData = {
@@ -100,7 +100,7 @@ function GroupEdit() {
100100
id,
101101
screenGroupScreenGroupInput: JSON.stringify(saveData),
102102
});
103-
}
103+
};
104104

105105
return (
106106
<>

src/components/groups/group-form.jsx

+9-1
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,18 @@ function GroupForm({
8585
GroupForm.defaultProps = {
8686
isLoading: false,
8787
loadingMessage: "",
88+
group: PropTypes.shape({
89+
description: "",
90+
title: "",
91+
}),
8892
};
8993

9094
GroupForm.propTypes = {
91-
group: PropTypes.objectOf(PropTypes.any).isRequired,
95+
group: PropTypes.shape({
96+
description: PropTypes.string.isRequired,
97+
98+
title: PropTypes.string.isRequired,
99+
}),
92100
handleInput: PropTypes.func.isRequired,
93101
handleSubmit: PropTypes.func.isRequired,
94102
headerText: PropTypes.string.isRequired,

src/components/groups/groups-list.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,10 @@ function GroupsList() {
104104
}, [isDeleteError]);
105105

106106
/** Starts the deletion process. */
107-
function handleDelete() {
107+
const handleDelete = () => {
108108
setIsDeleting(true);
109109
setLoadingMessage(t("loading-messages.deleting-group"));
110-
}
110+
};
111111

112112
// The columns for the table.
113113
const columns = GroupColumns({

src/components/media-modal/media-modal.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ function MediaModal({ show, onClose, handleAccept, multiple }) {
2525
const { t } = useTranslation("common");
2626

2727
/** @param {Array} images The images that are selected in the dialog. */
28-
function handleSelectedImages(images) {
28+
const handleSelectedImages = (images) => {
2929
setSelectedImages(images);
3030
if (!multiple && images.length === 1) {
3131
handleAccept(images);
3232
}
33-
}
33+
};
3434

3535
return (
3636
<Modal

src/components/media/media-create.jsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ function MediaCreate() {
3131
* @param {object} props The props.
3232
* @param {object} props.target Event target
3333
*/
34-
function handleInput({ target }) {
34+
const handleInput = ({ target }) => {
3535
const localFormStateObject = { ...formStateObject };
3636
localFormStateObject[target.id] = target.value;
3737
setFormStateObject(localFormStateObject);
38-
}
38+
};
3939

4040
/** Saves multiple pieces of media. */
4141
useEffect(() => {
@@ -66,7 +66,7 @@ function MediaCreate() {
6666
}, [isSaveSuccess]);
6767

6868
/** Handles submit. */
69-
function handleSubmit() {
69+
const handleSubmit = () => {
7070
const localMediaToCreate = [];
7171
formStateObject.images.forEach((element) => {
7272
setLoadingMessage(
@@ -85,7 +85,7 @@ function MediaCreate() {
8585
});
8686

8787
setMediaToCreate(localMediaToCreate);
88-
}
88+
};
8989

9090
return (
9191
<MediaForm

src/components/media/media-edit.jsx

-60
This file was deleted.

src/components/media/media-form.jsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,11 @@ MediaForm.defaultProps = {
9090
};
9191

9292
MediaForm.propTypes = {
93-
media: PropTypes.objectOf(PropTypes.any).isRequired,
93+
media: PropTypes.arrayOf(
94+
PropTypes.shape({
95+
url: PropTypes.string,
96+
})
97+
).isRequired,
9498
handleInput: PropTypes.func.isRequired,
9599
handleSubmit: PropTypes.func.isRequired,
96100
headerText: PropTypes.string.isRequired,

src/components/media/media-list.jsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,13 @@ function MediaList({ fromModal }) {
9393
}, [context.selectedTenant.get]);
9494

9595
/** @param {number} nextPage - The next page. */
96-
function updateUrlAndChangePage(nextPage) {
96+
const updateUrlAndChangePage = (nextPage) => {
9797
const params = new URLSearchParams(search);
9898
params.delete("page");
9999
params.append("page", nextPage);
100100
navigate({ search: params.toString() });
101101
setPage(nextPage);
102-
}
102+
};
103103

104104
/** Sets the url. */
105105
useEffect(() => {
@@ -118,10 +118,10 @@ function MediaList({ fromModal }) {
118118
*
119119
* @param {string} newSearchText Updates the search text state and url.
120120
*/
121-
function handleSearch(newSearchText) {
121+
const handleSearch = (newSearchText) => {
122122
setPage(1);
123123
setSearchText(newSearchText);
124-
}
124+
};
125125

126126
/** Deletes multiple pieces of media. */
127127
useEffect(() => {
@@ -151,10 +151,10 @@ function MediaList({ fromModal }) {
151151
}, [isDeleteError]);
152152

153153
/** Deletes selected data, and closes modal. */
154-
function handleDelete() {
154+
const handleDelete = () => {
155155
setLoadingMessage(t("loading-messages.deleting-media"));
156156
setIsDeleting(true);
157-
}
157+
};
158158

159159
useEffect(() => {
160160
if (mediaLoadError) {

src/components/navigation/nav-items/restricted-nav-route.jsx

+6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { React, useContext } from "react";
2+
import PropTypes from "prop-types";
23
import UserContext from "../../../context/user-context";
34

45
/**
@@ -24,4 +25,9 @@ function RestrictedNavRoute({ children, roles }) {
2425
return children;
2526
}
2627

28+
RestrictedNavRoute.propTypes = {
29+
children: PropTypes.node.isRequired,
30+
roles: PropTypes.arrayOf(PropTypes.string).isRequired,
31+
};
32+
2733
export default RestrictedNavRoute;

src/components/playlist-drag-and-drop/playlist-drag-and-drop.jsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,16 @@ function PlaylistDragAndDrop({ handleChange, name, screenId, regionId }) {
6161
*
6262
* @param {string} filter - The filter.
6363
*/
64-
function onFilter(filter) {
64+
const onFilter = (filter) => {
6565
setSearchText(filter);
66-
}
66+
};
6767

6868
/**
6969
* Removes playlist from list of playlists, and closes modal.
7070
*
7171
* @param {object} removeItem - Item to remove
7272
*/
73-
function removeFromList(removeItem) {
73+
const removeFromList = (removeItem) => {
7474
const indexOfItemToRemove = selectedData
7575
.map((item) => {
7676
return item["@id"];
@@ -82,21 +82,21 @@ function PlaylistDragAndDrop({ handleChange, name, screenId, regionId }) {
8282

8383
const target = { value: selectedDataCopy, id: name };
8484
handleChange({ target });
85-
}
85+
};
8686

8787
/**
8888
* Adds group to list of groups.
8989
*
9090
* @param {object} props - The props.
9191
* @param {object} props.target - The target.
9292
*/
93-
function handleAdd({ target }) {
93+
const handleAdd = ({ target }) => {
9494
const { value, id } = target;
9595
setSelectedData(value);
9696
handleChange({
9797
target: { id, value },
9898
});
99-
}
99+
};
100100

101101
const columns = SelectPlaylistColumns({
102102
handleDelete: removeFromList,

src/components/playlist/campaign-form.jsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,15 @@ function CampaignForm({ campaign, handleInput }) {
4444
</>
4545
);
4646
}
47+
48+
CampaignForm.defaultProps = {
49+
campaign: null,
50+
};
51+
4752
CampaignForm.propTypes = {
48-
campaign: PropTypes.objectOf(PropTypes.any).isRequired,
53+
campaign: PropTypes.objectOf({
54+
"@id": PropTypes.string,
55+
}),
4956
handleInput: PropTypes.func.isRequired,
5057
};
5158

src/components/playlist/playlist-campaign-edit.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function PlaylistCampaignEdit({ location }) {
3030

3131
return (
3232
<>
33-
{slideId && (
33+
{(slideId || loadingError) && (
3434
<PlaylistCampaignManager
3535
saveMethod="PUT"
3636
location={location}

src/components/playlist/playlist-campaign-form.jsx

+13-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function PlaylistCampaignForm({
4444
const [publishedToError, setPublishedToError] = useState(false);
4545

4646
/** Check if published is set */
47-
function checkInputsHandleSubmit() {
47+
const checkInputsHandleSubmit = () => {
4848
setPublishedToError(false);
4949
setPublishedFromError(false);
5050
let submit = true;
@@ -60,7 +60,7 @@ function PlaylistCampaignForm({
6060
if (submit) {
6161
handleSubmit();
6262
}
63-
}
63+
};
6464

6565
return (
6666
<>
@@ -159,10 +159,20 @@ PlaylistCampaignForm.defaultProps = {
159159
isLoading: false,
160160
loadingMessage: "",
161161
isCampaign: false,
162+
playlist: null,
162163
};
163164

164165
PlaylistCampaignForm.propTypes = {
165-
playlist: PropTypes.objectOf(PropTypes.any).isRequired,
166+
playlist: PropTypes.shape({
167+
description: PropTypes.string,
168+
169+
published: PropTypes.shape({
170+
from: PropTypes.string,
171+
to: PropTypes.string,
172+
}),
173+
174+
title: PropTypes.string,
175+
}),
166176
handleInput: PropTypes.func.isRequired,
167177
handleSubmit: PropTypes.func.isRequired,
168178
headerText: PropTypes.string.isRequired,

0 commit comments

Comments
 (0)