Skip to content

Commit

Permalink
Ignore Wrong Version Manifest & Make Category text include all levels
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuqi Zhang committed May 4, 2024
1 parent 894101a commit 8d76d29
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/common/store/layers.store.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const useLayersStore = createWithEqualityFn(
setCategoryLayer: categoryLayer => {
set(prev => {
const dwgLabels =
prev.textLayers.find(t => t.name === categoryLayer)?.textList?.map(t => t.value.toLowerCase().trim()) || [];
prev.textLayers.filter(t => t.name === categoryLayer).flatMap(t => t?.textList?.map(t => t.value.toLowerCase().trim())).filter(hasValueAndUnique) || [];
const dwgMap = {};
dwgLabels.forEach(label => (dwgMap[label] = PLACES_PREVIEW.DEFAULT_IMDF_CATEGORY));
return {
Expand Down Expand Up @@ -466,3 +466,7 @@ export function convertLayersFromManifestJson(layers, allowedTextLayerNames, all
isDraft: true,
});
}

function hasValueAndUnique(value, index, array) {
return value !== undefined && array.indexOf(value) === index;
}
5 changes: 4 additions & 1 deletion src/common/store/response.store.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,12 @@ export function parseManifestJson(json) {

export const isValidManifestVersion = version => {
const manifestVersion = parseInt(version);
const { isPlacesPreview } = getFeatureFlags();

if (version === PLACES_PREVIEW.VERSION) return true;
return manifestVersion >= 2;
if (!isPlacesPreview) return manifestVersion >= 2;

return false;
};

export function getFirstMeaningfulError({ error = {} }) {
Expand Down
2 changes: 2 additions & 0 deletions src/common/translations/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ const en = {
'Feature class name must begin with an upper case or lower case character.',
'error.manifest.incorrect.version':
'Existing manifest provided is not supported. Only manifest version 2.0 or later is supported.',
'error.manifest.places.incorrect.version':
'The provided manifest is ignored due to invalid manifest version. Only manifest version "places-1.0" is supported.',
'error.manifest.invalid': 'Existing manifest provided is invalid.',
'error.network.issue.cors':
'Unable to process your request due to a network issue or CORS is enabled for your Azure Maps account and a rule needs to be added for this tool.',
Expand Down
9 changes: 8 additions & 1 deletion src/components/progress-bar/progress-bar.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { MessageBar, MessageBarType } from '@fluentui/react';
import { useCompletedSteps, useProgressBarSteps, useProgressBarStore } from 'common/store';
import { useEffect, useMemo } from 'react';
import { getFeatureFlags } from 'utils';
import { useTranslation } from 'react-i18next';
import { useLocation } from 'react-router-dom';
import ProgressBarButton from './progress-bar-button';
Expand All @@ -18,6 +19,7 @@ const progressBarStoreSelector = s => [
export const ProgressBar = () => {
const { t } = useTranslation();
const { pathname } = useLocation();
const { isPlacesPreview } = getFeatureFlags();
const completedSteps = useCompletedSteps();
const [
isIncorrectManifestVersionErrorShown,
Expand Down Expand Up @@ -48,11 +50,16 @@ export const ProgressBar = () => {
return (
<>
<div className={errorContainer}>
{isIncorrectManifestVersionErrorShown && (
{isIncorrectManifestVersionErrorShown && !isPlacesPreview &&(
<MessageBar messageBarType={MessageBarType.warning} isMultiline onDismiss={hideIncorrectManifestVersionError}>
{t('error.manifest.incorrect.version')}
</MessageBar>
)}
{isIncorrectManifestVersionErrorShown && isPlacesPreview &&(
<MessageBar messageBarType={MessageBarType.warning} isMultiline onDismiss={hideIncorrectManifestVersionError}>
{t('error.manifest.places.incorrect.version')}
</MessageBar>
)}
{isInvalidManifestErrorShown && (
<MessageBar messageBarType={MessageBarType.warning} isMultiline onDismiss={hideInvalidManifestError}>
{t('error.manifest.invalid')}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/layers/units/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const Units = () => {
]);

const texts = useMemo(() => {
return textLayers.find(t => t.name === categoryLayer)?.textList?.map(t => t.value) || [];
return textLayers.filter(t => t.name === categoryLayer).flatMap(t => t?.textList?.map(t => t.value.toLowerCase().trim())).filter(t => t !== undefined) || [];
}, [categoryLayer, textLayers]);

useEffect(() => {
Expand Down

0 comments on commit 8d76d29

Please sign in to comment.