From 55894b26c58e235a5270d4856c0dcd59edc0333e Mon Sep 17 00:00:00 2001 From: mkl <> Date: Wed, 20 Mar 2024 12:01:21 +0100 Subject: [PATCH 1/8] Update nests popup to support Copy ID --- src/features/nest/NestPopup.jsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/features/nest/NestPopup.jsx b/src/features/nest/NestPopup.jsx index b955dda57..bcb713f44 100644 --- a/src/features/nest/NestPopup.jsx +++ b/src/features/nest/NestPopup.jsx @@ -76,6 +76,11 @@ export function NestPopup({ setDeepStore(`filters.nests.filter.${key}.enabled`, false) } + const copyId = () => { + setAnchorEl(null) + navigator.clipboard.writeText(id) + } + useAnalytics('Popup', `Name: ${name} Pokemon: ${pokemon_id}`, 'Nest') const options = [ @@ -83,6 +88,10 @@ export function NestPopup({ { name: 'exclude', action: handleExclude }, ] + if (perms.admin) { + options.push({ name: 'Copy ID', action: copyId }) + } + return ( Date: Wed, 20 Mar 2024 14:18:57 +0100 Subject: [PATCH 2/8] Update pokestop popup to support Copy ID --- src/features/pokestop/PokestopPopup.jsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/features/pokestop/PokestopPopup.jsx b/src/features/pokestop/PokestopPopup.jsx index 92f10f7f4..6debfd4bb 100644 --- a/src/features/pokestop/PokestopPopup.jsx +++ b/src/features/pokestop/PokestopPopup.jsx @@ -307,6 +307,7 @@ const MenuActions = ({ invasions, }) => { const { t } = useTranslation() + const { perms } = useMemory((s) => s.auth) const masterfile = useMemory((s) => s.masterfile) const filters = useStorage((s) => s.filters) @@ -354,6 +355,11 @@ const MenuActions = ({ }) } + const copyId = () => { + setAnchorEl(null) + navigator.clipboard.writeText(id) + } + const options = [{ name: 'hide', action: handleHide }] if (hasQuest) { @@ -459,6 +465,11 @@ const MenuActions = ({ } options.push({ name: 'timer', action: handleTimer }) } + + if (perms.admin) { + options.push({ name: 'Copy ID', action: copyId }) + } + return ( From bc6e7c650f661887710f57ed4603e167966a8a63 Mon Sep 17 00:00:00 2001 From: mkl <> Date: Wed, 20 Mar 2024 15:07:40 +0100 Subject: [PATCH 3/8] Update gym popup to support Copy ID --- src/features/gym/GymPopup.jsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/features/gym/GymPopup.jsx b/src/features/gym/GymPopup.jsx index 923c3202b..32c3d2cf7 100644 --- a/src/features/gym/GymPopup.jsx +++ b/src/features/gym/GymPopup.jsx @@ -164,6 +164,7 @@ const DropdownOptions = ({ raid_level, }) => { const { t } = useTranslation() + const { perms } = useMemory((s) => s.auth) const { gyms, raids, gymBadges, webhooks } = useMemory((s) => s.auth.perms) const gymValidDataLimit = useMemory((s) => s.gymValidDataLimit) @@ -208,6 +209,11 @@ const DropdownOptions = ({ }) } + const copyId = () => { + setAnchorEl(null) + navigator.clipboard.writeText(id) + } + const options = [{ name: 'hide', action: handleHide }] if (gyms) { @@ -251,6 +257,10 @@ const DropdownOptions = ({ }) } + if (perms.admin) { + options.push({ name: 'Copy ID', action: copyId }) + } + return options.filter(Boolean).map((option) => ( {typeof option.name === 'string' ? t(option.name) : option.name} From dcfab70af1ad6147ec60a30e4a14ff3826a7fc66 Mon Sep 17 00:00:00 2001 From: mkl <> Date: Wed, 20 Mar 2024 15:09:02 +0100 Subject: [PATCH 4/8] Update spawnpoint popup to support Copy ID --- src/features/spawnpoint/SpawnpointPopup.jsx | 36 ++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/src/features/spawnpoint/SpawnpointPopup.jsx b/src/features/spawnpoint/SpawnpointPopup.jsx index 74fe4363d..fe6928ae4 100644 --- a/src/features/spawnpoint/SpawnpointPopup.jsx +++ b/src/features/spawnpoint/SpawnpointPopup.jsx @@ -11,14 +11,48 @@ import { dayCheck } from '@utils/dayCheck' * @param {import('@rm/types').Spawnpoint} props * @returns */ -export function SpawnpointPopup({ despawn_sec, lat, lon, updated }) { +export function SpawnpointPopup({ id, despawn_sec, lat, lon, updated }) { const { t } = useTranslation() + const { perms } = useMemory((s) => s.auth) const minute = despawn_sec > 60 ? Math.round(despawn_sec / 60) : despawn_sec const minuteFixed = minute < 10 ? `0${minute}` : minute + const handleClose = () => { + setAnchorEl(null) + } + + const copyId = () => { + setAnchorEl(null) + navigator.clipboard.writeText(id) + } + + const options = [] + + if (perms.admin) { + options.push({ name: 'Copy ID', action: copyId }) + } + return ( + + {options.map((option) => ( + + {typeof option.name === 'string' ? t(option.name) : option.name} + + ))} + {t('spawnpoint')} From 001e532dd2b9791bd312dd45a661bf9e37cebbf4 Mon Sep 17 00:00:00 2001 From: mkl <> Date: Wed, 20 Mar 2024 15:27:27 +0100 Subject: [PATCH 5/8] Fix gym popup --- src/features/gym/GymPopup.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/features/gym/GymPopup.jsx b/src/features/gym/GymPopup.jsx index 32c3d2cf7..a6d29cc03 100644 --- a/src/features/gym/GymPopup.jsx +++ b/src/features/gym/GymPopup.jsx @@ -210,7 +210,7 @@ const DropdownOptions = ({ } const copyId = () => { - setAnchorEl(null) + handleClose() navigator.clipboard.writeText(id) } From 9f8166387a6b4c46afec8f23d4120fe124d8a728 Mon Sep 17 00:00:00 2001 From: mkl <> Date: Wed, 20 Mar 2024 15:32:33 +0100 Subject: [PATCH 6/8] Fix spawnpoint popup --- src/features/spawnpoint/SpawnpointPopup.jsx | 41 ++++++++++++--------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/src/features/spawnpoint/SpawnpointPopup.jsx b/src/features/spawnpoint/SpawnpointPopup.jsx index fe6928ae4..237e87ef8 100644 --- a/src/features/spawnpoint/SpawnpointPopup.jsx +++ b/src/features/spawnpoint/SpawnpointPopup.jsx @@ -1,8 +1,11 @@ // @ts-check import * as React from 'react' import Typography from '@mui/material/Typography' +import Menu from '@mui/material/Menu' +import MenuItem from '@mui/material/MenuItem' import { useTranslation } from 'react-i18next' +import { useMemory } from '@store/useMemory' import { ErrorBoundary } from '@components/ErrorBoundary' import { dayCheck } from '@utils/dayCheck' @@ -15,13 +18,15 @@ export function SpawnpointPopup({ id, despawn_sec, lat, lon, updated }) { const { t } = useTranslation() const { perms } = useMemory((s) => s.auth) + const [anchorEl, setAnchorEl] = React.useState(null) + const minute = despawn_sec > 60 ? Math.round(despawn_sec / 60) : despawn_sec const minuteFixed = minute < 10 ? `0${minute}` : minute const handleClose = () => { setAnchorEl(null) } - + const copyId = () => { setAnchorEl(null) navigator.clipboard.writeText(id) @@ -36,23 +41,23 @@ export function SpawnpointPopup({ id, despawn_sec, lat, lon, updated }) { return ( - {options.map((option) => ( - - {typeof option.name === 'string' ? t(option.name) : option.name} - - ))} - + anchorEl={anchorEl} + keepMounted + open={!!anchorEl} + onClose={handleClose} + PaperProps={{ + style: { + maxHeight: 216, + minWidth: '20ch', + }, + }} + > + {options.map((option) => ( + + {typeof option.name === 'string' ? t(option.name) : option.name} + + ))} + {t('spawnpoint')} From 6365f283defc1660d61b455cbe7e14d173145867 Mon Sep 17 00:00:00 2001 From: mkl <> Date: Thu, 21 Mar 2024 10:43:01 +0100 Subject: [PATCH 7/8] Change general perms to only admin and support for locales --- packages/locales/lib/human/en.json | 3 ++- packages/locales/lib/human/es.json | 3 ++- src/features/gym/GymPopup.jsx | 6 +++--- src/features/nest/NestPopup.jsx | 10 ++++++---- src/features/pokestop/PokestopPopup.jsx | 6 +++--- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/packages/locales/lib/human/en.json b/packages/locales/lib/human/en.json index 97f7f2f70..9153617dd 100644 --- a/packages/locales/lib/human/en.json +++ b/packages/locales/lib/human/en.json @@ -780,5 +780,6 @@ "locale_instructions_7": "Create a pull request", "locale_instructions_8": "Wait for the pull request to be reviewed and merged", "enter_translation": "Enter Translation", - "individual_filters": "Partially Filtered" + "individual_filters": "Partially Filtered", + "copy_id": "Copy ID" } diff --git a/packages/locales/lib/human/es.json b/packages/locales/lib/human/es.json index 26528d5a6..49438bc56 100644 --- a/packages/locales/lib/human/es.json +++ b/packages/locales/lib/human/es.json @@ -615,5 +615,6 @@ "show_editor": "Mostrar Editor", "hide_editor": "Ocultar Editor", "reported_error": "Este error ha sido reportado al servidor con el identificador", - "dark_mode": "Modo Oscuro" + "dark_mode": "Modo Oscuro", + "copy_id": "Copiar ID" } diff --git a/src/features/gym/GymPopup.jsx b/src/features/gym/GymPopup.jsx index a6d29cc03..073ef3dc8 100644 --- a/src/features/gym/GymPopup.jsx +++ b/src/features/gym/GymPopup.jsx @@ -164,7 +164,7 @@ const DropdownOptions = ({ raid_level, }) => { const { t } = useTranslation() - const { perms } = useMemory((s) => s.auth) + const admin = useMemory((s) => s.auth.perms.admin) const { gyms, raids, gymBadges, webhooks } = useMemory((s) => s.auth.perms) const gymValidDataLimit = useMemory((s) => s.gymValidDataLimit) @@ -257,8 +257,8 @@ const DropdownOptions = ({ }) } - if (perms.admin) { - options.push({ name: 'Copy ID', action: copyId }) + if (admin) { + options.push({ name: 'copy_id', action: copyId }) } return options.filter(Boolean).map((option) => ( diff --git a/src/features/nest/NestPopup.jsx b/src/features/nest/NestPopup.jsx index bcb713f44..215f2f8b4 100644 --- a/src/features/nest/NestPopup.jsx +++ b/src/features/nest/NestPopup.jsx @@ -50,7 +50,9 @@ export function NestPopup({ submitted_by = '', }) { const { t } = useTranslation() - const { perms } = useMemory((s) => s.auth) + + const admin = useMemory((s) => s.auth.perms.admin) + const nestSubmissions = useMemory((s) => s.auth.perms.nestSubmissions) const [parkName, setParkName] = React.useState(true) const [anchorEl, setAnchorEl] = React.useState(null) @@ -88,8 +90,8 @@ export function NestPopup({ { name: 'exclude', action: handleExclude }, ] - if (perms.admin) { - options.push({ name: 'Copy ID', action: copyId }) + if (admin) { + options.push({ name: 'copy_id', action: copyId }) } return ( @@ -188,7 +190,7 @@ export function NestPopup({ )} - {perms.nestSubmissions && ( + {nestSubmissions && (