Skip to content

Commit

Permalink
Merge pull request #3485 from Emurgo/ruslan/packages
Browse files Browse the repository at this point in the history
packages
  • Loading branch information
vsubhuman authored May 6, 2024
2 parents 17e6eea + d51fa98 commit be1e3c1
Show file tree
Hide file tree
Showing 9 changed files with 232 additions and 756 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,7 @@ export default class WalletSendFormRevamp extends Component<Props, State> {
)}
<Box
sx={{
height: '129px',
position: 'relative',
padding: '16px 0px',
borderRadius: '8px',
Expand All @@ -736,21 +737,27 @@ export default class WalletSendFormRevamp extends Component<Props, State> {
}),
}}
>
<Typography component="div"
<Typography
component="div"
sx={{
position: 'absolute',
top: '-8px',
left: '6px',
backgroundColor: 'common.white',
paddingX: '4px',
color: shouldSendAll && 'grayscale.200',
fontWeight: 400,
fontSize: '12px',
lineHeight: '16px',
letterSpacing: '0.2px',
}}
variant="caption2"
>
{intl.formatMessage(globalMessages.amountLabel)}
</Typography>
<Box
sx={{
height: '32px',
margin: '0px 16px',
display: 'flex',
alignItems: 'center',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { isValidReceiveAddress } from '../../api/ada/lib/storage/bridge/utils';
export default class URILandingPage extends Component<StoresAndActionsProps> {
onClose: void => void = () => {
this.props.actions.dialogs.closeActiveDialog.trigger();
this.props.actions.router.goToRoute.trigger({ route: ROUTES.MY_WALLETS });
this.props.actions.router.goToRoute.trigger({ route: ROUTES.WALLETS.ROOT });
this.props.stores.loading.resetUriParams();
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import type { MessageDescriptor } from 'react-intl';
import { ROUTES } from '../../routes-config';
import globalMessages, { connectorMessages } from '../../i18n/global-messages';
import { matchRoute } from '../../utils/routing';
import { asGetStakingKey } from '../../api/ada/lib/storage/models/PublicDeriver/traits';
import { ReactComponent as walletsIcon } from '../../assets/images/sidebar/my_wallets.inline.svg';
import { ReactComponent as transferIcon } from '../../assets/images/sidebar/transfer_wallets.inline.svg';
Expand Down Expand Up @@ -45,8 +44,7 @@ export const MY_WALLETS: SidebarCategory = registerCategory({
label: globalMessages.sidebarWallets,
isVisible: request =>
request.hasAnyWallets &&
request.selected == null &&
matchRoute(ROUTES.WALLETS.ADD, request.currentRoute) === false,
request.selected == null,
});

export const WALLETS_ROOT: SidebarCategory = registerCategory({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default class LoadingStore extends BaseLoadingStore<StoresMap, ActionsMap
}

@computed get fromUriScheme(): boolean {
return matchRoute(ROUTES.SEND_FROM_URI.ROOT, this._originRoute.route) !== false;
return matchRoute(ROUTES.SEND_FROM_URI.ROOT, this._originRoute.route);
}

@computed get uriParams(): ?UriParams {
Expand Down
7 changes: 0 additions & 7 deletions packages/yoroi-extension/app/stores/toplevel/WalletStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { action, computed, observable, runInAction } from 'mobx';
import { debounce, find } from 'lodash';
import Store from '../base/Store';
import Request from '../lib/LocalizedRequest';
import { matchRoute } from '../../utils/routing';
import { ROUTES } from '../../routes-config';
import environment from '../../environment';
import config from '../../config';
Expand Down Expand Up @@ -392,12 +391,6 @@ export default class WalletStore extends Store<StoresMap, ActionsMap> {

// =================== PRIVATE API ==================== //

@computed get _canRedirectToWallet(): boolean {
const currentRoute = this.stores.app.currentRoute;
const isRootRoute = matchRoute(ROUTES.WALLETS.ROOT, currentRoute) !== false;
return isRootRoute;
}

_pollRefresh: void => Promise<void> = async () => {
// Do not update if screen not active
// TODO: use visibilityState instead
Expand Down
14 changes: 10 additions & 4 deletions packages/yoroi-extension/app/utils/logging.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// @flow
import RingBuffer from 'ringbufferjs';
import moment from 'moment';
import FileSaver from 'file-saver';
import { inspect } from 'util';
Expand All @@ -13,7 +12,14 @@ const logger = console;
// populated by ConfigWebpackPlugin
declare var CONFIG: ConfigType;
const { logsBufferSize, logsFileSuffix } = CONFIG.app;
const logs = new RingBuffer(logsBufferSize);
const errors = [];

function pushError(s: string): void {
errors.push(s);
if (errors.length > logsBufferSize) {
errors.shift();
}
}

export const Logger = {

Expand All @@ -29,7 +35,7 @@ export const Logger = {
// fix format so it shows up properly in Chrome console
const fixedString = data.replace(/\\n/g, '\n');
logger.error(fixedString);
logs.enq(`[${moment().format()}] ${fixedString}\n`);
pushError(`[${moment().format()}] ${fixedString}\n`);
},

warn: (data : string) => {
Expand All @@ -47,7 +53,7 @@ export const silenceLogsForTesting = () => {

export const downloadLogs = (publicKey?: string) => {
const header = generateLogHeader(publicKey);
let errorLogs = logs.peekN(logs.size());
let errorLogs = [...errors];
if (errorLogs.length === 0) {
errorLogs = [`[${moment().format()}] No errors logged.`];
}
Expand Down
4 changes: 1 addition & 3 deletions packages/yoroi-extension/app/utils/routing.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
// @flow

import RouteParser from 'route-parser';

export const matchRoute = (
pattern: string, path: string
): false | { [param: string]: string, ... } => new RouteParser(pattern).match(path);
): boolean => path.toLowerCase().startsWith(pattern.toLowerCase());

/**
* Build a route from a pattern like `/wallets/:id` to `/wallets/123`
Expand Down
Loading

0 comments on commit be1e3c1

Please sign in to comment.