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

Add rollups tab #1554

Merged
merged 53 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
1ab56c1
add rollups tab
pablomendezroyo Aug 9, 2023
04c2608
add optimism db
pablomendezroyo Sep 11, 2023
d0b57b0
bump types dep
pablomendezroyo Sep 11, 2023
75a2a82
add basic calls
pablomendezroyo Sep 11, 2023
bf33b61
stop progress
pablomendezroyo Sep 11, 2023
7b54334
add optimism calls
pablomendezroyo Sep 12, 2023
088083e
add optimism module
pablomendezroyo Sep 12, 2023
51bc7f9
implemented types and getOptimismConfig
pablomendezroyo Sep 12, 2023
0c3149d
move getPkgData to utils
pablomendezroyo Sep 12, 2023
47a012b
remove unused code
pablomendezroyo Sep 12, 2023
bd7cebb
add mock data
pablomendezroyo Sep 12, 2023
e42248a
implement setOptimismConfig
pablomendezroyo Sep 12, 2023
14abb61
fix args optimismConfigSet
pablomendezroyo Sep 12, 2023
0ab81c9
add frontend struct
pablomendezroyo Sep 12, 2023
6f6dc55
implemented frontend components
pablomendezroyo Sep 13, 2023
9856a60
Add Ethereum RPC field
dsimog01 Sep 13, 2023
dc74811
Fix mainnet RPC set
dsimog01 Sep 13, 2023
7d39a8d
Added setNewOptimismConfig function
dsimog01 Sep 14, 2023
1209384
Filled optimism config set
dsimog01 Sep 14, 2023
bfa4c21
Set env RPC to rollup tab RPC field
dsimog01 Sep 14, 2023
a25a035
test commit
pablomendezroyo Sep 15, 2023
ef4420e
Merge branch 'develop' into pablo/add-rollups-tab
pablomendezroyo Sep 18, 2023
27226dd
Merge branch 'develop' into pablo/add-rollups-tab
pablomendezroyo Sep 19, 2023
8369b6f
Fix allowed selections in OP tab
dsimog01 Sep 19, 2023
757c7fd
add modules ui to db
pablomendezroyo Sep 19, 2023
7cf37d8
add types to common
pablomendezroyo Sep 19, 2023
62cdd0d
add basic component modules to dashboard
pablomendezroyo Sep 19, 2023
83aa38d
Refactor setOpConfig
dsimog01 Sep 20, 2023
5629141
Add OP global envs
dsimog01 Sep 20, 2023
05c910e
Allow custom L1 RPC
dsimog01 Sep 20, 2023
4d05aeb
remove usage context
pablomendezroyo Sep 20, 2023
05e2984
add modules context
pablomendezroyo Sep 20, 2023
9157abf
Update development hashes
dsimog01 Sep 20, 2023
6246030
Add OP community (#1604)
dappnodedev Sep 21, 2023
40deb79
Update dropdown icon
dappnodedev Sep 21, 2023
d030bc3
Update Op instructions
dappnodedev Sep 21, 2023
04abfc3
Update op-erigon
dappnodedev Sep 21, 2023
6c11cd0
add UIX to modules dropdown
pablomendezroyo Sep 21, 2023
7e22470
add linter disable until rollups tab
pablomendezroyo Sep 21, 2023
dd4ece2
Merge branch 'develop' into pablo/add-modules-dashboard
pablomendezroyo Sep 21, 2023
bee2824
Merge branch 'develop' into pablo/add-rollups-tab
pablomendezroyo Sep 22, 2023
de878a1
Merge branch 'pablo/add-rollups-tab' into pablo/add-modules-dashboard
pablomendezroyo Sep 22, 2023
4b67218
add eventbus import
pablomendezroyo Sep 22, 2023
54a371d
add eventbus import
pablomendezroyo Sep 22, 2023
c134ad0
add rollupsmodule status value
pablomendezroyo Sep 22, 2023
9fb0bd7
fix app context import
pablomendezroyo Sep 22, 2023
ee44097
fix navbarIrtems
pablomendezroyo Sep 22, 2023
3e5cde3
Merge pull request #1601 from dappnode/pablo/add-modules-dashboard
pablomendezroyo Sep 22, 2023
370f205
remove unused navnar scss
pablomendezroyo Sep 22, 2023
d26c007
Do not use key-value pairs to store storage in brw
pablomendezroyo Sep 22, 2023
9db801f
Merge pull request #1610 from dappnode/pablo/fix-confirm
pablomendezroyo Sep 22, 2023
7bd6194
Merge branch 'develop' into pablo/add-rollups-tab
pablomendezroyo Sep 22, 2023
1b6743e
remove hashes
pablomendezroyo Sep 25, 2023
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
4 changes: 2 additions & 2 deletions packages/admin-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
},
"dependencies": {
"@dappnode/common": "^0.1.0",
"@dappnode/eventbus": "^0.1.0",
"@dappnode/dappmanager": "^0.1.0",
"@dappnode/types": "^0.1.25",
"@dappnode/eventbus": "^0.1.0",
"@dappnode/types": "^0.1.26",
"@reduxjs/toolkit": "^1.3.5",
"@types/clipboard": "^2.0.7",
"@types/node": "^18.11.18",
Expand Down
157 changes: 84 additions & 73 deletions packages/admin-ui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,102 +15,113 @@ import { Login } from "./start-pages/Login";
import { Register } from "./start-pages/Register";
import { NoConnection } from "start-pages/NoConnection";
// Types
import { Theme, UsageMode } from "types";
import { AppContextIface, Theme, UiModuleStatus } from "types";

export const UsageContext = React.createContext({
usage: "advanced",
toggleUsage: () => {}
});

export const ThemeContext = React.createContext({
export const AppContext = React.createContext<AppContextIface>({
theme: "light",
toggleTheme: () => {}
stakersModuleStatus: "enabled",
rollupsModuleStatus: "disabled",
toggleTheme: () => {},
toggleStakersModuleStatus: () => {},
toggleRollupsModuleStatus: () => {}
});

const useLocalStorage = <T extends string>(
key: string,
initialValue: T
): [T, React.Dispatch<React.SetStateAction<T>>] => {
const [storedValue, setStoredValue] = useState<T>(() => {
try {
const item = window.localStorage.getItem(key);
// Assert that either the item or initialValue is of type T
return (item as T) || initialValue;
} catch (error) {
return initialValue;
}
});

useEffect(() => {
window.localStorage.setItem(key, storedValue);
}, [key, storedValue]);

return [storedValue, setStoredValue];
};

function MainApp({ username }: { username: string }) {
// App is the parent container of any other component.
// If this re-renders, the whole app will. So DON'T RERENDER APP!
// Check ONCE what is the status of the VPN and redirect to the login page.

const [screenWidth, setScreenWidth] = useState(window.screen.width);

//const storedUsage = localStorage.getItem("usage");
const storedTheme = localStorage.getItem("theme");
//const initialUsage = storedUsage === "advanced" ? "advanced" : "basic";
const initialUsage = "advanced";
const initialTheme =
storedTheme === "light" || storedTheme === "dark" ? storedTheme : "light";

const [theme, setTheme] = useState<Theme>(initialTheme);
const [usage, setUsage] = useState<UsageMode>(initialUsage);

const toggleTheme = () => {
setTheme(curr => (curr === "light" ? "dark" : "light"));
};

const toggleUsage = () => {
setUsage(curr => (curr === "basic" ? "advanced" : "basic"));
};

useEffect(() => {
localStorage.setItem("theme", theme);
}, [theme]);

useEffect(() => {
localStorage.setItem("usage", usage);
}, [usage]);
const [screenWidth, setScreenWidth] = useState(window.innerWidth);
const [theme, setTheme] = useLocalStorage<Theme>("theme", "light");
const [stakersModuleStatus, setStakersModuleStatus] = useLocalStorage<
UiModuleStatus
>("stakersModuleStatus", "enabled");
const [rollupsModuleStatus, setRollupsModuleStatus] = useLocalStorage<
UiModuleStatus
>("rollupsModuleStatus", "disabled");

useEffect(() => {
const handleResize = () => setScreenWidth(window.innerWidth);
window.addEventListener("resize", handleResize);
return () => window.removeEventListener("resize", handleResize);
}, [screenWidth]);
}, []);

// Scroll to top on pathname change
const screenLocation = useLocation();
useEffect(() => {
window.scrollTo(0, 0);
}, [screenLocation.pathname]);

const appContext: AppContextIface = {
theme,
stakersModuleStatus,
rollupsModuleStatus,
toggleTheme: () =>
setTheme((curr: Theme) => (curr === "light" ? "dark" : "light")),
toggleStakersModuleStatus: () =>
setStakersModuleStatus((curr: UiModuleStatus) =>
curr === "enabled" ? "disabled" : "enabled"
),
toggleRollupsModuleStatus: () =>
setRollupsModuleStatus((curr: UiModuleStatus) =>
curr === "enabled" ? "disabled" : "enabled"
)
};

return (
<UsageContext.Provider value={{ usage, toggleUsage }}>
<ThemeContext.Provider value={{ theme, toggleTheme }}>
<div className="body" id={theme}>
<SideBar screenWidth={screenWidth} />
<TopBar
username={username}
theme={theme}
toggleUsage={toggleUsage}
toggleTheme={toggleTheme}
/>
<div id="main">
<ErrorBoundary>
<NotificationsMain />
</ErrorBoundary>
<Routes>
{Object.values(pages).map(({ RootComponent, rootPath }) => (
<Route
key={rootPath}
path={rootPath}
element={
<ErrorBoundary>
<RootComponent />
</ErrorBoundary>
}
/>
))}
{/* Redirection for routes with hashes */}
{/* 404 routes redirect to dashboard or default page */}
<Route path="*" element={<DefaultRedirect />} />
</Routes>
</div>

{/* Place here non-page components */}
<Welcome />
<ToastContainer />
<AppContext.Provider value={appContext}>
<div className="body" id={theme}>
<SideBar screenWidth={screenWidth} />
<TopBar username={username} appContext={appContext} />
<div id="main">
<ErrorBoundary>
<NotificationsMain />
</ErrorBoundary>
<Routes>
{/** Provide the app context only to the dashboard (where the modules switch is handled) */}
{Object.values(pages).map(({ RootComponent, rootPath }) => (
<Route
key={rootPath}
path={rootPath}
element={
<ErrorBoundary>
<RootComponent />
</ErrorBoundary>
}
/>
))}
{/* Redirection for routes with hashes */}
{/* 404 routes redirect to dashboard or default page */}
<Route path="*" element={<DefaultRedirect />} />
</Routes>
</div>
</ThemeContext.Provider>
</UsageContext.Provider>

{/* Place here non-page components */}
<Welcome />
<ToastContainer />
</div>
</AppContext.Provider>
);
}

Expand Down
128 changes: 122 additions & 6 deletions packages/admin-ui/src/__mock-backend__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,11 @@ export const otherCalls: Omit<Routes, keyof typeof namedSpacedCalls> = {
ethProvider: "http://geth.dappnode:8545",
fullnodeDomainTarget: "geth.dnp.dappnode.eth",
newFeatureIds: [
"repository",
"repository-fallback",
"system-auto-updates",
"enable-ethical-metrics",
"change-host-password"
//"repository",
//"repository-fallback",
//"system-auto-updates",
//"enable-ethical-metrics",
//"change-host-password"
]
}),
natRenewalEnable: async () => {},
Expand All @@ -252,7 +252,123 @@ export const otherCalls: Omit<Routes, keyof typeof namedSpacedCalls> = {
mail: "@example.com",
isEnabled: true
}),
disableEthicalMetrics: async () => {}
disableEthicalMetrics: async () => {},
optimismConfigGet: async () => ({
executionClients: [
{
status: "ok",
dnpName: "op-geth.dnp.dappnode.eth",
avatarUrl: "",
isInstalled: true,
isUpdated: true,
isRunning: true,
data: {
dnpName: "package",
reqVersion: "0.1.0",
semVersion: "0.1.0",
imageFile: {
hash: "QM..",
source: "ipfs",
size: 123
},
warnings: {},
signedSafe: true,
metadata: {
name: "geth.dnp.dappnode.eth",
description: "Go implementation of ethereum. Execution client",
shortDescription: "Go implementation of ethereum",
version: "0.1.0"
}
},
isSelected: true,
enableHistorical: true
},
{
status: "ok",
dnpName: "op-erigon.dnp.dappnode.eth",
avatarUrl: "",
isInstalled: true,
isUpdated: true,
isRunning: true,
data: {
dnpName: "package",
reqVersion: "0.1.0",
semVersion: "0.1.0",
imageFile: {
hash: "QM..",
source: "ipfs",
size: 123
},
warnings: {},
signedSafe: true,
metadata: {
name: "geth.dnp.dappnode.eth",
description: "Go implementation of ethereum. Execution client",
shortDescription: "Go implementation of ethereum",
version: "0.1.0"
}
},
isSelected: false,
enableHistorical: false
}
],
rollup: {
status: "ok",
dnpName: "op-node.dnp.dappnode.eth",
avatarUrl: "",
isInstalled: false,
isUpdated: false,
isRunning: true,
data: {
dnpName: "package",
reqVersion: "0.1.0",
semVersion: "0.1.0",
imageFile: {
hash: "QM..",
source: "ipfs",
size: 123
},
warnings: {},
signedSafe: true,
metadata: {
name: "geth.dnp.dappnode.eth",
description: "Go implementation of ethereum. Execution client",
shortDescription: "Go implementation of ethereum",
version: "0.1.0"
}
},
isSelected: false,
mainnetRpcUrl: ""
},
archive: {
status: "ok",
dnpName: "op-l2geth.dnp.dappnode.eth",
avatarUrl: "",
isInstalled: false,
isUpdated: false,
isRunning: true,
data: {
dnpName: "package",
reqVersion: "0.1.0",
semVersion: "0.1.0",
imageFile: {
hash: "QM..",
source: "ipfs",
size: 123
},
warnings: {},
signedSafe: true,
metadata: {
name: "geth.dnp.dappnode.eth",
description: "Go implementation of ethereum. Execution client",
shortDescription: "Go implementation of ethereum",
version: "0.1.0"
}
},
isSelected: true
}
}),
optimismConfigSet: async () => {}
};

export const calls: Routes = {
Expand Down
Loading
Loading