<commit_before>import { Box, Col, Text } from '@tlon/indigo-react';
import { Group } from '@urbit/api/groups';
import { deSig } from '@urbit/api';
import { Association } from '@urbit/api/metadata';
import React, { ReactElement, useCallback, useRef } from 'react';
import { Link, Route, RouteComponentProps, Switch } from 'react-router-dom';
import { resourceFromPath } from '~/logic/lib/group';
import { useHashLink } from '~/logic/lib/useHashLink';
import { ModalOverlay } from '~/views/components/ModalOverlay';
import { SidebarItem } from '~/views/landscape/components/SidebarItem';
import { DeleteGroup } from './DeleteGroup';
import { GroupSettings } from './GroupSettings/GroupSettings';
import { Participants } from './Participants';

export function PopoverRoutes(
  props: {
    baseUrl: string;
    group: Group;
    association: Association;
  } & RouteComponentProps
): ReactElement {
  const relativeUrl = (url: string) => `${props.baseUrl}/popover${url}`;
  const innerRef = useRef(null);

  const onDismiss = useCallback(() => {
    props.history.push(props.baseUrl);
  }, [props.history.push, props.baseUrl]);

  useHashLink();

  const groupSize = props.group.members.size;
  const ship = resourceFromPath(props.association?.group ?? '//~zod/group').ship;
  const owner = deSig(ship) === window.ship;

  const admin = props.group?.tags?.role?.admin.has(window.ship) || false;

  return (
    <Switch>
      <Route
        path={[relativeUrl('/:view'), relativeUrl('')]}
        render={(routeProps) => {
          const { view } = routeProps.match.params;
          return (
            <ModalOverlay
              spacing={[3,5,7]}
              ref={innerRef}
              border={1}
              borderColor="washedGray"
              borderRadius={1}
              width="100%"
              height="100%"
              bg="white"
              dismiss={onDismiss}
            >
              <Box
                display="grid"
                gridTemplateRows={['32px 1fr', '100%']}
                gridTemplateColumns={['100%', '250px 1fr']}
                height="100%"
                width="100%"
              >
                <Col
                  display={view ? ['none', 'flex'] : 'flex'}
                  borderRight={1}
                  borderRightColor="washedGray"
                >
                  <Text my={4} mx={3} fontWeight="600" fontSize={2}>Group Settings</Text>
                  <Col gapY={2}>
                    <Text my={1} mx={3} gray>Group</Text>
                    <SidebarItem
                      icon='Notifications'
                      to={relativeUrl('/settings#notifications')}
                      text="Notifications"
                    />
                    <SidebarItem
                      icon="Users"
                      to={relativeUrl('/participants')}
                      text="Participants"
                      selected={view === 'participants'}
                    ><Text gray>{groupSize}</Text>
                    </SidebarItem>
                    { admin && (
                      <>
                        <Box pt={3} mb={1} mx={3}>
                          <Text gray>Administration</Text>
                        </Box>
                        <SidebarItem
                          icon="Groups"
                          to={relativeUrl('/settings#group-details')}
                          text="Group Details"
                        />
                        <SidebarItem
                          icon="Dashboard"
                          to={relativeUrl('/settings#channels')}
                          text="Channel Management"
                        />
                        { owner && (
                        <SidebarItem
                          icon="Server"
                          to={relativeUrl('/settings#feed')}
                          text="Group Feed"
                        />)}

                      </>
                    )}
                    <DeleteGroup owner={owner} association={props.association} />
                  </Col>
                </Col>
                <Box
                  gridArea={'1 / 1 / 2 / 2'}
                  p={2}
                  display={['auto', 'none']}
                >
                  <Link to={view ? relativeUrl('') : props.baseUrl}>
                    <Text>{'<- Back'}</Text>
                  </Link>
                </Box>
                <Box overflow="hidden">
                  {view === 'settings' && (
                    <GroupSettings
                      baseUrl={`${props.baseUrl}/popover`}
                      group={props.group}
                      association={props.association}
                    />
                  )}
                  {view === 'participants' && (
                    <Participants
                      group={props.group}
                      association={props.association}
                    />
                  )}
                </Box>
              </Box>
            </ModalOverlay>
          );
        }}
      />
    </Switch>
  );
}
<commit_msg>popover-routes: put something resembling a real path<commit_after>import { Box, Col, Text } from '@tlon/indigo-react';
import { Group } from '@urbit/api/groups';
import { deSig } from '@urbit/api';
import { Association } from '@urbit/api/metadata';
import React, { ReactElement, useCallback, useRef } from 'react';
import { Link, Route, RouteComponentProps, Switch } from 'react-router-dom';
import { resourceFromPath } from '~/logic/lib/group';
import { useHashLink } from '~/logic/lib/useHashLink';
import { ModalOverlay } from '~/views/components/ModalOverlay';
import { SidebarItem } from '~/views/landscape/components/SidebarItem';
import { DeleteGroup } from './DeleteGroup';
import { GroupSettings } from './GroupSettings/GroupSettings';
import { Participants } from './Participants';

export function PopoverRoutes(
  props: {
    baseUrl: string;
    group: Group;
    association: Association;
  } & RouteComponentProps
): ReactElement {
  const relativeUrl = (url: string) => `${props.baseUrl}/popover${url}`;
  const innerRef = useRef(null);

  const onDismiss = useCallback(() => {
    props.history.push(props.baseUrl);
  }, [props.history.push, props.baseUrl]);

  useHashLink();

  const groupSize = props.group.members.size;
  const ship = resourceFromPath(props.association?.group ?? '/ship/~zod/group').ship;
  const owner = deSig(ship) === window.ship;

  const admin = props.group?.tags?.role?.admin.has(window.ship) || false;

  return (
    <Switch>
      <Route
        path={[relativeUrl('/:view'), relativeUrl('')]}
        render={(routeProps) => {
          const { view } = routeProps.match.params;
          return (
            <ModalOverlay
              spacing={[3,5,7]}
              ref={innerRef}
              border={1}
              borderColor="washedGray"
              borderRadius={1}
              width="100%"
              height="100%"
              bg="white"
              dismiss={onDismiss}
            >
              <Box
                display="grid"
                gridTemplateRows={['32px 1fr', '100%']}
                gridTemplateColumns={['100%', '250px 1fr']}
                height="100%"
                width="100%"
              >
                <Col
                  display={view ? ['none', 'flex'] : 'flex'}
                  borderRight={1}
                  borderRightColor="washedGray"
                >
                  <Text my={4} mx={3} fontWeight="600" fontSize={2}>Group Settings</Text>
                  <Col gapY={2}>
                    <Text my={1} mx={3} gray>Group</Text>
                    <SidebarItem
                      icon='Notifications'
                      to={relativeUrl('/settings#notifications')}
                      text="Notifications"
                    />
                    <SidebarItem
                      icon="Users"
                      to={relativeUrl('/participants')}
                      text="Participants"
                      selected={view === 'participants'}
                    ><Text gray>{groupSize}</Text>
                    </SidebarItem>
                    { admin && (
                      <>
                        <Box pt={3} mb={1} mx={3}>
                          <Text gray>Administration</Text>
                        </Box>
                        <SidebarItem
                          icon="Groups"
                          to={relativeUrl('/settings#group-details')}
                          text="Group Details"
                        />
                        <SidebarItem
                          icon="Dashboard"
                          to={relativeUrl('/settings#channels')}
                          text="Channel Management"
                        />
                        { owner && (
                        <SidebarItem
                          icon="Server"
                          to={relativeUrl('/settings#feed')}
                          text="Group Feed"
                        />)}

                      </>
                    )}
                    <DeleteGroup owner={owner} association={props.association} />
                  </Col>
                </Col>
                <Box
                  gridArea={'1 / 1 / 2 / 2'}
                  p={2}
                  display={['auto', 'none']}
                >
                  <Link to={view ? relativeUrl('') : props.baseUrl}>
                    <Text>{'<- Back'}</Text>
                  </Link>
                </Box>
                <Box overflow="hidden">
                  {view === 'settings' && (
                    <GroupSettings
                      baseUrl={`${props.baseUrl}/popover`}
                      group={props.group}
                      association={props.association}
                    />
                  )}
                  {view === 'participants' && (
                    <Participants
                      group={props.group}
                      association={props.association}
                    />
                  )}
                </Box>
              </Box>
            </ModalOverlay>
          );
        }}
      />
    </Switch>
  );
}

{'fraction_non_alphanumeric': 0.13090695626651014, 'fraction_numerical': 0.009392427355444672, 'mean_word_length': 1.231877729257642, 'pattern_counts': {'":': 0, '<': 85, '<?xml version=': 0, '>': 89, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4331828', 'n_tokens_mistral': 2670, 'n_tokens_neox': 2443, 'n_words': 458}