Skip to content

Commit 396c670

Browse files
authored
Merge pull request #619 from mapswipe/fix/tile-server-url-validations
Fix validation for imagery url
2 parents 2616fed + 6bf6490 commit 396c670

File tree

5 files changed

+43
-18
lines changed

5 files changed

+43
-18
lines changed

firebase/functions/.eslintrc.js

+5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ module.exports = {
2626
'promise',
2727
],
2828
rules: {
29+
'@typescript-eslint/no-unnecessary-condition': 'warn',
30+
'@typescript-eslint/no-unused-vars': 1,
31+
'@typescript-eslint/no-use-before-define': 1,
32+
'@typescript-eslint/no-shadow': ['error'],
33+
2934
'max-len': ['error', 200],
3035
'indent': ['error', 4],
3136
'quotes': ['error', 'single'],

firebase/functions/tsconfig.json

+12
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,19 @@
55
"noUnusedLocals": true,
66
"outDir": "lib",
77
"sourceMap": true,
8+
89
"strict": true,
10+
"alwaysStrict": true,
11+
"strictNullChecks": true,
12+
"noUncheckedIndexedAccess": true,
13+
"noFallthroughCasesInSwitch": true,
14+
"noImplicitOverride": true,
15+
"noImplicitAny": true,
16+
"noImplicitReturns": true,
17+
"noImplicitThis": true,
18+
"noUnusedLocals": true,
19+
"noUnusedParameters": true,
20+
921
"target": "es2017",
1022

1123
"noFallthroughCasesInSwitch": true,

manager-dashboard/app/components/TileServerInput/index.tsx

+15-11
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,22 @@ export const tileServerDefaultCredits: Record<TileServerType, string> = {
5959
};
6060

6161
function imageryUrlCondition(value: string | null | undefined) {
62-
if (value && (
63-
(
64-
!value.includes('{z}')
65-
|| !value.includes('{x}')
66-
|| (!value.includes('{y}') && !value.includes('{-y}'))
67-
) || (
68-
!value.includes('{quad_key}')
69-
)
70-
)) {
71-
return 'Imagery url must contain {x}, {y} (or {-y}) & {z} placeholders or {quad_key} placeholder.';
62+
if (!value) {
63+
return undefined;
7264
}
73-
return undefined;
65+
66+
if (value.includes('{quad_key}')) {
67+
return undefined;
68+
}
69+
70+
if (
71+
value.includes('{z}')
72+
&& value.includes('{x}')
73+
&& (value.includes('{y}') || value.includes('{-y}'))
74+
) {
75+
return undefined;
76+
}
77+
return 'Imagery url must contain {x}, {y} (or {-y}) & {z} placeholders or {quad_key} placeholder.';
7478
}
7579

7680
type TileServerInputType = PartialForm<TileServer>;

manager-dashboard/app/views/NewProject/index.tsx

+6-4
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,9 @@ function NewProject(props: Props) {
411411
|| projectSubmissionStatus === 'projectSubmit'
412412
);
413413

414+
const tileServerBVisible = value?.projectType === PROJECT_TYPE_CHANGE_DETECTION
415+
|| value?.projectType === PROJECT_TYPE_COMPLETENESS;
416+
414417
return (
415418
<div className={_cs(styles.newProject, className)}>
416419
<div className={styles.container}>
@@ -712,7 +715,7 @@ function NewProject(props: Props) {
712715
</InputSection>
713716

714717
<InputSection
715-
heading="Tile Server A"
718+
heading={tileServerBVisible ? 'Tile Server A' : 'Tile Server'}
716719
>
717720
<TileServerInput
718721
name={'tileServer' as const}
@@ -723,10 +726,9 @@ function NewProject(props: Props) {
723726
/>
724727
</InputSection>
725728

726-
{(value?.projectType === PROJECT_TYPE_CHANGE_DETECTION
727-
|| value?.projectType === PROJECT_TYPE_COMPLETENESS) && (
729+
{tileServerBVisible && (
728730
<InputSection
729-
heading="Tile Server"
731+
heading="Tile Server B"
730732
>
731733
<TileServerInput
732734
name={'tileServerB' as const}

manager-dashboard/app/views/NewTutorial/index.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,9 @@ function NewTutorial(props: Props) {
205205
|| tutorialSubmissionStatus === 'tutorialSubmit'
206206
);
207207

208+
const tileServerBVisible = value?.projectType === PROJECT_TYPE_CHANGE_DETECTION
209+
|| value?.projectType === PROJECT_TYPE_COMPLETENESS;
210+
208211
return (
209212
<div className={_cs(styles.newTutorial, className)}>
210213
<div className={styles.container}>
@@ -307,7 +310,7 @@ function NewTutorial(props: Props) {
307310
</InputSection>
308311
)}
309312
<InputSection
310-
heading="Tile Server A"
313+
heading={tileServerBVisible ? 'Tile Server A' : 'Tile Server'}
311314
>
312315
<TileServerInput
313316
name={'tileServer' as const}
@@ -317,8 +320,7 @@ function NewTutorial(props: Props) {
317320
disabled={submissionPending}
318321
/>
319322
</InputSection>
320-
{(value?.projectType === PROJECT_TYPE_CHANGE_DETECTION
321-
|| value?.projectType === PROJECT_TYPE_COMPLETENESS) && (
323+
{tileServerBVisible && (
322324
<InputSection
323325
heading="Tile Server B"
324326
>

0 commit comments

Comments
 (0)