Skip to content

Commit

Permalink
Improve instructions when user uploads a part of a shapefile
Browse files Browse the repository at this point in the history
  • Loading branch information
underbluewaters committed Oct 8, 2024
1 parent a6b4f23 commit efcdce8
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions packages/client/src/admin/uploads/ProjectBackgroundJobContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export default function DataUploadDropzone({
message = t(`"${file.name}" is a projection file.`);
isPartOfShapefile = true;
} else if (file.name.endsWith(".shp")) {
message = t(`"${file.name}" is a bare shapefile.`);
message = t(`"${file.name}" should be a zipfile.`);
isPartOfShapefile = true;
} else if (file.name.endsWith(".xml")) {
message = t(`"${file.name}" is an XML file.`);
Expand All @@ -218,7 +218,7 @@ export default function DataUploadDropzone({
if (message) {
const description = isPartOfShapefile
? t(
`Parts of shapefiles cannot be uploaded directly. To upload a shapefile, create a .zip file with all related files (.shp, .prj, .shx, etc) and upload that zipfile.`
`Parts of shapefiles cannot be uploaded directly. To upload a shapefile, create a zipfile (.zip) with all related sidecar files (.shp, .prj, .shx, etc). At a minimum, your upload will need to contain the geometry file (.shp) and the projection file (.prj).`
)
: isUnsupportedRaster
? t(
Expand All @@ -230,6 +230,7 @@ export default function DataUploadDropzone({
return {
message,
description,
isPartOfShapefile,
};
} else {
return true;
Expand All @@ -249,16 +250,22 @@ export default function DataUploadDropzone({
for (const file of acceptedFiles) {
const supported = isUploadForSupported(file);
if (supported !== true) {
const { message, description } = supported;
const response = await confirm(message, {
description,
secondaryButtonText: "Upload anyway",
primaryButtonText: "Cancel",
});
if (!response) {
filteredFiles.push(file);
// Something weird happens when opening these confirm dialogs over and over again
await sleep(100);
const { message, description, isPartOfShapefile } = supported;
if (isPartOfShapefile) {
alert(message, {
description,
});
} else {
const response = await confirm(message, {
description,
secondaryButtonText: "Upload anyway",
primaryButtonText: "Cancel",
});
if (!response) {
filteredFiles.push(file);
// Something weird happens when opening these confirm dialogs over and over again
await sleep(100);
}
}
} else {
filteredFiles.push(file);
Expand Down

0 comments on commit efcdce8

Please sign in to comment.