Skip to content

Commit 37eefc6

Browse files
committed
refactor: moved to Debug component, simpler env variables
1 parent b95079c commit 37eefc6

File tree

6 files changed

+56
-62
lines changed

6 files changed

+56
-62
lines changed

web/.env.devnet.public

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# Do not enter sensitive information here.
22
export REACT_APP_DEPLOYMENT=devnet
33
export REACT_APP_KLEROS_CORE_SUBGRAPH_DEVNET=https://api.thegraph.com/subgraphs/name/kleros/kleros-v2-core-devnet
4-
export REACT_APP_DISPUTE_TEMPLATE_ARBGOERLI_SUBGRAPH_DEVNET=https://api.thegraph.com/subgraphs/name/kleros/kleros-v2-dr-devnet
5-
export REACT_APP_DEVNET_STATUS_URL=https://kleros-v2-devnet.betteruptime.com/badge
4+
export REACT_APP_DISPUTE_TEMPLATE_ARBGOERLI_SUBGRAPH_DEVNET=https://api.thegraph.com/subgraphs/name/kleros/kleros-v2-dr-devnet

web/.env.testnet.public

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# Do not enter sensitive information here.
22
export REACT_APP_DEPLOYMENT=testnet
33
export REACT_APP_KLEROS_CORE_SUBGRAPH_TESTNET=https://api.thegraph.com/subgraphs/name/kleros/kleros-v2-core-testnet-2
4-
export REACT_APP_DISPUTE_TEMPLATE_ARBGOERLI_SUBGRAPH_TESTNET=https://api.thegraph.com/subgraphs/name/kleros/kleros-v2-dr-testnet-2
5-
export REACT_APP_TESTNET_STATUS_URL=https://kleros-v2.betteruptime.com/badge
4+
export REACT_APP_DISPUTE_TEMPLATE_ARBGOERLI_SUBGRAPH_TESTNET=https://api.thegraph.com/subgraphs/name/kleros/kleros-v2-dr-testnet-2

web/src/consts/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@ export const EMAIL_REGEX = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.
1717
export const TELEGRAM_REGEX = /^@\w{5,32}$/;
1818
export const ETH_ADDRESS_REGEX = /^0x[a-fA-F0-9]{40}$/;
1919
export const ETH_SIGNATURE_REGEX = /^0x[a-fA-F0-9]{130}$/;
20+
21+
export const SERVICES_STATUS_DEVNET_URL = "https://kleros-v2-devnet.betteruptime.com/badge";
22+
export const SERVICES_STATUS_TESTNET_URL = "https://kleros-v2.betteruptime.com/badge";

web/src/layout/Header/navbar/Debug.tsx

Lines changed: 51 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
1-
import React from "react";
1+
import React, { useMemo } from "react";
22
import styled from "styled-components";
33
import { useSortitionModulePhase } from "hooks/contracts/generated";
4-
import { GIT_BRANCH, GIT_DIRTY, GIT_HASH, GIT_TAGS, GIT_URL, RELEASE_VERSION } from "consts/index";
4+
import { useToggleTheme } from "hooks/useToggleThemeContext";
5+
import {
6+
GIT_BRANCH,
7+
GIT_DIRTY,
8+
GIT_HASH,
9+
GIT_TAGS,
10+
GIT_URL,
11+
RELEASE_VERSION,
12+
SERVICES_STATUS_DEVNET_URL,
13+
SERVICES_STATUS_TESTNET_URL,
14+
} from "consts/index";
515

616
const Container = styled.div`
17+
display: flex;
18+
flex-direction: column;
19+
gap: 12px;
20+
721
label,
822
a {
923
font-family: "Roboto Mono", monospace;
@@ -13,6 +27,14 @@ const Container = styled.div`
1327
}
1428
`;
1529

30+
const StyledIframe = styled.iframe`
31+
border: none;
32+
width: 100%;
33+
height: 30px;
34+
background-color: ${({ theme }) => theme.mediumPurple};
35+
border-radius: 300px;
36+
`;
37+
1638
const Version = () => (
1739
<label>
1840
v{RELEASE_VERSION}{" "}
@@ -25,6 +47,31 @@ const Version = () => (
2547
</label>
2648
);
2749

50+
const ServicesStatus = () => {
51+
const [theme] = useToggleTheme();
52+
const deployment = process.env.REACT_APP_DEPLOYMENT ?? "testnet";
53+
let statusUrl: string;
54+
switch (deployment) {
55+
case "devnet":
56+
statusUrl = SERVICES_STATUS_DEVNET_URL;
57+
break;
58+
case "testnet":
59+
statusUrl = SERVICES_STATUS_TESTNET_URL;
60+
break;
61+
default:
62+
throw new Error(`Unknown deployment: ${deployment}`);
63+
}
64+
statusUrl = useMemo(
65+
() => (theme === "light" ? statusUrl + "?theme=light" : statusUrl + "?theme=dark"),
66+
[statusUrl, theme]
67+
);
68+
return (
69+
<label>
70+
<StyledIframe src={`${statusUrl}`} />
71+
</label>
72+
);
73+
};
74+
2875
enum Phases {
2976
staking,
3077
generating,
@@ -35,21 +82,13 @@ const Phase = () => {
3582
const { data: phase } = useSortitionModulePhase({
3683
watch: true,
3784
});
38-
return (
39-
<>
40-
{phase !== undefined && (
41-
<label>
42-
<br />
43-
phase: {Phases[phase]}
44-
</label>
45-
)}
46-
</>
47-
);
85+
return <>{phase !== undefined && <label>Phase: {Phases[phase]}</label>}</>;
4886
};
4987

5088
const Debug: React.FC = () => {
5189
return (
5290
<Container>
91+
<ServicesStatus />
5392
<Version />
5493
<Phase />
5594
</Container>

web/src/layout/Header/navbar/Menu/Help.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import Telegram from "svgs/socialmedia/telegram.svg";
1212
import { IHelp } from "..";
1313
import Debug from "../Debug";
1414
import Onboarding from "components/Popup/MiniGuides/Onboarding";
15-
import { StatusBadge } from "./StatusBadge";
1615

1716
const Container = styled.div`
1817
display: flex;
@@ -123,7 +122,6 @@ const Help: React.FC<IHelp> = ({ toggleIsHelpOpen }) => {
123122
<small>{item.text}</small>
124123
</ListItem>
125124
))}
126-
<StatusBadge />
127125
<Debug />
128126
</Container>
129127
{isOnboardingMiniGuidesOpen && <Onboarding toggleMiniGuide={toggleIsOnboardingMiniGuidesOpen} />}

web/src/layout/Header/navbar/Menu/StatusBadge.tsx

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)