-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from gnosischain/dev
UI improvements
- Loading branch information
Showing
33 changed files
with
982 additions
and
467 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,9 @@ name: Create and publish docker images for the API | |
# Configures this workflow to run every time a change is pushed to the branch called `release`. | ||
on: | ||
push: | ||
branches: ['main'] | ||
branches: | ||
- main | ||
- dev | ||
tags: | ||
- v* | ||
paths: | ||
|
@@ -73,4 +75,28 @@ jobs: | |
context: api | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
|
||
eks-deployment-restart: | ||
runs-on: ubuntu-latest | ||
needs: build-and-push-image | ||
permissions: | ||
id-token: write # Required for the OIDC, see https://github.com/aws-actions/configure-aws-credentials?tab=readme-ov-file#OIDC | ||
contents: read | ||
steps: | ||
- name: configure aws credentials | ||
uses: aws-actions/[email protected] | ||
with: | ||
audience: sts.amazonaws.com | ||
role-to-assume: ${{ secrets.DEV_AWS_EKS_ROLE }} | ||
role-session-name: GitHub_to_AWS_via_FederatedOIDC | ||
aws-region: ${{ secrets.DEV_AWS_REGION }} | ||
|
||
- name: Configure kubectl for EKS | ||
run: aws eks update-kubeconfig --name ${{ secrets.DEV_AWS_EKS_CLUSTER }} --region ${{ secrets.DEV_AWS_REGION }} | ||
|
||
- name: Restart Bridge Explorer Deployment | ||
if: github.ref == 'refs/heads/dev' | ||
run: | | ||
kubectl config use-context arn:aws:eks:${{ secrets.DEV_AWS_REGION }}:${{ secrets.DEV_AWS_ACCOUNT_ID }}:cluster/${{ secrets.DEV_AWS_EKS_CLUSTER }} | ||
kubectl rollout restart deploy/${{ secrets.DEV_AWS_EKS_DEPLOYMENT_API }} -n ${{ secrets.DEV_AWS_EKS_NAMESPACE }} |
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 |
---|---|---|
|
@@ -4,7 +4,9 @@ name: Create and publish docker images for the UI | |
# Configures this workflow to run every time a change is pushed to the branch called `release`. | ||
on: | ||
push: | ||
branches: ['main'] | ||
branches: | ||
- main | ||
- dev | ||
tags: | ||
- v* | ||
paths: | ||
|
@@ -44,14 +46,50 @@ jobs: | |
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages. | ||
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository. | ||
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step. | ||
- name: Build and push Docker image | ||
- name: Dev branch - Build and push Docker image | ||
if: github.ref == 'refs/heads/dev' | ||
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 | ||
with: | ||
context: app | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
build-args: | | ||
"REACT_APP_HCAPTCHA_SITE_KEY=${{ secrets.REACT_APP_HCAPTCHA_SITE_KEY }}" | ||
"REACT_APP_FAUCET_API_URL=${{ secrets.REACT_APP_FAUCET_API_URL}}" | ||
"REACT_APP_HCAPTCHA_SITE_KEY=${{ secrets.DEV_REACT_APP_HCAPTCHA_SITE_KEY }}" | ||
"REACT_APP_FAUCET_API_URL=${{ secrets.DEV_REACT_APP_FAUCET_API_URL}}" | ||
- name: Main branch / tags - Build and push Docker image | ||
if: ( github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') ) | ||
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 | ||
with: | ||
context: app | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
build-args: | | ||
"REACT_APP_HCAPTCHA_SITE_KEY=${{ secrets.PROD_REACT_APP_HCAPTCHA_SITE_KEY }}" | ||
"REACT_APP_FAUCET_API_URL=${{ secrets.PROD_REACT_APP_FAUCET_API_URL}}" | ||
eks-deployment-restart: | ||
runs-on: ubuntu-latest | ||
needs: build-and-push-image | ||
permissions: | ||
id-token: write # Required for the OIDC, see https://github.com/aws-actions/configure-aws-credentials?tab=readme-ov-file#OIDC | ||
contents: read | ||
steps: | ||
- name: configure aws credentials | ||
uses: aws-actions/[email protected] | ||
with: | ||
audience: sts.amazonaws.com | ||
role-to-assume: ${{ secrets.DEV_AWS_EKS_ROLE }} | ||
role-session-name: GitHub_to_AWS_via_FederatedOIDC | ||
aws-region: ${{ secrets.DEV_AWS_REGION }} | ||
|
||
- name: Configure kubectl for EKS | ||
run: aws eks update-kubeconfig --name ${{ secrets.DEV_AWS_EKS_CLUSTER }} --region ${{ secrets.DEV_AWS_REGION }} | ||
|
||
- name: Restart Bridge Explorer Deployment | ||
if: github.ref == 'refs/heads/dev' | ||
run: | | ||
kubectl config use-context arn:aws:eks:${{ secrets.DEV_AWS_REGION }}:${{ secrets.DEV_AWS_ACCOUNT_ID }}:cluster/${{ secrets.DEV_AWS_EKS_CLUSTER }} | ||
kubectl rollout restart deploy/${{ secrets.DEV_AWS_EKS_DEPLOYMENT_UI }} -n ${{ secrets.DEV_AWS_EKS_NAMESPACE }} |
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,2 @@ | ||
REACT_APP_HCAPTCHA_SITE_KEY= | ||
REACT_APP_FAUCET_API_URL=http://localhost:8000/api/v1 |
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
Binary file not shown.
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
Binary file not shown.
Binary file not shown.
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 was deleted.
Oops, something went wrong.
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,77 @@ | ||
import { useEffect, useState } from "react" | ||
import { ToastContainer, toast } from "react-toastify" | ||
import "react-toastify/dist/ReactToastify.css" | ||
import axios from "axios" | ||
import logo from "./images/logo.svg" | ||
import "./css/App.css" | ||
import Loading from "./components/Loading/Loading" | ||
import Faucet from "./components/FaucetForm/Faucet" | ||
|
||
const chainName:{ [key: string]: string }= { | ||
"100": "Gnosis", | ||
"10200": "Chiado" | ||
} | ||
|
||
function App(): JSX.Element { | ||
const [chainId, setChainId] = useState("10200") | ||
const [loading, setLoading] = useState(true) | ||
const [enabledTokens, setEnabledTokens] = useState([]) | ||
const [faucetLoading, setFaucetLoading] = useState(true) | ||
|
||
const getFaucetInfo = async () => { | ||
return axios.get(`${process.env.REACT_APP_FAUCET_API_URL}/info`) | ||
} | ||
|
||
useEffect(() => { | ||
getFaucetInfo() | ||
.then((response) => { | ||
setChainId(response.data.chainId) | ||
setEnabledTokens(response.data.enabledTokens) | ||
|
||
const chain = chainName[response.data.chainId] | ||
document.title = `${chain} Faucet` | ||
document.querySelector('meta[name="description"]')?.setAttribute("content", `Faucet for ${chain} chain`) | ||
}) | ||
.catch(() => { | ||
toast.error("Network error") | ||
}) | ||
.finally(() => { | ||
setFaucetLoading(false) | ||
setLoading(false) | ||
}) | ||
}, []) | ||
|
||
const title = faucetLoading ? "FAUCET" : `${chainName[chainId]} CHAIN` | ||
const subtitle = faucetLoading | ||
? "Loading..." | ||
: (chainId === "100" ? "Faucet" : "Testnet Faucet") | ||
|
||
return ( | ||
<> | ||
<ToastContainer | ||
position="bottom-right" | ||
hideProgressBar={true} | ||
newestOnTop={false} | ||
closeOnClick={true} | ||
// pauseOnFocusLoss | ||
draggable | ||
pauseOnHover | ||
/> | ||
<div className="app-container"> | ||
<img src={logo} className="app-logo" alt="logo" /> | ||
<div className="title"> | ||
<h1>{title}</h1> | ||
<h2>{subtitle}</h2> | ||
</div> | ||
<Faucet | ||
chainId={chainId} | ||
enabledTokens={enabledTokens} | ||
setLoading={setLoading} | ||
/> | ||
</div> | ||
{loading && <Loading/>} | ||
</> | ||
) | ||
} | ||
|
||
export default App |
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,28 @@ | ||
import React, { RefObject } from "react" | ||
import HCaptcha from "@hcaptcha/react-hcaptcha" | ||
|
||
const siteKey = process.env.REACT_APP_HCAPTCHA_SITE_KEY || "10000000-ffff-ffff-ffff-000000000001" | ||
|
||
interface CaptchaProps { | ||
setCaptchaToken: (token: string) => void, | ||
windowWidth: number, | ||
captchaRef: RefObject<HCaptcha> | ||
} | ||
|
||
const Captcha: React.FC<CaptchaProps> = ({ setCaptchaToken, windowWidth, captchaRef }) => { | ||
|
||
const onVerifyCaptcha = (token: string) => { | ||
setCaptchaToken(token) | ||
} | ||
|
||
return ( | ||
<HCaptcha | ||
size={windowWidth > 500 ? "normal" : "compact"} | ||
sitekey={siteKey} | ||
onVerify={onVerifyCaptcha} | ||
ref={captchaRef} | ||
/> | ||
) | ||
} | ||
|
||
export default Captcha |
Oops, something went wrong.