Skip to content

Commit

Permalink
Revert "tagging: add iD Tagging scheme to advanced mode 🎉 (zbycz#131)"
Browse files Browse the repository at this point in the history
This reverts commit 5a492a7
  • Loading branch information
zbycz committed Jun 20, 2023
1 parent 44fb928 commit deb61e7
Show file tree
Hide file tree
Showing 24 changed files with 68 additions and 1,074 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"@material-ui/core": "^4.11.4",
"@material-ui/icons": "^4.11.2",
"@material-ui/lab": "4.0.0-alpha.58",
"@openstreetmap/id-tagging-schema": "^6.1.0",
"@sentry/browser": "^6.5.1",
"@sentry/node": "^6.5.1",
"@types/maplibre-gl": "^1.13.1",
Expand Down
45 changes: 12 additions & 33 deletions src/components/FeaturePanel/FeaturePanel.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { useState } from 'react';
import { Typography } from '@material-ui/core';
import { FeatureHeading } from './FeatureHeading';
import Coordinates from './Coordinates';
import { useToggleState } from '../helpers';
import { TagsTable } from './TagsTable';
import { getFullOsmappLink, getUrlOsmId } from '../../services/helpers';
import { EditDialog } from './EditDialog/EditDialog';
import {
Expand All @@ -21,8 +21,6 @@ import { EditButton } from './EditButton';
import { FeaturedTags } from './FeaturedTags';
import { getLabel } from '../../helpers/featureLabel';
import { ImageSection } from './ImageSection/ImageSection';
import { IdSchemeFields } from './IdSchemeFields';
import { TagsTable } from './TagsTable';

const featuredKeys = [
'website',
Expand Down Expand Up @@ -71,36 +69,17 @@ const FeaturePanel = () => {
setDialogOpenedWith={setDialogOpenedWith}
/>

{advanced && (
<IdSchemeFields
featuredTags={deleted ? [] : featuredTags}
feature={feature}
/>
)}
{!advanced && (
<>
{featuredTags.length && (
<Typography
variant="overline"
display="block"
color="textSecondary"
>
{t('featurepanel.other_info_heading')}
</Typography>
)}
<TagsTable
tags={tags}
center={feature.center}
except={
advanced || deleted ? [] : ['name', 'layer', ...featuredKeys]
}
onEdit={setDialogOpenedWith}
key={
getUrlOsmId(osmMeta) // we need to refresh inner state
}
/>
</>
)}
<TagsTable
tags={tags}
center={feature.center}
except={
advanced || deleted ? [] : ['name', 'layer', ...featuredKeys]
}
onEdit={setDialogOpenedWith}
key={
getUrlOsmId(osmMeta) // we need to refresh inner state
}
/>

{advanced && <Members />}

Expand Down
6 changes: 6 additions & 0 deletions src/components/FeaturePanel/FeaturedTags.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import Typography from '@material-ui/core/Typography';
import React from 'react';
import styled from 'styled-components';
import { t } from '../../services/intl';
import { FeaturedTag } from './FeaturedTag';

const Spacer = styled.div`
Expand All @@ -15,6 +17,10 @@ export const FeaturedTags = ({ featuredTags, setDialogOpenedWith }) => {
<FeaturedTag key={k} k={k} v={v} onEdit={setDialogOpenedWith} />
))}
<Spacer />

<Typography variant="overline" display="block" color="textSecondary">
{t('featurepanel.other_info_heading')}
</Typography>
</>
);
};
136 changes: 0 additions & 136 deletions src/components/FeaturePanel/IdSchemeFields.tsx

This file was deleted.

33 changes: 31 additions & 2 deletions src/components/FeaturePanel/ImageSection/ImageSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import React from 'react';
import styled from 'styled-components';
import { useFeatureContext } from '../../utils/FeatureContext';
import { FeatureImage } from './FeatureImage';
import Maki from '../../utils/Maki';
import { hasName } from '../../../helpers/featureLabel';
import { t } from '../../../services/intl';
import { SHOW_PROTOTYPE_UI } from '../../../config';
import { PoiDescription } from './PoiDescription';
import { Feature } from '../../../services/types';

const StyledIconButton = styled(IconButton)`
svg {
Expand All @@ -18,13 +20,40 @@ const StyledIconButton = styled(IconButton)`
}
`;

const PoiType = styled.div`
color: #fff;
margin: 0 auto 0 15px;
font-size: 13px;
position: relative;
width: 100%;
svg {
vertical-align: bottom;
}
span {
position: absolute;
left: 20px;
}
`;

const getSubclass = ({ layer, osmMeta, properties }: Feature) =>
properties.subclass?.replace(/_/g, ' ') ||
(layer && layer.id) || // layer.id specified only when maplibre-gl skeleton displayed
osmMeta.type;

export const ImageSection = () => {
const { feature } = useFeatureContext();
const { properties } = feature;

const poiType = hasName(feature)
? getSubclass(feature)
: t('featurepanel.no_name');

return (
<FeatureImage feature={feature} ico={properties.class}>
<PoiDescription />
<PoiType>
<Maki ico={properties.class} invert middle />
<span>{poiType}</span>
</PoiType>

{SHOW_PROTOTYPE_UI && (
<>
Expand Down
46 changes: 0 additions & 46 deletions src/components/FeaturePanel/ImageSection/PoiDescription.tsx

This file was deleted.

3 changes: 0 additions & 3 deletions src/components/utils/FeatureContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import Router from 'next/router';
import Cookies from 'js-cookie';
import { Feature } from '../../services/types';
import { useBoolState } from '../helpers';
import { publishDbgObject } from '../../utils';

export interface FeatureContextType {
feature: Feature | null;
Expand Down Expand Up @@ -44,8 +43,6 @@ export const FeatureProvider = ({
useEffect(() => {
// set feature on next.js router transition
setFeature(featureFromRouter);
publishDbgObject('feature', featureFromRouter);
publishDbgObject('schema', featureFromRouter?.schema);
}, [featureFromRouter]);

const [homepageShown, showHomepage, hideHomepage] = useBoolState(
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/featureLabel.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Feature } from '../services/types';
import { roundedToDeg } from '../utils';

const getSubclass = ({ properties, osmMeta, schema }: Feature) =>
schema?.label || properties.subclass?.replace(/_/g, ' ') || osmMeta.type;
const getSubclass = ({ properties, osmMeta }: Feature) =>
properties.subclass?.replace(/_/g, ' ') || osmMeta.type; // TODO translate ? maybe use iD editor logic (already with translations)

const getRef = (feature: Feature) =>
feature.tags.ref ? `${getSubclass(feature)} ${feature.tags.ref}` : '';
Expand Down
14 changes: 0 additions & 14 deletions src/services/__tests__/osmApi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,15 @@ import {
way,
wayFeature,
} from './osmApi.fixture';
import { intl } from '../intl';
import * as tagging from '../tagging/translations';
import * as idTaggingScheme from '../tagging/idTaggingScheme';

const osm = (item) => ({ elements: [item] });
const overpass = {
elements: [{ center: { lat: 50, lon: 14 } }],
};

// fetchFeature() fetches the translations for getSchemaForFeature()
// TODO maybe refactor it without need for intl?
intl.lang = 'en';
jest.mock('next/config', () => () => ({
publicRuntimeConfig: { languages: ['en'] },
}));

describe('fetchFeature', () => {
beforeEach(() => {
jest.clearAllMocks();
jest.spyOn(tagging, 'fetchSchemaTranslations').mockResolvedValue(true);
jest
.spyOn(idTaggingScheme, 'getSchemaForFeature')
.mockReturnValue(undefined); // this is covered in idTaggingScheme.test.ts
});

const isServer = jest.spyOn(helpers, 'isServer').mockReturnValue(true);
Expand Down
Loading

0 comments on commit deb61e7

Please sign in to comment.