mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-20 03:35:51 +00:00
Fix interactive tutorials issues
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import * as React from 'react';
|
||||
import { useLocation } from 'react-router-dom';
|
||||
// @ts-ignore
|
||||
import dynamicReact from '@markdoc/markdoc/dist/react';
|
||||
import { usePageSharedData, useTranslate } from '@portal/hooks';
|
||||
@@ -27,6 +28,7 @@ export function IndexPageItems() {
|
||||
|
||||
export function InteractiveBlock(props: { children: React.ReactNode; label: string; steps: string[] }) {
|
||||
const stepId = idify(props.label);
|
||||
const { pathname } = useLocation();
|
||||
|
||||
return (
|
||||
<div className="interactive-block" id={'interactive-' + stepId}>
|
||||
@@ -51,7 +53,7 @@ export function InteractiveBlock(props: { children: React.ReactNode; label: stri
|
||||
})}
|
||||
</ul>
|
||||
</div>
|
||||
<div className="interactive-block-ui">{dynamicReact(props.children, React, {})}</div>
|
||||
<div className="interactive-block-ui" key={pathname}>{dynamicReact(props.children, React, {})}</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -176,8 +176,8 @@ function show_error(block, message) {
|
||||
* use the generated credentials instead of the placeholder EXAMPLE_ADDR and
|
||||
* EXAMPLE_SECRET.
|
||||
*/
|
||||
const EXAMPLE_ADDR = "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe"
|
||||
const EXAMPLE_SECRET = "s████████████████████████████"
|
||||
var EXAMPLE_ADDR = "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe"
|
||||
var EXAMPLE_SECRET = "s████████████████████████████"
|
||||
function setup_generate_step() {
|
||||
|
||||
$("#generate-creds-button").click( async (event) => {
|
||||
@@ -629,6 +629,14 @@ async function show_log(block, msg) {
|
||||
block.find(".output-area").append(msg)
|
||||
}
|
||||
|
||||
function onCurrentRouteLoaded(callback) {
|
||||
const currentPath = window.location.pathname;
|
||||
window.onRouteChange(() => {
|
||||
if (window.location.pathname === currentPath) {
|
||||
callback()
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
window.onRouteChange(() => {
|
||||
disable_followup_steps()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// 1. Generate
|
||||
// 2. Connect
|
||||
// The code for these steps is handled by interactive-tutorial.js
|
||||
window.onRouteChange(() => {
|
||||
onCurrentRouteLoaded(() => {
|
||||
|
||||
const EXPLORER = $("#connect-button").data("explorer")
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// 1. Generate
|
||||
// 2. Connect
|
||||
// The code for these steps is handled by interactive-tutorial.js
|
||||
window.onRouteChange(() => {
|
||||
onCurrentRouteLoaded(() => {
|
||||
|
||||
// 3. Send AccountSet --------------------------------------------------------
|
||||
$("#send-accountset").click( async (event) => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// 1. Generate
|
||||
// 2. Connect
|
||||
// The code for these steps is handled by interactive-tutorial.js
|
||||
window.onRouteChange(() => {
|
||||
onCurrentRouteLoaded(() => {
|
||||
|
||||
// 3. Send AccountSet to Start the Freeze ------------------------------------
|
||||
// also 6. Send AccountSet to End the Freeze.
|
||||
|
||||
@@ -55,7 +55,7 @@ window.after_connect.push(async () => {
|
||||
trust_line_setup_done = true
|
||||
})
|
||||
|
||||
window.onRouteChange(() => {
|
||||
onCurrentRouteLoaded(() => {
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ function domain_to_hex(s) {
|
||||
return result.toUpperCase()
|
||||
}
|
||||
|
||||
window.onRouteChange(() => {
|
||||
onCurrentRouteLoaded(() => {
|
||||
setup_2x_generate_step()
|
||||
|
||||
$("#cold-domain-text").keyup( (event) => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// 1. Generate
|
||||
// 2. Connect
|
||||
// The code for these steps is handled by interactive-tutorial.js
|
||||
window.onRouteChange(() => {
|
||||
onCurrentRouteLoaded(() => {
|
||||
|
||||
// 3. Send AccountSet --------------------------------------------------------
|
||||
$("#send-accountset").click( async (event) => {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// 1. Connect
|
||||
// The code for these steps is handled by interactive-tutorial.js
|
||||
|
||||
window.onRouteChange(() => {
|
||||
onCurrentRouteLoaded(() => {
|
||||
|
||||
// 2. Prepare Transaction ------------------------------------------------------
|
||||
$("#prepare-button").click( async function(event) {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
// Get Credentials, Connect steps handled by the snippet
|
||||
|
||||
window.onRouteChange(() => {
|
||||
onCurrentRouteLoaded(() => {
|
||||
|
||||
// Look Up Offers --------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// 1. Generate
|
||||
// 2. Connect
|
||||
// The code for these steps is handled by interactive-tutorial.js
|
||||
window.onRouteChange(() => {
|
||||
onCurrentRouteLoaded(() => {
|
||||
const LLS_OFFSET = 75 // Expire unconfirmed transactions after about ~5 min
|
||||
|
||||
// 3. Check Sequence Number
|
||||
|
||||
Reference in New Issue
Block a user