This repository has been archived by the owner on Feb 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Jasti Sri Radhe Shyam <[email protected]>
- Loading branch information
1 parent
cde28bb
commit 345b797
Showing
17 changed files
with
246 additions
and
21 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
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
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
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 |
---|---|---|
|
@@ -20,3 +20,4 @@ | |
pub mod contract; | ||
pub mod frontend; | ||
pub mod gist; | ||
pub mod version; |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use actix_web::{ | ||
body::BoxBody, | ||
HttpResponse, | ||
}; | ||
|
||
pub use sandbox::VersionListResult; | ||
|
||
pub async fn route_version_list() -> HttpResponse<BoxBody> { | ||
let formatting_result = "[\"1.0.0\"]".to_string(); | ||
// let formatting_result = serde_json::to_string(&result).unwrap(); | ||
HttpResponse::Ok().append_header(("Content-Type","application/json")).body(formatting_result) | ||
} |
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
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
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import Common from '@paritytech/commontypes'; | ||
|
||
export type versionListApiResponse = | ||
| { | ||
type: 'OK'; | ||
payload: Common.VersionListResult; | ||
} | ||
| { | ||
type: 'NETWORK_ERROR'; | ||
} | ||
| { | ||
type: 'SERVER_ERROR'; | ||
payload: { status: number }; | ||
}; | ||
|
||
export type Config = { | ||
versionListUrl: string; | ||
}; | ||
|
||
const mapResponse = async (response: Response): Promise<versionListApiResponse> => | ||
response.status === 200 | ||
? { | ||
type: 'OK', | ||
payload: await response.json(), | ||
} | ||
: { | ||
type: 'SERVER_ERROR', | ||
payload: { status: response.status }, | ||
}; | ||
|
||
export const versionListRequest = ( | ||
config: Config, | ||
): Promise<versionListApiResponse> => { | ||
const opts: RequestInit = { | ||
method: 'GET', | ||
mode: 'cors', | ||
credentials: 'same-origin', | ||
headers: { 'Content-Type': 'application/json' }, | ||
}; | ||
|
||
return fetch(config.versionListUrl || '', opts) | ||
.then(mapResponse) | ||
.catch(() => ({ type: 'NETWORK_ERROR' })); | ||
}; |
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
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { MenuElementWrapper } from '@paritytech/components/'; | ||
import { ReactElement, useContext } from 'react'; | ||
import { AppContext } from '~/context/app/'; | ||
import { Dispatch, State } from '~/context/app/reducer'; | ||
|
||
export const VersionsSubmenu = (): ReactElement => { | ||
const [state, dispatch]: [State, Dispatch] = useContext(AppContext); | ||
|
||
return ( | ||
<div className="w-56"> | ||
<h2 className="px-4 pt-1 pb-2">Supported Versions</h2> | ||
{state.versionList.map((version) => ( | ||
<MenuElementWrapper> | ||
{version} | ||
</MenuElementWrapper> | ||
))} | ||
</div> | ||
); | ||
}; |
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
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
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
Oops, something went wrong.