Skip to content

Commit

Permalink
chore: merge master #1051
Browse files Browse the repository at this point in the history
  • Loading branch information
escapedcat committed Mar 20, 2023
2 parents 43a4091 + ca0f48a commit dd85f9a
Show file tree
Hide file tree
Showing 103 changed files with 2,713 additions and 1,654 deletions.
58 changes: 29 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lightning-browser-extension",
"version": "1.27.0",
"version": "1.28.1",
"description": "Lightning browser extension",
"private": true,
"repository": "https://github.com/bumi/lightning-browser-extension.git",
Expand Down Expand Up @@ -36,7 +36,7 @@
},
"dependencies": {
"@bitcoin-design/bitcoin-icons-react": "^0.1.9",
"@headlessui/react": "^1.7.8",
"@headlessui/react": "^1.7.12",
"@lightninglabs/lnc-web": "^0.2.2-alpha",
"@noble/secp256k1": "^1.7.1",
"@tailwindcss/forms": "^0.5.3",
Expand All @@ -50,41 +50,41 @@
"dayjs": "^1.11.7",
"dexie": "^3.2.3",
"elliptic": "^6.5.4",
"html5-qrcode": "^2.3.6",
"html5-qrcode": "^2.3.7",
"i18next": "^22.4.10",
"i18next-browser-languagedetector": "^7.0.1",
"lnmessage": "^0.0.19",
"lnmessage": "^0.1.0",
"lodash.merge": "^4.6.2",
"lodash.pick": "^4.4.0",
"lodash.snakecase": "^4.1.1",
"pubsub-js": "^1.9.4",
"react": "^18.2.0",
"react-confetti": "^6.1.0",
"react-dom": "^18.2.0",
"react-i18next": "^12.1.5",
"react-loading-skeleton": "^3.1.1",
"react-i18next": "^12.2.0",
"react-loading-skeleton": "^3.2.0",
"react-modal": "^3.16.1",
"react-qr-code": "^2.0.11",
"react-router-dom": "^6.8.1",
"react-router-dom": "^6.8.2",
"react-toastify": "^9.1.1",
"stream": "^0.0.2",
"tailwindcss": "^3.2.6",
"tailwindcss": "^3.2.7",
"uuid": "^9.0.0",
"webextension-polyfill": "^0.10.0",
"zustand": "^3.7.2"
},
"devDependencies": {
"@commitlint/cli": "^17.4.4",
"@commitlint/config-conventional": "^17.4.4",
"@jest/types": "^29.4.3",
"@playwright/test": "^1.30.0",
"@jest/types": "^29.5.0",
"@playwright/test": "^1.31.1",
"@swc/core": "^1.3.35",
"@swc/jest": "^0.2.24",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.4.3",
"@trivago/prettier-plugin-sort-imports": "^4.0.0",
"@types/chrome": "^0.0.218",
"@trivago/prettier-plugin-sort-imports": "^4.1.1",
"@types/chrome": "^0.0.224",
"@types/crypto-js": "^4.1.1",
"@types/elliptic": "^6.4.14",
"@types/lodash.merge": "^4.6.7",
Expand All @@ -93,11 +93,11 @@
"@types/pubsub-js": "^1.8.3",
"@types/react-dom": "^18.0.11",
"@types/react-modal": "^3.13.1",
"@types/uuid": "^9.0.0",
"@types/uuid": "^9.0.1",
"@types/webextension-polyfill": "^0.10.0",
"@typescript-eslint/eslint-plugin": "^5.52.0",
"@typescript-eslint/parser": "^5.52.0",
"autoprefixer": "^10.4.13",
"@typescript-eslint/eslint-plugin": "^5.54.1",
"@typescript-eslint/parser": "^5.54.1",
"autoprefixer": "^10.4.14",
"buffer": "^6.0.3",
"clean-webpack-plugin": "^4.0.0",
"complete-randomer": "^1.9.1",
Expand All @@ -106,36 +106,36 @@
"css-loader": "^6.7.3",
"css-minimizer-webpack-plugin": "^4.2.2",
"del-cli": "^5.0.0",
"eslint": "^8.34.0",
"eslint-config-prettier": "^8.6.0",
"eslint": "^8.35.0",
"eslint-config-prettier": "^8.7.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"fake-indexeddb": "^4.0.1",
"filemanager-webpack-plugin": "^8.0.0",
"html-webpack-plugin": "^5.5.0",
"husky": "^8.0.3",
"jest": "^29.4.3",
"jest-environment-jsdom": "^29.4.3",
"jest-webextension-mock": "^3.8.8",
"lint-staged": "^13.1.2",
"mini-css-extract-plugin": "^2.7.2",
"msw": "^1.0.1",
"jest": "^29.5.0",
"jest-environment-jsdom": "^29.5.0",
"jest-webextension-mock": "^3.8.9",
"lint-staged": "^13.2.0",
"mini-css-extract-plugin": "^2.7.3",
"msw": "^1.1.0",
"postcss": "^8.4.21",
"postcss-cli": "^10.1.0",
"postcss-loader": "^7.0.2",
"pptr-testing-library": "^0.7.0",
"prettier": "^2.8.4",
"process": "^0.11.10",
"puppeteer": "^19.6.3",
"sass": "^1.58.0",
"puppeteer": "^19.7.2",
"sass": "^1.58.3",
"sass-loader": "^13.2.0",
"stream-browserify": "^3.0.0",
"swc-loader": "^0.2.3",
"terser-webpack-plugin": "^5.3.6",
"tsconfig-paths-webpack-plugin": "^4.0.0",
"terser-webpack-plugin": "^5.3.7",
"tsconfig-paths-webpack-plugin": "^4.0.1",
"typescript": "^4.9.5",
"webpack": "^5.75.0",
"webpack": "^5.76.1",
"webpack-bundle-analyzer": "^4.8.0",
"webpack-cli": "^5.0.1",
"webpack-dev-server": "^4.11.1",
Expand Down
15 changes: 9 additions & 6 deletions src/app/components/AllowanceMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import { CrossIcon } from "@bitcoin-design/bitcoin-icons-react/outline";
import Setting from "@components/Setting";
import Toggle from "@components/form/Toggle";
import type { FormEvent } from "react";
import { useEffect, useState } from "react";
import { Fragment, useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import Modal from "react-modal";
import { toast } from "react-toastify";
import { useAccount } from "~/app/context/AccountContext";
import { useSettings } from "~/app/context/SettingsContext";
import msg from "~/common/lib/msg";
import type { Allowance, Permission } from "~/types";
Expand All @@ -28,7 +29,7 @@ function AllowanceMenu({ allowance, onEdit, onDelete }: Props) {
getFormattedFiat,
} = useSettings();
const showFiat = !isLoadingSettings && settings.showFiat;

const { account } = useAccount();
const [modalIsOpen, setIsOpen] = useState(false);
const [budget, setBudget] = useState("");
const [lnurlAuth, setLnurlAuth] = useState(false);
Expand Down Expand Up @@ -58,6 +59,7 @@ function AllowanceMenu({ allowance, onEdit, onDelete }: Props) {
permissions: Permission[];
}>("listPermissions", {
id: allowance.id,
accountId: account?.id,
});

const permissions: Permission[] = permissionResponse?.permissions;
Expand All @@ -72,8 +74,8 @@ function AllowanceMenu({ allowance, onEdit, onDelete }: Props) {
}
};

!permissions && fetchPermissions();
}, [allowance.id, permissions]);
fetchPermissions();
}, [account?.id, allowance.id]);

useEffect(() => {
if (budget !== "" && showFiat) {
Expand Down Expand Up @@ -125,6 +127,7 @@ function AllowanceMenu({ allowance, onEdit, onDelete }: Props) {
if (changedIds.length) {
await msg.request("deletePermissionsById", {
ids: changedIds,
accountId: account?.id,
});
}

Expand Down Expand Up @@ -237,7 +240,7 @@ function AllowanceMenu({ allowance, onEdit, onDelete }: Props) {
</h2>
<div>
{permissions.map((permission) => (
<>
<Fragment key={permission.id}>
<Setting
title={permission.method}
subtitle={tPermissions(
Expand Down Expand Up @@ -265,7 +268,7 @@ function AllowanceMenu({ allowance, onEdit, onDelete }: Props) {
}}
/>
</Setting>
</>
</Fragment>
))}
</div>
</div>
Expand Down
105 changes: 70 additions & 35 deletions src/app/components/CompanionDownloadInfo.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { ReceiveIcon } from "@bitcoin-design/bitcoin-icons-react/filled";
import { useState } from "react";
import { useTranslation } from "react-i18next";

type Props = {
hasTorCallback: () => void;
hasTorCallback: (hasTor: boolean) => void;
};

function CompanionDownloadInfo({ hasTorCallback }: Props) {
const [hasTorSupport, setHasTorSupport] = useState(false);
const [isTor, setIsTor] = useState(false);
const { t } = useTranslation("components", {
keyPrefix: "companion_download_info",
});
Expand All @@ -20,40 +19,76 @@ function CompanionDownloadInfo({ hasTorCallback }: Props) {
if (userAgent.indexOf("Linux") !== -1) return "Linux";
}

function onChangeConnectionMode(isTor: boolean) {
setIsTor(isTor);
hasTorCallback(isTor);
}

// TODO: check if the companion app is already installed
return (
<>
{!hasTorSupport && (
<div className="dark:text-white">
<p className="mb-2">{t("description")} </p>
<p className="mb-2">
<a
href={`https://getalby.com/install/companion/${getOS()}`}
target="_blank"
rel="noreferrer noopener"
className="font-bold"
>
{t("download_here")}
<ReceiveIcon className="w-6 h-6 inline" />
</a>
</p>
<p>
{t("or")}{" "}
<a
href="#"
className="font-bold"
onClick={(e) => {
e.preventDefault();
setHasTorSupport(true);
hasTorCallback();
}}
>
{t("using_tor")}
</a>
</p>
</div>
)}
</>
<div className="dark:text-white">
<h3 className="mb-2 font-medium text-gray-800 dark:text-white">
{t("heading")}
</h3>
<ul className="grid w-full gap-3 md:grid-cols-2">
<li>
<input
type="radio"
id="mode-companion"
name="mode"
value="companion"
className="hidden peer"
checked={!isTor}
onChange={() => onChangeConnectionMode(false)}
/>
<label
htmlFor="mode-companion"
className="inline-flex items-center justify-between w-full p-5 text-gray-500 bg-white border border-gray-200 rounded-lg cursor-pointer dark:hover:text-gray-300 dark:border-gray-700 dark:peer-checked:text-orange-bitcoin peer-checked:border-orange-bitcoin peer-checked:text-orange-bitcoin hover:text-gray-600 hover:bg-gray-100 dark:text-gray-400 dark:bg-gray-800 dark:hover:bg-gray-700"
>
<div className="block">
<div className="text-md font-semibold mb-2">
{t("companion.title")}
</div>
<div className="text-sm mb-2">{t("companion.description")}</div>
<div className="text-sm">
<a
className="text-sky-500 hover:text-sky-300"
href={`https://getalby.com/install/companion/${getOS()}`}
target="_blank"
rel="noreferrer"
>
{t("download")} &raquo;
</a>
</div>
</div>
</label>
</li>
<li>
<input
type="radio"
id="mode-tor"
name="mode"
value="tor"
className="hidden peer"
checked={isTor}
onChange={() => onChangeConnectionMode(true)}
/>
<label
htmlFor="mode-tor"
className="inline-flex items-center justify-between w-full p-5 text-gray-500 bg-white border border-gray-200 rounded-lg cursor-pointer dark:hover:text-gray-300 dark:border-gray-700 dark:peer-checked:text-orange-bitcoin peer-checked:border-orange-bitcoin peer-checked:text-orange-bitcoin hover:text-gray-600 hover:bg-gray-100 dark:text-gray-400 dark:bg-gray-800 dark:hover:bg-gray-700"
>
<div className="block">
<div className="w-full font-semibold mb-2">
{t("tor_native.title")}
</div>
<div className="w-full text-sm mb-2">
{t("tor_native.description")}
</div>
</div>
</label>
</li>
</ul>
</div>
);
}

Expand Down
17 changes: 17 additions & 0 deletions src/app/components/Hyperlink/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { ReactNode } from "react";

type Props = {
onClick: () => void;
children: ReactNode;
};

export default function Hyperlink({ onClick, children }: Props) {
return (
<a
className="cursor-pointer text-sky-500 hover:text-sky-400"
onClick={onClick}
>
{children}
</a>
);
}
4 changes: 3 additions & 1 deletion src/app/components/Navbar/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ export default function Navbar({ children }: Props) {
<div className="flex">
<UserMenu />
{children && (
<nav className="ml-8 space-x-8 hidden md:flex">{children}</nav>
<nav className="ml-4 space-x-4 lg:ml-4 lg:space-x-8 hidden md:flex">
{children}
</nav>
)}
</div>
<AccountMenu />
Expand Down
Loading

0 comments on commit dd85f9a

Please sign in to comment.