diff --git a/frontend/widgets/src/QueryApi.Dashboard.jsx b/frontend/widgets/src/QueryApi.Dashboard.jsx index 8b7c30f2e..b8a166e40 100644 --- a/frontend/widgets/src/QueryApi.Dashboard.jsx +++ b/frontend/widgets/src/QueryApi.Dashboard.jsx @@ -16,8 +16,9 @@ const EXTERNAL_APP_URL = props.EXTERNAL_APP_URL || "https://queryapi-frontend-24ktefolwq-ew.a.run.app"; let appPath = props.isDev ? "dev-App" : "App"; + State.init({ - activeTab: activeTab, + activeTab: Storage.privateGet("queryapi:activeTab") || activeTab, my_indexers: [], all_indexers: [], selected_indexer: undefined, @@ -283,6 +284,20 @@ const ButtonLink = styled.a` }} `; +const previousSelectedTab = Storage.privateGet("queryapi:activeTab"); +if (previousSelectedTab && previousSelectedTab !== state.activeTab) { + State.update({ + activeTab: previousSelectedTab, + }); +} + +const selectTab = (tabName) => { + Storage.privateSet("queryapi:activeTab", tabName); + State.update({ + activeTab: tabName, + }); +}; + const indexerView = (accountId, indexerName) => { const editUrl = `https://near.org/#/${APP_OWNER}/widget/QueryApi.${appPath}?selectedIndexerPath=${accountId}/${indexerName}&view=editor-window`; const statusUrl = `https://near.org/#/${APP_OWNER}/widget/QueryApi.${appPath}?selectedIndexerPath=${accountId}/${indexerName}&view=indexer-status`; @@ -318,23 +333,10 @@ const indexerView = (accountId, indexerName) => { - - State.update({ - activeTab: "indexer-status", - }) - } - > + selectTab("indexer-status")}> View Status - - State.update({ - activeTab: "editor-window", - }) - } - > + selectTab("editor-window")}> {accountId === context.accountId ? "Edit Indexer" : "View Indexer"} @@ -350,7 +352,7 @@ return ( State.update({ activeTab: "indexers" })} + onClick={() => selectTab("indexers")} selected={state.activeTab === "indexers"} > Indexers @@ -358,7 +360,7 @@ return ( {props.view === "create-new-indexer" && ( State.update({ activeTab: "create-new-indexer" })} + onClick={() => selectTab("create-new-indexer")} selected={state.activeTab === "create-new-indexer"} > Create New Indexer @@ -369,7 +371,7 @@ return ( <> State.update({ activeTab: "editor-window" })} + onClick={() => selectTab("editor-window")} selected={state.activeTab === "editor-window"} > Indexer Editor @@ -377,7 +379,7 @@ return ( State.update({ activeTab: "indexer-status" })} + onClick={() => selectTab("indexer-status")} selected={state.activeTab === "indexer-status"} > Indexer Status @@ -390,11 +392,7 @@ return ( { - State.update({ - activeTab: "indexers", - }); - }} + onClick={() => selectTab("indexers")} > + onClick={() => { State.update({ activeTab: "create-new-indexer", selected_indexer: "", - }) - } + }); + selectTab("create-new-indexer"); + }} > Create New Indexer @@ -474,7 +473,7 @@ return ( ))} {indexerView( selected_accountId ?? state.indexers[0].accountId, - selected_indexerName ?? state.indexers[0].indexerName, + selected_indexerName ?? state.indexers[0].indexerName )}