diff --git a/admin/app/controllers/maps_controller.ts b/admin/app/controllers/maps_controller.ts index ab91f32..3ce6e18 100644 --- a/admin/app/controllers/maps_controller.ts +++ b/admin/app/controllers/maps_controller.ts @@ -13,7 +13,14 @@ export default class MapsController { constructor(private mapService: MapService) {} async index({ inertia }: HttpContext) { - return inertia.render('maps') + const baseAssetsCheck = await this.mapService.checkBaseAssetsExist() + const regionFiles = await this.mapService.listRegions() + return inertia.render('maps', { + maps: { + baseAssetsExist: baseAssetsCheck, + regionFiles: regionFiles.files, + }, + }) } async checkBaseAssets({}: HttpContext) { diff --git a/admin/inertia/components/layout/MissingBaseAssetsAlert.tsx b/admin/inertia/components/layout/MissingBaseAssetsAlert.tsx deleted file mode 100644 index b06ef53..0000000 --- a/admin/inertia/components/layout/MissingBaseAssetsAlert.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import AlertWithButton from "../AlertWithButton" - -export type MissingBaseAssetsAlertProps = { - onClickDownload?: () => Promise - loading?: boolean -} - -const MissingBaseAssetsAlert = (props: MissingBaseAssetsAlertProps) => { - return ( - { - if (props.onClickDownload) { - return props.onClickDownload() - } - } - }} - /> - ) -} - -export default MissingBaseAssetsAlert diff --git a/admin/inertia/pages/maps.tsx b/admin/inertia/pages/maps.tsx index 9bdeadb..69fe38f 100644 --- a/admin/inertia/pages/maps.tsx +++ b/admin/inertia/pages/maps.tsx @@ -3,8 +3,18 @@ import { Head, Link } from '@inertiajs/react' import MapComponent from '~/components/maps/MapComponent' import StyledButton from '~/components/StyledButton' import { IconArrowLeft } from '@tabler/icons-react' +import { FileEntry } from '../../types/files' +import AlertWithButton from '~/components/AlertWithButton' + +export default function Maps(props: { + maps: { baseAssetsExist: boolean; regionFiles: FileEntry[] } +}) { + const alertMessage = !props.maps.baseAssetsExist + ? 'The base map assets have not been installed. Please download them first to enable map functionality.' + : props.maps.regionFiles.length === 0 + ? 'No map regions have been downloaded yet. Please download some regions to enable map functionality.' + : null -export default function Maps() { return ( @@ -19,7 +29,23 @@ export default function Maps() { -
+
+ {alertMessage && ( + { + window.location.href = '/settings/maps' + }, + }} + /> + )}
diff --git a/admin/inertia/pages/settings/maps.tsx b/admin/inertia/pages/settings/maps.tsx index bddeec8..b2c1ce4 100644 --- a/admin/inertia/pages/settings/maps.tsx +++ b/admin/inertia/pages/settings/maps.tsx @@ -5,7 +5,6 @@ import StyledButton from '~/components/StyledButton' import { useModals } from '~/context/ModalContext' import StyledModal from '~/components/StyledModal' import { FileEntry } from '../../../types/files' -import MissingBaseAssetsAlert from '~/components/layout/MissingBaseAssetsAlert' import { useNotifications } from '~/context/NotificationContext' import { useState } from 'react' import api from '~/lib/api' @@ -16,6 +15,7 @@ import StyledSectionHeader from '~/components/StyledSectionHeader' import CuratedCollectionCard from '~/components/CuratedCollectionCard' import { CuratedCollectionWithStatus } from '../../../types/downloads' import ActiveDownloads from '~/components/ActiveDownloads' +import AlertWithButton from '~/components/AlertWithButton' const CURATED_COLLECTIONS_KEY = 'curated-map-collections' @@ -194,7 +194,19 @@ export default function MapsManager(props: {
{!props.maps.baseAssetsExist && ( - + downloadBaseAssets(), + }} + /> )}