Skip to content

Commit abbc6f6

Browse files
Merge pull request #47 from Chia-Network/develop
Release 0.1.0
2 parents 57034d9 + d24fdcf commit abbc6f6

7 files changed

+96
-31
lines changed

.github/workflows/build-installers.yaml

+6-6
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ jobs:
6262
- name: Notarize
6363
run: |
6464
DMG_FILE=$(find ${{ github.workspace }}/dist/ -type f -name '*.dmg')
65-
npm install -g notarize-cli
66-
notarize-cli \
67-
--file="$DMG_FILE" \
68-
--bundle-id net.chia.$APP_NAME \
69-
--username "${{ secrets.APPLE_NOTARIZE_USERNAME }}" \
70-
--password "${{ secrets.APPLE_NOTARIZE_PASSWORD }}"
65+
xcrun notarytool submit \
66+
--wait \
67+
--apple-id "${{ secrets.APPLE_NOTARIZE_USERNAME }}" \
68+
--password "${{ secrets.APPLE_NOTARIZE_PASSWORD }}" \
69+
--team-id "${{ secrets.APPLE_TEAM_ID }}" \
70+
"$DMG_FILE"
7171
7272
- name: Upload Mac Installer
7373
uses: actions/upload-artifact@v3

.repo-content-updater.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pr_target_grant: develop
1+
pr_target_branch: develop
22
assign_users:
33
- TheLastCicada
44
commit_prefix: "chore: "

app-builds.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
module.exports = {
22
cadt: {
3-
tag: "1.3.9",
3+
tag: "1.3.10",
44
url: "https://github.com/Chia-Network/core-registry-cadt-ui/releases/download/{{tag}}/core-registry-cadt-ui-web-build.tar.gz",
55
},
66
climate_explorer: {
7-
tag: "1.1.11",
7+
tag: "1.1.13",
88
url: "https://github.com/Chia-Network/climate-explorer-ui/releases/download/{{tag}}/climate-explorer-ui-web-build.tar.gz",
99
},
1010
climate_tokenization_engine: {
11-
tag: "1.1.8",
11+
tag: "1.1.9",
1212
url: "https://github.com/Chia-Network/Climate-Tokenization-Engine-UI/releases/download/{{tag}}/climate-tokenization-engine-ui-web-build.tar.gz",
1313
},
1414
};

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "core-registry-ui",
3-
"version": "0.0.15",
3+
"version": "0.1.0",
44
"scripts": {
55
"start": "nf start -p 3001",
66
"electron": "electron .",

src/App.jsx

+43-17
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { ExplorerLogo } from "./components/ExplorerLogo";
66
import { TokenizationLogo } from "./components/TokenizationLogo";
77
import { Flowbite, Button, Modal } from "flowbite-react";
88
import flowbiteThemeSettings from "./flowbite.theme";
9+
import { LocaleSwitcher } from "./components/LocalSwitcher";
910

1011
const appLinks = {
1112
cadt: {
@@ -37,9 +38,36 @@ const App = () => {
3738
}, [flowbiteThemeSettings]);
3839

3940
const ActiveLogo = activeApp.logo;
40-
const TokenizationLogo = appLinks["climateTokenization"].logo;
41-
const ExplorerLogo = appLinks["climateExplorer"].logo;
42-
const CadtLogo = appLinks["cadt"].logo;
41+
42+
function getIframeOrigin(iframe) {
43+
try {
44+
const url = new URL(iframe.src);
45+
return url.origin;
46+
} catch (error) {
47+
console.error("Invalid iframe URL", error);
48+
return null;
49+
}
50+
}
51+
52+
function sendMessageToIframe(iframe, message) {
53+
const targetOrigin = getIframeOrigin(iframe);
54+
if (targetOrigin && iframe.contentWindow) {
55+
iframe.contentWindow.postMessage(message, targetOrigin);
56+
} else {
57+
console.error(
58+
"Failed to determine target origin or iframe is not available"
59+
);
60+
}
61+
}
62+
63+
const handleLocaleChange = (event) => {
64+
const message = { changeLocale: event };
65+
[cadtRef, climateExplorerRef, climateTokenizationRef].forEach((ref) => {
66+
if (ref.current) {
67+
sendMessageToIframe(ref.current, message);
68+
}
69+
});
70+
};
4371

4472
const handleSubmit = (e) => {
4573
e.preventDefault();
@@ -48,12 +76,9 @@ const App = () => {
4876
const formData = new FormData(form);
4977
const data = Object.fromEntries(formData.entries());
5078

51-
// Validation function for host
5279
const isValidHost = (host) => /^https?:\/\/.+(:\d{1,5})?$/.test(host);
53-
// Validation function for API key (adjust as needed)
5480
const isValidApiKey = (key) => key.trim() !== "";
5581

56-
// Array containing the field names, corresponding error element IDs, and validation functions
5782
const fields = [
5883
{
5984
name: "cadtRegistryHost",
@@ -180,17 +205,18 @@ const App = () => {
180205
) : (
181206
<div></div>
182207
)}
183-
184-
{validateLocalStorage() ? (
185-
<Button color="gray" onClick={handleDisconnect}>
186-
Disconnect
187-
</Button>
188-
) : (
189-
<Button color="gray" onClick={() => setShowConnect(true)}>
190-
Connect
191-
</Button>
192-
)}
193-
208+
<div className="flex gap-8 items-center">
209+
<LocaleSwitcher handleLocaleChange={handleLocaleChange} />
210+
{validateLocalStorage() ? (
211+
<Button color="gray" onClick={handleDisconnect}>
212+
Disconnect
213+
</Button>
214+
) : (
215+
<Button color="gray" onClick={() => setShowConnect(true)}>
216+
Connect
217+
</Button>
218+
)}
219+
</div>
194220
{showConnect && (
195221
<Modal show={true} onClose={() => setShowConnect(false)}>
196222
<Modal.Header>Connect to Core Registry</Modal.Header>

src/components/LocalSwitcher.jsx

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import React, { useState } from "react";
2+
import styled, { withTheme } from "styled-components";
3+
import { Dropdown } from "flowbite-react";
4+
5+
const LANGUAGE_CODES = Object.freeze({
6+
ENGLISH: "en-US",
7+
SPANISH: "es-ES",
8+
FRENCH: "fr-FR",
9+
GERMAN: "de-DE",
10+
CHINESE: "cn",
11+
});
12+
13+
const LocaleSwitcher = ({ handleLocaleChange }) => {
14+
const [currentLanguage, setCurrentLanguage] = useState(
15+
LANGUAGE_CODES["ENGLISH"]
16+
);
17+
18+
const handleChange = (value) => {
19+
setCurrentLanguage(value);
20+
handleLocaleChange(value);
21+
};
22+
return (
23+
<Dropdown
24+
label={currentLanguage}
25+
>
26+
{Object.keys(LANGUAGE_CODES).map((key) => (
27+
<Dropdown.Item
28+
key={LANGUAGE_CODES[key]}
29+
onClick={() => handleChange(LANGUAGE_CODES[key])}
30+
value={LANGUAGE_CODES[key]}
31+
>
32+
{key}
33+
</Dropdown.Item>
34+
))}
35+
</Dropdown>
36+
);
37+
};
38+
39+
export { LocaleSwitcher };

src/flowbite.theme.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
export default () => ({
22
theme: {
33
dropdown: {
4-
arrowIcon: "ml-2 h-11 w-4 items-center justify-center",
5-
content: "py-1 focus:outline-none",
4+
arrowIcon: "ml-2 w-4 self-center justify-center",
5+
content: "items-center py-1 focus:outline-none",
66
floating: {
77
animation: "transition-opacity",
88
arrow: {
@@ -23,7 +23,7 @@ export default () => ({
2323
hidden: "invisible opacity-0",
2424
item: {
2525
container: "focus:outline-none",
26-
base: "focus:outline-none flex items-center justify-start py-2 px-4 text-sm text-gray-700 cursor-pointer w-full hover:bg-gray-900 focus:outline-none dark:text-gray-200 dark:hover:bg-gray-900 focus:outline-none dark:hover:text-white dark:focus:bg-gray-600 dark:focus:text-white",
26+
base: "focus:outline-none flex items-center justify-start py-2 px-4 text-sm text-white cursor-pointer w-full hover:bg-gray-900 focus:outline-none dark:text-gray-200 dark:hover:bg-gray-900 focus:outline-none dark:hover:text-white dark:focus:bg-gray-600 dark:focus:text-white",
2727
icon: "mr-2 h-4 w-4 focus:outline-none",
2828
},
2929
style: {

0 commit comments

Comments
 (0)