-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(meshconfig): implement useMeshWideConfigState
- Loading branch information
Showing
3 changed files
with
74 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 19 additions & 3 deletions
22
plugins/lime-plugin-mesh-wide-config/src/meshConfigQueries.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,30 @@ | ||
import { useQuery } from "@tanstack/react-query"; | ||
|
||
import { getMeshWideConfig } from "plugins/lime-plugin-mesh-wide-config/src/meshConfigApi"; | ||
import { IMeshWideConfig } from "plugins/lime-plugin-mesh-wide-config/src/meshConfigTypes"; | ||
import { | ||
getMeshWideConfig, | ||
getMeshWideConfigState, | ||
} from "plugins/lime-plugin-mesh-wide-config/src/meshConfigApi"; | ||
import { | ||
IMeshWideConfig, | ||
MeshWideConfigState, | ||
} from "plugins/lime-plugin-mesh-wide-config/src/meshConfigTypes"; | ||
|
||
export function useMeshWideConfig(params) { | ||
return useQuery<IMeshWideConfig>( | ||
["lime-meshwide", "get_mesh_config"], | ||
["lime-mesh-config", "get_mesh_config"], | ||
getMeshWideConfig, | ||
{ | ||
...params, | ||
} | ||
); | ||
} | ||
|
||
export function useMeshWideConfigState(params) { | ||
return useQuery<MeshWideConfigState>( | ||
["lime-mesh-config", "get_mesh_config_state"], | ||
getMeshWideConfigState, | ||
{ | ||
...params, | ||
} | ||
); | ||
} |
28 changes: 28 additions & 0 deletions
28
plugins/lime-plugin-mesh-wide-config/src/meshConfigTypes.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,34 @@ | ||
import { MainNodeStatusType } from "plugins/lime-plugin-mesh-wide-upgrade/src/meshUpgradeTypes"; | ||
|
||
export interface IMeshWideSection { | ||
name: string; | ||
options: { [key: string]: string }; | ||
} | ||
|
||
export type IMeshWideConfig = IMeshWideSection[]; | ||
|
||
export type ConfigUpdateState = | ||
| "DEFAULT" // No transaction | ||
| "READY_FOR_UPGRADE" | ||
| "UPGRADE_SCHEDULED" | ||
| "CONFIRMATION_PENDING" | ||
| "CONFIRMED" | ||
| "ABORTED" | ||
| "ERROR"; | ||
|
||
export interface NodeMeshConfigInfo { | ||
timestamp: string; | ||
main_node: MainNodeStatusType; | ||
error: string; | ||
node_ip: string; | ||
state: ConfigUpdateState; | ||
} | ||
|
||
export type MeshWideNodeConfigInfo = { | ||
bleachTTL: number; | ||
author: string; | ||
} & NodeMeshConfigInfo; | ||
|
||
export interface MeshWideConfigState { | ||
[key: string]: MeshWideNodeConfigInfo; | ||
} |