-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Disable styles #970
base: master
Are you sure you want to change the base?
Disable styles #970
Changes from all commits
03ad72b
b9fae9c
60995ed
22ef038
d17e1b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { useMemo } from 'react'; | ||
|
||
export default (t) => useMemo(() => ({ | ||
disableMapLayers: { | ||
name: t('attributeUiDisableMapLayers'), | ||
type: 'string', | ||
}, | ||
}), [t]); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,8 +30,10 @@ export default () => { | |
const hereKey = useAttributePreference('hereKey'); | ||
const mapboxAccessToken = useAttributePreference('mapboxAccessToken'); | ||
const customMapUrl = useSelector((state) => state.session.server?.mapUrl); | ||
const disabledStyles = new Set((useSelector((state) => state.session.server.attributes?.disableMapLayers) || '').split(',') || []); | ||
const activeStyles = []; | ||
|
||
return [ | ||
const Styles = [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. variables shouldn't start with a capital letter. it should be lower case |
||
{ | ||
id: 'locationIqStreets', | ||
title: t('mapLocationIqStreets'), | ||
|
@@ -170,7 +172,7 @@ export default () => { | |
attribute: 'mapboxAccessToken', | ||
}, | ||
{ | ||
id: 'mapboxSatelliteStreet', | ||
id: 'mapboxSatellite', | ||
title: t('mapMapboxSatellite'), | ||
style: styleCustom( | ||
[`https://api.mapbox.com/styles/v1/mapbox/satellite-streets-v11/tiles/{z}/{x}/{y}?access_token=${mapboxAccessToken}`], | ||
|
@@ -185,4 +187,11 @@ export default () => { | |
available: !!customMapUrl, | ||
}, | ||
]; | ||
|
||
for (let i = 0; i < Styles.length; i += 1) { | ||
if (!disabledStyles.has(Styles[i].id)) { | ||
activeStyles.push(Styles[i]); | ||
} | ||
} | ||
return activeStyles; | ||
Comment on lines
+191
to
+196
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just use |
||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ import PageLayout from '../common/components/PageLayout'; | |
import SettingsMenu from './components/SettingsMenu'; | ||
import useCommonDeviceAttributes from '../common/attributes/useCommonDeviceAttributes'; | ||
import useCommonUserAttributes from '../common/attributes/useCommonUserAttributes'; | ||
import useServerAttributes from '../common/attributes/useServerAttributes '; | ||
import { useCatch } from '../reactHelper'; | ||
|
||
const useStyles = makeStyles((theme) => ({ | ||
|
@@ -58,6 +59,7 @@ const ServerPage = () => { | |
const t = useTranslation(); | ||
|
||
const commonUserAttributes = useCommonUserAttributes(t); | ||
const commonServerAttributes = useServerAttributes(t); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You forgot to rename the variable. |
||
const commonDeviceAttributes = useCommonDeviceAttributes(t); | ||
|
||
const original = useSelector((state) => state.session.server); | ||
|
@@ -238,7 +240,7 @@ const ServerPage = () => { | |
<EditAttributesView | ||
attributes={item.attributes} | ||
setAttributes={(attributes) => setItem({ ...item, attributes })} | ||
definitions={{ ...commonUserAttributes, ...commonDeviceAttributes }} | ||
definitions={{ ...commonUserAttributes, ...commonDeviceAttributes, ...commonServerAttributes }} | ||
/> | ||
</AccordionDetails> | ||
</Accordion> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would split it into two. First get
disableMapLayers
using selector and then a separate line to convert it into a set.Also I think
|| []
should be unnecessary.