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

Copy ID support in popups #989

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from

Conversation

prof-miles0
Copy link
Contributor

No description provided.

@prof-miles0
Copy link
Contributor Author

I think I need help to include the Menu in spawnpoints popup. Nests pokestops and gyms are working fine since those already had the menu...

@@ -164,6 +164,7 @@ const DropdownOptions = ({
raid_level,
}) => {
const { t } = useTranslation()
const { perms } = useMemory((s) => s.auth)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const { perms } = useMemory((s) => s.auth)
const admin = useMemory((s) => s.auth.perms.admin)

I know the way you have it is how it was done in the Nest Popup component, but that isn't the "correct" way and should be fixed there too. For new components though, I would prefer if you could use the way I suggested on Discord. That goes for the rest of the popups too. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes included. I still have to do it for spawnpoints and routes. This ones are going to be more difficult for me since I have to add the menu...

@TurtIeSocks
Copy link
Collaborator

I think I need help to include the Menu in spawnpoints popup. Nests pokestops and gyms are working fine since those already had the menu...

Here's a recommend reusable component:

// /src/components/popups/CopyIDMenu.jsx

// @ts-check
import * as React from 'react'
import Menu from '@mui/material/Menu'
import MenuItem from '@mui/material/MenuItem'
import IconButton from '@mui/material/IconButton'
import { useTranslation } from 'react-i18next'
import MoreVert from '@mui/icons-material/MoreVert'
import Grid from '@mui/material/Unstable_Grid2'

import { useMemory } from '@store/useMemory'

const PAPER_PROPS =
  /** @type {import('@mui/material').MenuProps['PaperProps']} */ ({
    style: {
      maxHeight: 216,
      minWidth: '20ch',
    },
  })

/**
 * @param {{ id: string | number, children?: React.ReactNode } & import('@mui/material').Grid2Props} props
 */
export function CopyIDMenu({ id, children, ...props }) {
  const [anchorEl, setAnchorEl] = React.useState(null)

  /** @type {import('@mui/material').IconButtonProps['onClick']} */
  const onClick = (event) => setAnchorEl(event.currentTarget)

  const handleClose = () => setAnchorEl(null)

  return (
    <Grid textAlign="right" {...props}>
      <IconButton onClick={onClick}>
        <MoreVert />
      </IconButton>
      <Menu
        anchorEl={anchorEl}
        keepMounted
        open={!!anchorEl}
        onClose={handleClose}
        PaperProps={PAPER_PROPS}
      >
        {children}
        <CopyIDMenuItem id={id} handleClose={handleClose} />
      </Menu>
    </Grid>
  )
}

/**
 * @param {{ id: string | number, handleClose: () => void }} props
 */
export function CopyIDMenuItem({ id, handleClose }) {
  const { t } = useTranslation()
  const admin = useMemory((s) => s.auth.perms.admin)

  const onClick = React.useCallback(() => {
    navigator.clipboard.writeText(String(id))
    handleClose()
  }, [id, handleClose])

  return admin && <MenuItem onClick={onClick}>{t('copy_id')}</MenuItem>
}

Then in your Spawnpoint popup you can change the top to something like this:

      <Grid container alignItems="center">
        <Grid xs={10}>
          <Typography variant="h5" align="center">
            {t('spawnpoint')}
          </Typography>
        </Grid>
        <CopyIDMenu id={id} xs={2} />
      </Grid>

( Make sure to import the new components needed )

Then in your Route popup, something like this:

        <Grid2 xs={10}>
          <Title>{route.name}</Title>
        </Grid2>
        <Grid2 xs={2}>
          <CopyIDMenu id={route.id} />
        </Grid2>

Let me know if those work for you or if you have any other questions! Thanks for the contribution so far, looking great!

prof-miles0 and others added 2 commits May 4, 2024 19:26
# [1.30.0-develop.1](v1.29.6...v1.30.0-develop.1) (2024-05-04)

### Bug Fixes

* `onlyShowAvailable` for nests selector ([068dac2](068dac2))
* 0iv/100iv overrides in a specific scenario ([aebebf1](aebebf1))
* 0s in gym popup ([2d9bdc1](2d9bdc1))
* actions ([079de55](079de55))
* add log to indicate config env var ([ba25048](ba25048))
* add missing `key` prop & simplify ([05be65c](05be65c))
* add new dist folders to lint ignores ([9a870cd](9a870cd))
* added migration for gym badges, fixed gold badge count not appearing on profile ([e9f9474](e9f9474))
* adjust wayfarer line weights ([e6c0696](e6c0696))
* ai generated locales ([2d0e7fb](2d0e7fb))
* alert state ([a39154d](a39154d))
* area selected translation ([bbe49e1](bbe49e1))
* asset options ([e56b0dd](e56b0dd))
* asset updating ([a8f1e9c](a8f1e9c))
* attempt to keep available/masterfile more in sync ([1961af3](1961af3))
* better selector tiles for colorblind users ([0256b5b](0256b5b))
* cache most things at process exit instead ([56eb47e](56eb47e))
* check for multidomains in areas ([e5b8a9c](e5b8a9c))
* check for networkError null ([e8bcb79](e8bcb79))
* ci ([6b4fa8a](6b4fa8a))
* ci ([c657ddd](c657ddd))
* clipped classname ([2563fb7](2563fb7))
* config getters ([494639a](494639a))
* couple of queries ([460f66e](460f66e))
* css className that got clipped ([1abe5e3](1abe5e3))
* custom favicons for each domain ([f470f53](f470f53))
* dont log golbat 404 pokemon id errors ([7292d13](7292d13))
* early version check ([c9d1295](c9d1295))
* express session augmentation ([35533e9](35533e9))
* fallback obj ([b6470f4](b6470f4))
* favicon error catching for dummies ([b6c0fae](b6c0fae))
* favicon instructions ([1851505](1851505))
* feedback from naji ([72344a0](72344a0))
* file caching for multi ([2acf34a](2acf34a))
* fixed new badge type in profile, refactored ternary in a positive way ([8bd1f90](8bd1f90))
* gym badge counts ([67f3b0d](67f3b0d))
* hopefully final fix for leaflet.locatecontrol ([e08e3f2](e08e3f2))
* importing ([89b7fce](89b7fce))
* improved jsdocs for search method ([5dcf288](5dcf288))
* less strict searching for `'` ([ca08a69](ca08a69))
* **lint:** prettier lint ([5f87694](5f87694))
* local assets ([615c3b8](615c3b8))
* locate translations / unit of measurement ([704423b](704423b))
* logging uncaughtException error ([6848cdc](6848cdc))
* map dependency checks ([85c992d](85c992d))
* maybe fix missing ci secret ([15058dc](15058dc))
* Merge pull request [WatWowMap#963](https://github.com/mkllrtxn/ReactMap/issues/963) from ReuschelCGN/translation ([cbc0160](cbc0160))
* misc icons ([f4423a9](f4423a9))
* mobile friendly :| ([b259e42](b259e42))
* more client ts checks ([5028cb2](5028cb2))
* more consistent gender filtering ([a3b24cb](a3b24cb))
* nest name memoization ([ec56d7d](ec56d7d))
* **nest:** make it compatible with previous tools ([9d97481](9d97481))
* **nest:** query only active nests ([ebb5295](ebb5295))
* no floats ([b8f645e](b8f645e))
* normal form check ([47e358b](47e358b))
* oops, swap ternary ([bdcfaf4](bdcfaf4))
* pass ref props for tooltip ([9d55d4c](9d55d4c))
* pokemon ui inconsistency ([0cb334c](0cb334c))
* pvp filter in when `all` is set ([2acf75f](2acf75f))
* react leaflet locate control fixes ([d01beb0](d01beb0))
* reading other config files ([ef30f33](ef30f33))
* refine ci ([515de64](515de64))
* remove log ([86c5854](86c5854))
* remove useeffect dep ([00d9bfc](00d9bfc))
* respect quest layer when searching ([4b0e0cc](4b0e0cc)), closes [WatWowMap#950](https://github.com/mkllrtxn/ReactMap/issues/950)
* rounding & icon for missing ai ([4ed05ff](4ed05ff))
* safe 0 fallback ([45795a8](45795a8))
* scan areas ([8dbc1f3](8dbc1f3))
* scan cells ([b6b45ca](b6b45ca))
* semi fix for the leaflet.locatecontrol issue ([4cb5882](4cb5882))
* server side routes ([77eafa9](77eafa9))
* simplify ([b48bcb3](b48bcb3))
* some clipped imports ([ed65bc0](ed65bc0))
* some incorrect feature imports ([a36ea7c](a36ea7c))
* still define obj though ([e98bb92](e98bb92))
* swapped ivOr stores ([98fe335](98fe335))
* throw error at a different point ([825b2d9](825b2d9))
* throw error if missing openai key ([de939e2](de939e2))
* try/catch on expert filter just in case ([4e430e6](4e430e6))
* tutorial crash issue ([4fcc100](4fcc100))
* types ([4b78846](4b78846))
* unnecessary call ([3c983d3](3c983d3))
* updating translations based on feedback from Fabio1988 and lenisko ([7d9ec75](7d9ec75))
* user options state ([1e23a55](1e23a55))
* various small things ([ada7947](ada7947))
* various text fixes ([6eb9c6a](6eb9c6a)), closes [WatWowMap#967](https://github.com/mkllrtxn/ReactMap/issues/967)
* webhook gym searching ([dc8ff8b](dc8ff8b))

### Features

* add icon overrides in config for troubleshooting/trolling ([d34b69a](d34b69a))
* added "basic" level gym badge ([4c4d3a4](4c4d3a4))
* data management page ([561c031](561c031))
* locales editing page ([bfbd15a](bfbd15a))
* lots of docs & examples ([1a33c5e](1a33c5e))
* new approach to multi domain ([aa5602b](aa5602b))
* pkmn filter diagram ([a40b201](a40b201))
* spacial rend range ([374c5eb](374c5eb))
* update polish locales ([WatWowMap#959](https://github.com/mkllrtxn/ReactMap/issues/959)) ([d28dc0a](d28dc0a))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants