diff --git a/src/Documentation/ui/DocumentationRoot.tsx b/src/Documentation/ui/DocumentationRoot.tsx index f6129b8b1..2743a1329 100644 --- a/src/Documentation/ui/DocumentationRoot.tsx +++ b/src/Documentation/ui/DocumentationRoot.tsx @@ -84,6 +84,10 @@ export function DocumentationRoot({ docPage }: { docPage?: string }): React.Reac setDeepLink(undefined); }, [deepLink, history]); + useEffect(() => { + setDeepLink(docPage); + }, [docPage]); + useEffect(() => { /** * Using setTimeout is a workaround. window.scrollTo does not work when we switch from Documentation tab to another diff --git a/src/GameOptions/ui/RemoteAPIPage.tsx b/src/GameOptions/ui/RemoteAPIPage.tsx index 9563cfc57..09115e036 100644 --- a/src/GameOptions/ui/RemoteAPIPage.tsx +++ b/src/GameOptions/ui/RemoteAPIPage.tsx @@ -1,10 +1,11 @@ import React, { useState } from "react"; -import { Button, Link, TextField, Tooltip, Typography } from "@mui/material"; +import { Button, TextField, Tooltip, Typography } from "@mui/material"; import { GameOptionsPage } from "./GameOptionsPage"; import { isValidConnectionHostname, isValidConnectionPort, Settings } from "../../Settings/Settings"; import { ConnectionBauble } from "./ConnectionBauble"; import { isRemoteFileApiConnectionLive, newRemoteFileApiConnection } from "../../RemoteFileAPI/RemoteFileAPI"; import { OptionSwitch } from "../../ui/React/OptionSwitch"; +import { DocumentationLink } from "../../ui/React/DocumentationLink"; export const RemoteAPIPage = (): React.ReactElement => { const [remoteFileApiHostname, setRemoteFileApiHostname] = useState(Settings.RemoteFileApiAddress); @@ -66,12 +67,7 @@ export const RemoteAPIPage = (): React.ReactElement => { text editor and then upload files to the home server. - - Documentation - + Documentation { subnets are very valuable in the right hands, if you can wrest them from their current owners.

- (For details about how to automate with the API, and for a working starter script, visit the IPvGO section of - the in-game{" "} - Router.toPage(Page.Documentation, { docPage: "programming/go_algorithms.md" })} - > - Bitburner Documentation) - + (For details about how to automate with the API, and for a working starter script, visit the{" "} + IPvGO section of the in-game + documentation.)

@@ -208,14 +202,9 @@ export const GoInstructionsPage = (): React.ReactElement => {

- * You can place routers and look at the board state via the "ns.go" api. For more details, go to the IPvGO - page in the{" "} - Router.toPage(Page.Documentation, { docPage: "programming/go_algorithms.md" })} - > - Bitburner Documentation - + * You can place routers and look at the board state via the "ns.go" api. For more details, go to the{" "} + IPvGO page in the documentation + tab.

* If a network surrounds a single empty node, the opponent can eventually capture it by filling in that diff --git a/src/Terminal/commands/common/deprecation.tsx b/src/Terminal/commands/common/deprecation.tsx index 4acda1b60..411c340ce 100644 --- a/src/Terminal/commands/common/deprecation.tsx +++ b/src/Terminal/commands/common/deprecation.tsx @@ -1,21 +1,16 @@ import React from "react"; import { Terminal } from "../../../Terminal"; import { Settings } from "../../../Settings/Settings"; -import { Link, Typography } from "@mui/material"; -import { Router } from "../../../ui/GameRoot"; -import { Page } from "../../../ui/Router"; +import { Typography } from "@mui/material"; +import { DocumentationLink } from "../../../ui/React/DocumentationLink"; export function sendDeprecationNotice() { return Terminal.printRaw( Running .script files is unsupported.{" "} - Router.toPage(Page.Documentation, { docPage: "migrations/ns2.md" })} - > + Here are instructions - {" "} + {" "} to migrate your scripts to .js files instead. , ); diff --git a/src/ui/React/DocumentationLink.tsx b/src/ui/React/DocumentationLink.tsx new file mode 100644 index 000000000..2439dfc8e --- /dev/null +++ b/src/ui/React/DocumentationLink.tsx @@ -0,0 +1,32 @@ +import React from "react"; +import { Link, type LinkProps } from "@mui/material"; +import { Settings } from "../../Settings/Settings"; +import { Router } from "../GameRoot"; +import { Page } from "../Router"; +import { openDocExternally } from "./Documentation"; + +export function DocumentationLink( + props: React.PropsWithChildren< + { + page: string; + } & LinkProps + >, +): React.ReactElement { + return ( + { + if (event.ctrlKey) { + openDocExternally(props.page); + return; + } + Router.toPage(Page.Documentation, { docPage: props.page }); + }} + {...props} + sx={{ cursor: "pointer", ...props.sx }} + > + {props.children} + + ); +} diff --git a/src/ui/React/NsApiDocumentationLink.tsx b/src/ui/React/NsApiDocumentationLink.tsx index 09d846e2a..43e643b60 100644 --- a/src/ui/React/NsApiDocumentationLink.tsx +++ b/src/ui/React/NsApiDocumentationLink.tsx @@ -1,29 +1,18 @@ import React from "react"; -import { Link } from "@mui/material"; -import { Settings } from "../../Settings/Settings"; -import { Router } from "../GameRoot"; -import { Page } from "../Router"; -import { defaultNsApiPage, openDocExternally } from "./Documentation"; +import { defaultNsApiPage } from "./Documentation"; +import { DocumentationLink } from "./DocumentationLink"; export function NsApiDocumentationLink(): React.ReactElement { return ( - { - if (event.ctrlKey) { - openDocExternally(defaultNsApiPage); - return; - } - Router.toPage(Page.Documentation, { docPage: defaultNsApiPage }); - }} + NS API documentation - + ); } diff --git a/src/utils/V2Modal.tsx b/src/utils/V2Modal.tsx index e0a32d92a..d3cad4f04 100644 --- a/src/utils/V2Modal.tsx +++ b/src/utils/V2Modal.tsx @@ -1,6 +1,7 @@ import { Button, Typography } from "@mui/material"; import React, { useState } from "react"; import { Modal } from "../ui/React/Modal"; +import { DocumentationLink } from "../ui/React/DocumentationLink"; let v2ModalOpen = false; @@ -20,20 +21,8 @@ export const V2Modal = (): React.ReactElement => {
{" "} You should also take a look at{" "} - - {" "} - the migration guide - {" "} - as well as{" "} - - the changelog - + the migration guide as well as{" "} + the changelog.