From c030d5c0993dc831b7a864cc4237aaa4605c99fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=20Erik=20St=C3=B8wer?= Date: Fri, 13 Dec 2024 21:13:20 +0100 Subject: [PATCH] Remove roleUtils file --- src/components/EditStopPage/ModalitiesMenuItems.js | 3 +-- src/components/Map/NeighbourMarker.js | 2 +- src/modelUtils/leafletUtils.js | 9 ++++++++- src/models/submodes.js | 4 ++++ src/utils/roleUtils.js | 13 ------------- 5 files changed, 14 insertions(+), 17 deletions(-) delete mode 100644 src/utils/roleUtils.js diff --git a/src/components/EditStopPage/ModalitiesMenuItems.js b/src/components/EditStopPage/ModalitiesMenuItems.js index 2f30806ff..462d03c4d 100644 --- a/src/components/EditStopPage/ModalitiesMenuItems.js +++ b/src/components/EditStopPage/ModalitiesMenuItems.js @@ -15,8 +15,7 @@ limitations under the Licence. */ import React from "react"; import MenuItem from "@mui/material/MenuItem"; import ModalityIconSvg from "../MainPage/ModalityIconSvg"; -import ArrowDropRight from "@mui/icons-material/ArrowRight"; -import { getInverseSubmodesWhitelist } from "../../utils/roleUtils"; +import { getInverseSubmodesWhitelist } from "../../models/submodes"; import { getStopPlacesForSubmodes } from "../../utils/roleUtils"; import MoreMenuItem from "../MainPage/MoreMenuItem"; diff --git a/src/components/Map/NeighbourMarker.js b/src/components/Map/NeighbourMarker.js index 886d804fa..1b000db25 100644 --- a/src/components/Map/NeighbourMarker.js +++ b/src/components/Map/NeighbourMarker.js @@ -20,7 +20,7 @@ import ReactDOM from "react-dom/server"; import CustomMarkerIcon from "./CustomMarkerIcon"; import { shallowCompareNeighbourMarker as shallowCompare } from "./shallowCompare/"; import PopupButton from "./PopupButton"; -import { isLegalChildStopPlace } from "../../utils/roleUtils"; +import { isLegalChildStopPlace } from "../../modelUtils/leafletUtils"; import { connect } from "react-redux"; class NeighbourMarker extends React.Component { diff --git a/src/modelUtils/leafletUtils.js b/src/modelUtils/leafletUtils.js index aaa9b5b08..adaf9c8c8 100644 --- a/src/modelUtils/leafletUtils.js +++ b/src/modelUtils/leafletUtils.js @@ -13,7 +13,6 @@ See the Licence for the specific language governing permissions and limitations under the Licence. */ import { LatLng } from "leaflet"; -import { isLegalChildStopPlace } from "../utils/roleUtils"; export const getUniquePathLinks = (a, key) => { var seen = {}; @@ -121,3 +120,11 @@ export const getGroupMemberSuggestions = ( return legalSuggestions.slice(0, nFirst); }; + +export const isLegalChildStopPlace = (stopPlace) => { + if (!stopPlace) { + return false; + } + + return stopPlace.permissions?.canEdit || false; +}; diff --git a/src/models/submodes.js b/src/models/submodes.js index bf77a8dab..b49ed1e66 100644 --- a/src/models/submodes.js +++ b/src/models/submodes.js @@ -45,3 +45,7 @@ export const submodes = [ "telecabin", "funicular", ]; + +export const getInverseSubmodesWhitelist = (whitelist) => { + return submodes.filter((submode) => whitelist.indexOf(submode) === -1); +}; diff --git a/src/utils/roleUtils.js b/src/utils/roleUtils.js deleted file mode 100644 index e2bf989ba..000000000 --- a/src/utils/roleUtils.js +++ /dev/null @@ -1,13 +0,0 @@ -import { submodes as allSubmodes } from "../models/submodes"; - -export const isLegalChildStopPlace = (stopPlace) => { - if (!stopPlace) { - return false; - } - - return stopPlace.permissions?.canEdit || false; -}; - -export const getInverseSubmodesWhitelist = (whitelist) => { - return allSubmodes.filter((submode) => whitelist.indexOf(submode) === -1); -};