Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show a message on top of RPC pages when the RPC URL is not input #1014

Merged
merged 3 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@creit.tech/stellar-wallets-kit": "^0.8.2",
"@ledgerhq/hw-app-str": "^6.28.6",
"@ledgerhq/hw-transport-webusb": "^6.28.6",
"@stellar/design-system": "^2.0.0-beta.15",
"@stellar/design-system": "^2.0.0-beta.16",
"@stellar/stellar-sdk": "^12.2.0",
"@stellar/stellar-xdr-json-web": "^0.0.1",
"@tanstack/react-query": "^5.54.1",
Expand Down
21 changes: 20 additions & 1 deletion src/app/(sidebar)/endpoints/[[...pages]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
CopyText,
Icon,
Input,
Notification,
Text,
Textarea,
} from "@stellar/design-system";
Expand Down Expand Up @@ -541,7 +542,13 @@ export default function Endpoints() {
return `${baseUrl}${searchParamString ? `?${searchParamString}` : ""}`;
// Not including RegEx const
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [endpointNetwork.horizonUrl, params, urlParams, urlPath]);
}, [
endpointNetwork.horizonUrl,
endpointNetwork.rpcUrl,
params,
urlParams,
urlPath,
]);

useEffect(() => {
setRequestUrl(buildUrl());
Expand Down Expand Up @@ -631,6 +638,7 @@ export default function Endpoints() {
</InputSideElement>
}
/>

<Button
size="md"
variant="secondary"
Expand Down Expand Up @@ -902,6 +910,17 @@ export default function Endpoints() {
<Card>
<form className="PageBody" onSubmit={handleSubmit}>
{renderEndpointUrl()}

{/* display a missing request url banner if requestUrl is empty */}
{!requestUrl ? (
<Notification
title={`Set a ${endpointNetwork.label} RPC URL in order to submit`}
icon={<Icon.AlertTriangle />}
variant="warning"
isFilled
/>
) : null}

{renderFields()}
</form>
</Card>
Expand Down
7 changes: 7 additions & 0 deletions src/components/NetworkSelector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import "./styles.scss";

export const NetworkSelector = () => {
const {
endpoints,
network,
isDynamicNetworkSelect,
selectNetwork,
Expand All @@ -28,6 +29,8 @@ export const NetworkSelector = () => {
const [isDropdownActive, setIsDropdownActive] = useState(false);
const [isDropdownVisible, setIsDropdownVisible] = useState(false);

const { updateNetwork } = endpoints;

const initialCustomState = {
horizonUrl: network.id === "custom" ? network.horizonUrl : "",
rpcUrl: network.id === "custom" ? network.rpcUrl : "",
Expand Down Expand Up @@ -194,6 +197,10 @@ export const NetworkSelector = () => {
const latestData = getData();

selectNetwork(latestData);

// also update the network setting for endpoints
updateNetwork(latestData);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added this to update its global endpoints network setting so that users would see the change right away vs. refresh the page to see the updated endpoint


setCustomNetwork(
networkData.id === "custom" ? customNetwork : initialCustomState,
);
Expand Down
28 changes: 6 additions & 22 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1063,10 +1063,10 @@
"@stablelib/random" "^1.0.2"
"@stablelib/wipe" "^1.0.1"

"@stellar/design-system@^2.0.0-beta.15":
version "2.0.0-beta.15"
resolved "https://registry.yarnpkg.com/@stellar/design-system/-/design-system-2.0.0-beta.15.tgz#431976a02faf29fa6e671b78e7ddb6c8cc1d73f4"
integrity sha512-jISw5zR/WCvbQspFe+TyuipoHDYAO7PQdlfu6Wpqmc4Gvc6g5O2hhbthn6mtF+wlsv6X3oz0Un6+FWPFnUVKiQ==
"@stellar/design-system@^2.0.0-beta.16":
version "2.0.0-beta.16"
resolved "https://registry.yarnpkg.com/@stellar/design-system/-/design-system-2.0.0-beta.16.tgz#a65d9d4d9231deb9b152c01276ceb6f3c9581bb8"
integrity sha512-mcMeOYaSdFJlSlx4C/To6UnJpKHy/J285SAmJILWr1NSfE/IwdIB+v2wKawPBNjEJ+mJpS1mc76vhPnFZzVCAA==
dependencies:
"@floating-ui/dom" "^1.6.3"
bignumber.js "^9.1.2"
Expand Down Expand Up @@ -5368,16 +5368,7 @@ string-argv@~0.3.2:
resolved "https://registry.yarnpkg.com/string-argv/-/string-argv-0.3.2.tgz#2b6d0ef24b656274d957d54e0a4bbf6153dc02b6"
integrity sha512-aqD2Q0144Z+/RqG52NeHEkZauTAUWJO8c6yTftGJKO3Tja5tUgIfmIl6kExvhtxSDP7fXB6DvzkfMpCd/F3G+Q==

"string-width-cjs@npm:string-width@^4.2.0":
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"

string-width@^4.1.0, string-width@^4.2.0:
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand Down Expand Up @@ -5457,14 +5448,7 @@ string_decoder@^1.1.1:
dependencies:
safe-buffer "~5.2.0"

"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"

strip-ansi@^6.0.0, strip-ansi@^6.0.1:
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
Expand Down