Add back database disabled banner

This commit is contained in:
Mitchell McCaffrey 2021-08-12 11:46:03 +10:00
parent 4f049370e5
commit 1ab6ad4f13
3 changed files with 38 additions and 0 deletions

View File

@ -0,0 +1,24 @@
import { Box, Text } from "theme-ui";
import Link from "./Link";
function DatabaseDisabledMessage({ type }: { type: string }) {
return (
<Box
sx={{
textAlign: "center",
borderRadius: "2px",
gridArea: "1 / 1 / span 1 / span 3",
}}
bg="highlight"
p={1}
>
<Text as="p" variant="body2">
{type} saving is unavailable. See <Link to="/faq#database">FAQ</Link>{" "}
for more information.
</Text>
</Box>
);
}
export default DatabaseDisabledMessage;

View File

@ -8,6 +8,7 @@ import ConfirmModal from "./ConfirmModal";
import Modal from "../components/Modal"; import Modal from "../components/Modal";
import LoadingOverlay from "../components/LoadingOverlay"; import LoadingOverlay from "../components/LoadingOverlay";
import DatabaseDisabledMessage from "../components/DatabaseDisabledMessage";
import ImageDrop from "../components/image/ImageDrop"; import ImageDrop from "../components/image/ImageDrop";
@ -29,6 +30,7 @@ import { useUserId } from "../contexts/UserIdContext";
import { useAssets } from "../contexts/AssetsContext"; import { useAssets } from "../contexts/AssetsContext";
import { GroupProvider } from "../contexts/GroupContext"; import { GroupProvider } from "../contexts/GroupContext";
import { TileDragProvider } from "../contexts/TileDragContext"; import { TileDragProvider } from "../contexts/TileDragContext";
import { useDatabase } from "../contexts/DatabaseContext";
import { Map } from "../types/Map"; import { Map } from "../types/Map";
import { import {
@ -55,6 +57,8 @@ function SelectMapModal({
}: SelectMapProps) { }: SelectMapProps) {
const { addToast } = useToasts(); const { addToast } = useToasts();
const { databaseStatus } = useDatabase();
const userId = useUserId(); const userId = useUserId();
const { const {
maps, maps,
@ -274,6 +278,9 @@ function SelectMapModal({
onDragCancel={() => setIsDraggingMap(false)} onDragCancel={() => setIsDraggingMap(false)}
> >
<TilesContainer> <TilesContainer>
{databaseStatus === "disabled" && (
<DatabaseDisabledMessage type="Map" />
)}
<MapTiles <MapTiles
mapsById={mapsById} mapsById={mapsById}
onMapEdit={setEditingMapId} onMapEdit={setEditingMapId}

View File

@ -8,6 +8,7 @@ import ConfirmModal from "./ConfirmModal";
import Modal from "../components/Modal"; import Modal from "../components/Modal";
import LoadingOverlay from "../components/LoadingOverlay"; import LoadingOverlay from "../components/LoadingOverlay";
import DatabaseDisabledMessage from "../components/DatabaseDisabledMessage";
import ImageDrop from "../components/image/ImageDrop"; import ImageDrop from "../components/image/ImageDrop";
@ -34,6 +35,7 @@ import { useAssets } from "../contexts/AssetsContext";
import { GroupProvider } from "../contexts/GroupContext"; import { GroupProvider } from "../contexts/GroupContext";
import { TileDragProvider } from "../contexts/TileDragContext"; import { TileDragProvider } from "../contexts/TileDragContext";
import { useMapStage } from "../contexts/MapStageContext"; import { useMapStage } from "../contexts/MapStageContext";
import { useDatabase } from "../contexts/DatabaseContext";
import { TokenState } from "../types/TokenState"; import { TokenState } from "../types/TokenState";
import { import {
@ -54,6 +56,8 @@ function SelectTokensModal({
}: SelectTokensModalProps) { }: SelectTokensModalProps) {
const { addToast } = useToasts(); const { addToast } = useToasts();
const { databaseStatus } = useDatabase();
const userId = useUserId(); const userId = useUserId();
const { const {
tokens, tokens,
@ -277,6 +281,9 @@ function SelectTokensModal({
onDragCancel={() => setIsDraggingToken(false)} onDragCancel={() => setIsDraggingToken(false)}
> >
<TilesContainer> <TilesContainer>
{databaseStatus === "disabled" && (
<DatabaseDisabledMessage type="Token" />
)}
<TokenTiles <TokenTiles
tokensById={tokensById} tokensById={tokensById}
onTokenEdit={setEditingTokenId} onTokenEdit={setEditingTokenId}