Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into fix/keyboard-command
Browse files Browse the repository at this point in the history
  • Loading branch information
pavanjoshi914 committed Oct 23, 2023
2 parents 261ffb9 + 47edecf commit 03f42a7
Show file tree
Hide file tree
Showing 219 changed files with 6,926 additions and 4,514 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/translations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Check Translation Changes

on:
pull_request:
paths:
- "src/i18n/locales/en/translation.json"
types:
- opened
- synchronize

jobs:
check_source_translation_file:
name: Check source translation file for changes
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
fetch-depth: 2 # Fetch the base commit as well

- uses: actions/setup-node@v3

- name: Check source translation file for changes
run: |
file_path="src/i18n/locales/en/translation.json"
branch_name=${{ github.base_ref }}
url="https://api.github.com/repos/${{ github.repository }}/contents/${file_path}?ref=${branch_name}"
BASE_CONTENT=$(curl -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" $url | jq -c -r .content | base64 -d | jq -c .)
node scripts/check-changed-translations.js "$BASE_CONTENT"
35 changes: 34 additions & 1 deletion create-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,39 @@

# Extract version from package.json
VERSION=$(node -pe "require('./package.json').version")
NODE_ENV=production

if [ -z ${ALBY_OAUTH_CLIENT_ID_CHROME+x} ];
then
echo "OAuth client id for Chrome:"
read ALBY_OAUTH_CLIENT_ID_CHROME
fi

if [ -z ${ALBY_OAUTH_CLIENT_SECRET_CHROME+x} ];
then
echo "OAuth client secret for Chrome:"
read ALBY_OAUTH_CLIENT_SECRET_CHROME
fi

if [ -z ${ALBY_OAUTH_CLIENT_ID_FIREFOX+x} ];
then
echo "OAuth client id for Firefox:"
read ALBY_OAUTH_CLIENT_ID_FIREFOX
fi

if [ -z ${ALBY_OAUTH_CLIENT_SECRET_FIREFOX+x} ];
then
echo "OAuth client secret for Firefox:"
read ALBY_OAUTH_CLIENT_SECRET_FIREFOX
fi

if [ -z ${ALBY_API_URL+x} ];
then
ALBY_API_URL="https://api.getalby.com"
fi

echo "Creating the build for v$VERSION"
yarn build

echo "Creating zip packages for v$VERSION"
cd dist/production
Expand Down Expand Up @@ -38,4 +71,4 @@ echo "Created alby-opera-v$VERSION.crx (SHA512: $SHA)"

echo "done!"

cd ../../../
cd ../../../
16 changes: 9 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lightning-browser-extension",
"version": "3.1.1",
"version": "3.3.0",
"description": "Lightning browser extension",
"private": true,
"repository": "https://github.com/bumi/lightning-browser-extension.git",
Expand All @@ -21,7 +21,7 @@
"build:firefox": "NODE_ENV=production TARGET_BROWSER=firefox webpack",
"build:opera": "NODE_ENV=production TARGET_BROWSER=opera webpack",
"build": "yarn build:chrome && yarn build:firefox && yarn build:opera",
"package": "yarn build && ./create-packages.sh",
"package": "./create-packages.sh",
"lint": "yarn lint:js && yarn tsc:compile && yarn format:fix",
"lint:js": "eslint src --ext .js,.jsx,.ts,.tsx --max-warnings 0",
"lint:js:fix": "eslint src --ext .js,.jsx,.ts,.tsx --fix",
Expand All @@ -35,19 +35,20 @@
"prepare": "husky install"
},
"dependencies": {
"@bitcoin-design/bitcoin-icons-react": "^0.1.9",
"@bitcoin-design/bitcoin-icons-react": "^0.1.10",
"@bitcoinerlab/secp256k1": "^1.0.5",
"@getalby/sdk": "^2.2.3",
"@headlessui/react": "^1.7.16",
"@lightninglabs/lnc-web": "^0.2.4-alpha",
"@noble/curves": "^1.1.0",
"@noble/secp256k1": "^2.0.0",
"@scure/bip32": "^1.3.1",
"@scure/bip39": "^1.2.1",
"@scure/btc-signer": "^0.5.1",
"@tailwindcss/forms": "^0.5.4",
"@vespaiach/axios-fetch-adapter": "^0.3.0",
"axios": "^0.27.2",
"bech32": "^2.0.0",
"bitcoinjs-lib": "^6.1.0",
"bolt11": "^1.4.1",
"crypto-js": "^4.1.1",
"dayjs": "^1.11.9",
Expand All @@ -66,12 +67,12 @@
"react": "^18.2.0",
"react-confetti": "^6.1.0",
"react-dom": "^18.2.0",
"react-hot-toast": "^2.4.1",
"react-i18next": "^12.3.1",
"react-loading-skeleton": "^3.3.1",
"react-modal": "^3.16.1",
"react-qr-code": "^2.0.12",
"react-router-dom": "^6.14.2",
"react-toastify": "^9.1.3",
"slip77": "^0.2.0",
"stream": "^0.0.2",
"tailwindcss": "^3.3.3",
Expand Down Expand Up @@ -125,8 +126,8 @@
"jest-webextension-mock": "^3.8.9",
"lint-staged": "^13.3.0",
"mini-css-extract-plugin": "^2.7.6",
"msw": "^1.2.3",
"postcss": "^8.4.28",
"msw": "^1.3.1",
"postcss": "^8.4.31",
"postcss-cli": "^10.1.0",
"postcss-loader": "^7.3.3",
"pptr-testing-library": "^0.7.0",
Expand All @@ -135,6 +136,7 @@
"puppeteer": "^21.0.3",
"stream-browserify": "^3.0.0",
"swc-loader": "^0.2.3",
"tailwindcss-3d": "^1.0.0",
"terser-webpack-plugin": "^5.3.9",
"tsconfig-paths-webpack-plugin": "^4.1.0",
"typescript": "^5.2.2",
Expand Down
32 changes: 32 additions & 0 deletions scripts/check-changed-translations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const fs = require("fs");

const previousData = JSON.parse(process.argv[2]);

const currentContent = fs.readFileSync(
"src/i18n/locales/en/translation.json",
"utf8"
);

const currentData = JSON.parse(currentContent);

function compareObjects(obj1, obj2, parentPath = "") {
for (const key in obj1) {
if (obj1.hasOwnProperty(key)) {
if (typeof obj1[key] === "object" && typeof obj2[key] === "object") {
compareObjects(
obj1[key],
obj2[key],
parentPath ? `${parentPath}.${key}` : key
);
} else if (obj1[key] !== obj2[key] && obj2[key] !== undefined) {
const title = `Translation source ${parentPath}.${key} has changed`;
const message = `Consider running \`node scripts/remove-outdated-translations.js ${parentPath}.${key}\` to reset existing translations.`;
console.log(
`::warning file=src/i18n/locales/en/translation.json,line=1,title=${title}::${message}`
);
}
}
}
}

compareObjects(previousData, currentData);
67 changes: 67 additions & 0 deletions scripts/remove-outdated-translations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
const fs = require("fs");
const glob = require("glob");
const path = require("path");

const keyToUpdate = process.argv[2]; // Get the key to update from command line argument

if (!keyToUpdate) {
console.error("Please provide the key to update as a command line argument.");
process.exit(1);
}

function deleteKey(obj, nestedKey) {
const keys = nestedKey.split(".");
let currentObj = obj;
let foundAndUpdated = false;

for (let i = 0; i < keys.length; i++) {
const key = keys[i];

if (i === keys.length - 1 && currentObj.hasOwnProperty(key)) {
delete currentObj[key];
foundAndUpdated = true;
} else if (
currentObj.hasOwnProperty(key) &&
typeof currentObj[key] === "object"
) {
currentObj = currentObj[key];
} else {
// Key doesn't exist, break out of loop
break;
}
}

return foundAndUpdated;
}

const startDirectory = path.join(__dirname, "..", "src", "i18n", "locales");

// Use glob to find files matching the pattern
const filesPattern = path.join(startDirectory, "**", "translation.json");
glob(filesPattern, (err, files) => {
if (err) {
console.error("Error while searching for files:", err);
process.exit(1);
}

files.forEach((filePath) => {
const isEnglishFile = filePath.includes(path.sep + "en" + path.sep); // Assuming 'en' is the English folder
if (isEnglishFile) return;

try {
const data = fs.readFileSync(filePath, "utf8");
const jsonData = JSON.parse(data);

const language = filePath
.split(path.sep + "locales" + path.sep)[1]
.split(path.sep)[0];

if (deleteKey(jsonData, keyToUpdate)) {
fs.writeFileSync(filePath, JSON.stringify(jsonData, null, 2));
console.log(`✅ ${language}`);
}
} catch (error) {
console.error(`Error processing ${filePath}: ${error}`);
}
});
});
19 changes: 8 additions & 11 deletions src/app/components/AccountDetailLayout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,17 @@ function AccountDetailLayout() {
return (
<>
<Header
title={t("title1")}
headerLeft={
<IconButton
onClick={back}
icon={<CaretLeftIcon className="w-4 h-4" />}
/>
}
/>
{account && (
<div className="border-b border-gray-200 dark:border-neutral-700 bg-white dark:bg-surface-01dp p-4">
<div className="flex-row justify-center space-x-2 flex items-center">
>
{account && (
<div className="flex-row justify-center space-x-2 flex items-center">
<Avatar
size={32}
size={24}
url={account?.avatarUrl}
name={account?.id || ""}
/>
Expand All @@ -50,12 +48,11 @@ function AccountDetailLayout() {
>
{account.name}
</h2>
<span>/</span>
<span>{t("title1")}</span>
</div>
<div className="flex-row justify-center flex items-center text-gray-500 text-sm dark:text-neutral-500">
{account.connector}
</div>
</div>
)}
)}
</Header>
<Outlet />
</>
);
Expand Down
12 changes: 7 additions & 5 deletions src/app/components/Avatar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { useEffect, useRef } from "react";
import { generateSvgGAvatar } from "~/app/components/Avatar/generator";
import { classNames } from "~/app/utils";

type Props = {
name: string;
size: number;
url?: string;
className?: string;
};

const Avatar = (props: Props) => {
Expand All @@ -20,6 +22,7 @@ const Avatar = (props: Props) => {
const AvatarImage = (props: Props) => {
return (
<div
className={classNames("translate-z-0", props.className ?? "")}
style={{
width: `${props.size}px`,
height: `${props.size}px`,
Expand Down Expand Up @@ -48,11 +51,10 @@ const AvatarSVG = (props: Omit<Props, "url">) => {

return (
<svg
className="rounded-full overflow-hidden"
style={{
transform:
"translateZ(0)" /* Forced GPU render to avoid ugly borders when switching accounts */,
}}
className={classNames(
"rounded-full overflow-hidden translate-z-0",
props.className ?? ""
)}
ref={svgRef}
width={props.size}
height={props.size}
Expand Down
14 changes: 7 additions & 7 deletions src/app/components/Badge/index.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { useTranslation } from "react-i18next";
import { classNames } from "~/app/utils";

type Props = {
label: "budget" | "auth" | "imported";
color: string;
textColor: string;
small?: boolean;
className: string;
};

export default function Badge({ label, color, textColor, small }: Props) {
export default function Badge({ label, className }: Props) {
const { t: tComponents } = useTranslation("components", {
keyPrefix: "badge",
});

return (
<span
className={`inline-block leading-none rounded-full font-medium mr-2 py-1 bg-${color} text-${textColor} ${
!small ? "px-2 text-xs" : "px-1.5 text-xxxs"
}`}
className={classNames(
"inline-block leading-none rounded-full font-medium mr-2 py-1 px-2 text-xs",
className
)}
>
{tComponents(`label.${label}`)}
</span>
Expand Down
15 changes: 3 additions & 12 deletions src/app/components/BadgesList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,20 @@ export default function BadgesList({ allowance }: Props) {
if (allowance.remainingBudget > 0) {
badges.push({
label: "budget",
color: "green-bitcoin",
textColor: "white",
className: "bg-blue-500 text-white",
});
}
if (allowance.lnurlAuth) {
badges.push({
label: "auth",
color: "green-bitcoin",
textColor: "white",
className: "bg-green-bitcoin text-white",
});
}

return (
<>
{badges?.map((b) => {
return (
<Badge
key={b.label}
label={b.label}
color={b.color}
textColor={b.textColor}
/>
);
return <Badge key={b.label} label={b.label} className={b.className} />;
})}
</>
);
Expand Down
Loading

0 comments on commit 03f42a7

Please sign in to comment.