Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: improve extension in-tab view #988

Merged
merged 3 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions e2e-tests/popup/buy-cspr/buy-cspr.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ popup.describe('Popup UI: buy cspr', () => {

await popupPage.getByText('Ukraine').click();

// wait until a modal window closed
await new Promise(r => setTimeout(r, 2000));

await popupPage.getByRole('button', { name: 'Next' }).click();

await popupExpect(
Expand All @@ -128,6 +131,9 @@ popup.describe('Popup UI: buy cspr', () => {

await popupPage.getByText('UAH').click();

// wait until a modal window closed
await new Promise(r => setTimeout(r, 2000));

await popupPage.getByRole('button', { name: 'Next' }).click();

await popupExpect(
Expand Down
19 changes: 4 additions & 15 deletions src/apps/import-account-with-file/app-router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ import { HashRouter, Route, Routes } from 'react-router-dom';
import { useUserActivityTracker } from '@hooks/use-user-activity-tracker';

import '@libs/i18n/i18n';
import { HeaderPopup, LayoutWindow } from '@libs/layout';

import { ImportAccountWithFilePage } from './pages/import-account-with-file';
import { ImportAccountWithFileFailureContentPage } from './pages/import-account-with-file-failure';
import { ImportAccountWithFileSuccessContentPage } from './pages/import-account-with-file-success';
import { ImportAccountWithFileFailurePage } from './pages/import-account-with-file-failure';
import { ImportAccountWithFileSuccessPage } from './pages/import-account-with-file-success';
import { ImportAccountWithFileUploadPage } from './pages/import-account-with-file-upload';
import { RouterPath } from './router';

Expand All @@ -28,21 +27,11 @@ export function AppRouter() {
/>
<Route
path={RouterPath.ImportAccountWithFileSuccess}
element={
<LayoutWindow
renderHeader={() => <HeaderPopup />}
renderContent={() => <ImportAccountWithFileSuccessContentPage />}
/>
}
element={<ImportAccountWithFileSuccessPage />}
/>
<Route
path={RouterPath.ImportAccountWithFileFailure}
element={
<LayoutWindow
renderHeader={() => <HeaderPopup />}
renderContent={() => <ImportAccountWithFileFailureContentPage />}
/>
}
element={<ImportAccountWithFileFailurePage />}
/>
</Routes>
</HashRouter>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React from 'react';
import { Trans, useTranslation } from 'react-i18next';

import { useTypedLocation } from '@import-account-with-file/router';

import {
ContentContainer,
IllustrationContainer,
ParagraphContainer,
SpacingSize
} from '@libs/layout';
import { SvgIcon, Typography } from '@libs/ui/components';

export function ImportAccountWithFileFailureContentPage() {
const { t } = useTranslation();
const location = useTypedLocation();
const state = location.state;

return (
<ContentContainer>
<IllustrationContainer>
<SvgIcon
src="assets/illustrations/error.svg"
width={200}
height={120}
/>
</IllustrationContainer>
<ParagraphContainer top={SpacingSize.XL}>
<Typography type="header">
<Trans t={t}>Something went wrong</Trans>
</Typography>
</ParagraphContainer>
<ParagraphContainer top={SpacingSize.Medium}>
<Typography type="body" color="contentSecondary">
{state?.importAccountStatusMessage
? state.importAccountStatusMessage
: t(
': We couldn’t import your account. Please confirm that you’re importing a file containing your secret key (not to be confused with your public key).'
)}
</Typography>
</ParagraphContainer>
</ContentContainer>
);
}
Original file line number Diff line number Diff line change
@@ -1,60 +1,37 @@
import React from 'react';
import { Trans, useTranslation } from 'react-i18next';

import {
RouterPath,
useTypedLocation,
useTypedNavigate
} from '@import-account-with-file/router';
import { RouterPath, useTypedNavigate } from '@import-account-with-file/router';

import { closeCurrentWindow } from '@background/close-current-window';

import {
ContentContainer,
FooterButtonsAbsoluteContainer,
IllustrationContainer,
ParagraphContainer,
SpacingSize
FooterButtonsContainer,
HeaderPopup,
LayoutWindow
} from '@libs/layout';
import { Button, SvgIcon, Typography } from '@libs/ui/components';
import { Button } from '@libs/ui/components';

import { ImportAccountWithFileFailureContentPage } from './content';

export function ImportAccountWithFileFailureContentPage() {
export const ImportAccountWithFileFailurePage = () => {
const { t } = useTranslation();
const navigate = useTypedNavigate();
const location = useTypedLocation();
const state = location.state;

return (
<ContentContainer>
<IllustrationContainer>
<SvgIcon
src="assets/illustrations/error.svg"
width={200}
height={120}
/>
</IllustrationContainer>
<ParagraphContainer top={SpacingSize.XL}>
<Typography type="header">
<Trans t={t}>Something went wrong</Trans>
</Typography>
</ParagraphContainer>
<ParagraphContainer top={SpacingSize.Medium}>
<Typography type="body" color="contentSecondary">
{state?.importAccountStatusMessage
? state.importAccountStatusMessage
: t(
': We couldn’t import your account. Please confirm that you’re importing a file containing your secret key (not to be confused with your public key).'
)}
</Typography>
</ParagraphContainer>
<FooterButtonsAbsoluteContainer>
<Button onClick={() => navigate(RouterPath.ImportAccountWithFile)}>
<Trans t={t}>Try to import again</Trans>
</Button>
<Button color="secondaryBlue" onClick={() => closeCurrentWindow()}>
<Trans t={t}>Maybe later</Trans>
</Button>
</FooterButtonsAbsoluteContainer>
</ContentContainer>
<LayoutWindow
renderHeader={() => <HeaderPopup />}
renderContent={() => <ImportAccountWithFileFailureContentPage />}
renderFooter={() => (
<FooterButtonsContainer>
<Button onClick={() => navigate(RouterPath.ImportAccountWithFile)}>
<Trans t={t}>Try to import again</Trans>
</Button>
<Button color="secondaryBlue" onClick={() => closeCurrentWindow()}>
<Trans t={t}>Maybe later</Trans>
</Button>
</FooterButtonsContainer>
)}
/>
);
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React from 'react';
import { Trans, useTranslation } from 'react-i18next';

import {
ContentContainer,
IllustrationContainer,
ParagraphContainer,
SpacingSize
} from '@libs/layout';
import { SvgIcon, Typography } from '@libs/ui/components';

export function ImportAccountWithFileSuccessContentPage() {
const { t } = useTranslation();

return (
<ContentContainer>
<IllustrationContainer>
<SvgIcon
src="assets/illustrations/account-imported.svg"
width={200}
height={120}
/>
</IllustrationContainer>
<ParagraphContainer top={SpacingSize.XL}>
<Typography type="header">
<Trans t={t}>Your account was successfully imported</Trans>
</Typography>
</ParagraphContainer>
<ParagraphContainer top={SpacingSize.Medium}>
<Typography type="body" color="contentSecondary">
<Trans t={t}>
Imported accounts are distinguished by an ‘IMPORTED’ icon in the
account lists.
</Trans>
</Typography>
</ParagraphContainer>
</ContentContainer>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,28 @@ import { Trans, useTranslation } from 'react-i18next';
import { closeCurrentWindow } from '@background/close-current-window';

import {
ContentContainer,
FooterButtonsAbsoluteContainer,
IllustrationContainer,
ParagraphContainer,
SpacingSize
FooterButtonsContainer,
HeaderPopup,
LayoutWindow
} from '@libs/layout';
import { Button, SvgIcon, Typography } from '@libs/ui/components';
import { Button } from '@libs/ui/components';

export function ImportAccountWithFileSuccessContentPage() {
import { ImportAccountWithFileSuccessContentPage } from './content';

export const ImportAccountWithFileSuccessPage = () => {
const { t } = useTranslation();

return (
<ContentContainer>
<IllustrationContainer>
<SvgIcon
src="assets/illustrations/account-imported.svg"
width={200}
height={120}
/>
</IllustrationContainer>
<ParagraphContainer top={SpacingSize.XL}>
<Typography type="header">
<Trans t={t}>Your account was successfully imported</Trans>
</Typography>
</ParagraphContainer>
<ParagraphContainer top={SpacingSize.Medium}>
<Typography type="body" color="contentSecondary">
<Trans t={t}>
Imported accounts are distinguished by an ‘IMPORTED’ icon in the
account lists.
</Trans>
</Typography>
</ParagraphContainer>
<FooterButtonsAbsoluteContainer>
<Button onClick={() => closeCurrentWindow()}>
<Trans t={t}>Done</Trans>
</Button>
</FooterButtonsAbsoluteContainer>
</ContentContainer>
<LayoutWindow
renderHeader={() => <HeaderPopup />}
renderContent={() => <ImportAccountWithFileSuccessContentPage />}
renderFooter={() => (
<FooterButtonsContainer>
<Button onClick={closeCurrentWindow}>
<Trans t={t}>Done</Trans>
</Button>
</FooterButtonsContainer>
)}
/>
);
}
};
53 changes: 6 additions & 47 deletions src/apps/popup/app-router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ import { ImportAccountFromLedgerPage } from '@popup/pages/import-account-from-le
import { ImportAccountFromTorusPage } from '@popup/pages/import-account-from-torus';
import { NavigationMenuPageContent } from '@popup/pages/navigation-menu';
import { NftDetailsPage } from '@popup/pages/nft-details';
import { NoConnectedAccountPageContent } from '@popup/pages/no-connected-account';
import { NoConnectedAccountPage } from '@popup/pages/no-connected-account';
import { RateAppPage } from '@popup/pages/rate-app';
import { ReceivePage } from '@popup/pages/receive';
import { RemoveAccountPageContent } from '@popup/pages/remove-account';
import { RenameAccountPageContent } from '@popup/pages/rename-account';
import { RemoveAccountPage } from '@popup/pages/remove-account';
import { RenameAccountPage } from '@popup/pages/rename-account';
import { SignWithLedgerInNewWindowPage } from '@popup/pages/sign-with-ledger-in-new-window';
import { StakesPage } from '@popup/pages/stakes';
import { TimeoutPageContent } from '@popup/pages/timeout';
Expand Down Expand Up @@ -134,52 +134,11 @@ function AppRoutes() {
/>
}
/>
<Route
path={RouterPath.RemoveAccount}
element={
<PopupLayout
renderHeader={() => (
<HeaderPopup
withNetworkSwitcher
withMenu
withConnectionStatus
renderSubmenuBarItems={() => (
<HeaderSubmenuBarNavLink linkType="back" />
)}
/>
)}
renderContent={() => <RemoveAccountPageContent />}
/>
}
/>
<Route
path={RouterPath.RenameAccount}
element={
<PopupLayout
renderHeader={() => (
<HeaderPopup
withNetworkSwitcher
withMenu
withConnectionStatus
renderSubmenuBarItems={() => (
<HeaderSubmenuBarNavLink linkType="back" />
)}
/>
)}
renderContent={() => <RenameAccountPageContent />}
/>
}
/>
<Route path={RouterPath.RemoveAccount} element={<RemoveAccountPage />} />
<Route path={RouterPath.RenameAccount} element={<RenameAccountPage />} />
<Route
path={RouterPath.NoConnectedAccount}
element={
<PopupLayout
renderHeader={() => (
<HeaderPopup withNetworkSwitcher withMenu withConnectionStatus />
)}
renderContent={() => <NoConnectedAccountPageContent />}
/>
}
element={<NoConnectedAccountPage />}
/>
<Route
path={RouterPath.ConnectedSites}
Expand Down
Loading
Loading