Skip to content
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
14 changes: 6 additions & 8 deletions packages/app-treasury/src/Overview/Proposals.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
/* eslint-disable @typescript-eslint/camelcase */
// Copyright 2017-2020 @polkadot/app-democracy authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.

import { DerivedTreasuryProposal } from '@polkadot/api-derive/types';
import { I18nProps } from '@polkadot/react-components/types';
import { AccountId, Balance } from '@polkadot/types/interfaces';

import React, { useEffect, useState } from 'react';
Expand All @@ -13,14 +11,16 @@ import { Table } from '@polkadot/react-components';
import { useApi, useAccounts, useCall } from '@polkadot/react-hooks';

import Proposal from './Proposal';
import translate from '../translate';
import { useTranslation } from '../translate';

interface Props extends I18nProps {
proposals?: DerivedTreasuryProposal[];
interface Props {
className?: string;
isApprovals?: boolean;
proposals?: DerivedTreasuryProposal[];
}

function ProposalsBase ({ className, isApprovals, proposals, t }: Props): React.ReactElement<Props> {
export default function ProposalsBase ({ className, isApprovals, proposals }: Props): React.ReactElement<Props> {
const { t } = useTranslation();
const { api } = useApi();
const { allAccounts } = useAccounts();
const members = useCall<[AccountId, Balance][]>(api.query.electionsPhragmen?.members || api.query.elections.members, []);
Expand Down Expand Up @@ -62,5 +62,3 @@ function ProposalsBase ({ className, isApprovals, proposals, t }: Props): React.
</div>
);
}

export default translate(ProposalsBase);
13 changes: 7 additions & 6 deletions packages/app-treasury/src/Overview/Propose.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.

import { I18nProps as Props } from '@polkadot/react-components/types';

import BN from 'bn.js';
import React, { useState } from 'react';
import { Button, InputAddress, InputBalance, Modal, TxButton } from '@polkadot/react-components';
import { useAccounts } from '@polkadot/react-hooks';

import translate from '../translate';
import { useTranslation } from '../translate';

interface Props {
className?: string;
}

function Propose ({ className, t }: Props): React.ReactElement<Props> | null {
export default function Propose ({ className }: Props): React.ReactElement<Props> | null {
const { t } = useTranslation();
const { hasAccounts } = useAccounts();
const [accountId, setAccountId] = useState<string | null>(null);
const [beneficiary, setBeneficiary] = useState<string | null>(null);
Expand Down Expand Up @@ -90,5 +93,3 @@ function Propose ({ className, t }: Props): React.ReactElement<Props> | null {
</>
);
}

export default translate(Propose);
11 changes: 4 additions & 7 deletions packages/app-treasury/src/Overview/Summary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,23 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.

import { I18nProps } from '@polkadot/react-components/types';

import BN from 'bn.js';
import React from 'react';
import { SummaryBox, CardSummary } from '@polkadot/react-components';
import { useApi, useCall } from '@polkadot/react-hooks';
import { formatBalance, formatNumber, stringToU8a } from '@polkadot/util';

import translate from '../translate';
import { useTranslation } from '../translate';

const TREASURY_ACCOUNT = stringToU8a('modlpy/trsry'.padEnd(32, '\0'));

interface Props extends I18nProps {
interface Props {
approvalCount?: number;
proposalCount?: number;
}

function Summary ({ approvalCount, proposalCount, t }: Props): React.ReactElement<Props> {
export default function Summary ({ approvalCount, proposalCount }: Props): React.ReactElement<Props> {
const { t } = useTranslation();
const { api } = useApi();
const pot = useCall<BN>(api.query.treasury.pot, []);
const bestNumber = useCall<BN>(api.derive.chain.bestNumber as any, []);
Expand Down Expand Up @@ -63,5 +62,3 @@ function Summary ({ approvalCount, proposalCount, t }: Props): React.ReactElemen
</SummaryBox>
);
}

export default translate(Summary);
12 changes: 6 additions & 6 deletions packages/app-treasury/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.

import { AppProps, BareProps, I18nProps } from '@polkadot/react-components/types';
import { AppProps, BareProps } from '@polkadot/react-components/types';

import React from 'react';
import { Route, Switch } from 'react-router';
Expand All @@ -11,13 +11,15 @@ import { HelpOverlay, Tabs } from '@polkadot/react-components';
import basicMd from './md/basic.md';
import Overview from './Overview';

import translate from './translate';
import { useTranslation } from './translate';

export { default as useCounter } from './useCounter';

interface Props extends AppProps, BareProps, I18nProps {}
interface Props extends AppProps, BareProps {}

export default function TreasuryApp ({ basePath }: Props): React.ReactElement<Props> {
const { t } = useTranslation();

function TreasuryApp ({ basePath, t }: Props): React.ReactElement<Props> {
return (
<main className='treasury--App'>
<HelpOverlay md={basicMd} />
Expand All @@ -39,5 +41,3 @@ function TreasuryApp ({ basePath, t }: Props): React.ReactElement<Props> {
</main>
);
}

export default translate(TreasuryApp);
10 changes: 4 additions & 6 deletions packages/apps/src/SideBar/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// of the Apache-2.0 license. See the LICENSE file for details.

import { ApiProps } from '@polkadot/react-api/types';
import { I18nProps } from '@polkadot/react-components/types';
import { Route } from '@polkadot/apps-routing/types';
import { AccountId } from '@polkadot/types/interfaces';

Expand All @@ -14,11 +13,11 @@ import { Badge, Icon, Menu, Tooltip } from '@polkadot/react-components';
import { useAccounts, useApi, useCall } from '@polkadot/react-hooks';
import { isFunction } from '@polkadot/util';

import translate from '../translate';
import { useTranslation } from '../translate';

const DUMMY_COUNTER = (): number => 0;

interface Props extends I18nProps {
interface Props {
isCollapsed: boolean;
onClick: () => void;
route: Route;
Expand Down Expand Up @@ -74,7 +73,8 @@ function checkVisible (name: string, { api, isApiReady, isApiConnected }: ApiPro
return notFound.length === 0;
}

function Item ({ route: { Modal, useCounter = DUMMY_COUNTER, display, i18n, icon, name }, t, isCollapsed, onClick }: Props): React.ReactElement<Props> | null {
export default function Item ({ route: { Modal, useCounter = DUMMY_COUNTER, display, i18n, icon, name }, isCollapsed, onClick }: Props): React.ReactElement<Props> | null {
const { t } = useTranslation();
const { allAccounts, hasAccounts } = useAccounts();
const apiProps = useApi();
const sudoKey = useCall<AccountId>(apiProps.isApiReady ? apiProps.api.query.sudo?.key : undefined, []);
Expand Down Expand Up @@ -141,5 +141,3 @@ function Item ({ route: { Modal, useCounter = DUMMY_COUNTER, display, i18n, icon
</Menu.Item>
);
}

export default translate(Item);
13 changes: 6 additions & 7 deletions packages/apps/src/modals/Network.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.

import { I18nProps } from '@polkadot/react-components/types';

import React from 'react';
import { Modal } from '@polkadot/react-components';
import General from '@polkadot/app-settings/General';

import translate from '../translate';
import { useTranslation } from '../translate';

interface Props extends I18nProps {
interface Props {
className?: string;
onClose: () => void;
}

function NetworkModal ({ className, onClose, t }: Props): React.ReactElement<Props> {
export default function NetworkModal ({ className, onClose }: Props): React.ReactElement<Props> {
const { t } = useTranslation();

return (
<Modal
className={className}
Expand All @@ -30,5 +31,3 @@ function NetworkModal ({ className, onClose, t }: Props): React.ReactElement<Pro
</Modal>
);
}

export default translate(NetworkModal);
23 changes: 12 additions & 11 deletions packages/apps/src/overlays/Accounts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.

import { I18nProps as Props } from '@polkadot/react-components/types';

import React, { useState } from 'react';
import { Link } from 'react-router-dom';
import styled from 'styled-components';
import { useAccounts, useApi } from '@polkadot/react-hooks';

import translate from '../translate';
import { useTranslation } from '../translate';
import BaseOverlay from './Base';

function Accounts ({ className, t }: Props): React.ReactElement<Props> | null {
interface Props {
className?: string;
}

function Accounts ({ className }: Props): React.ReactElement<Props> | null {
const { t } = useTranslation();
const { hasAccounts } = useAccounts();
const { isApiReady } = useApi();
const [isHidden, setIsHidden] = useState(false);
Expand Down Expand Up @@ -41,10 +44,8 @@ function Accounts ({ className, t }: Props): React.ReactElement<Props> | null {
);
}

export default translate(
styled(Accounts)`
background: #fff6cb;
border-color: #e7c000;
color: #6b5900;
`
);
export default styled(Accounts)`
background: #fff6cb;
border-color: #e7c000;
color: #6b5900;
`;
14 changes: 7 additions & 7 deletions packages/react-components/src/Button/Or.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,21 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.

import { I18nProps } from '../types';

import React from 'react';
import SUIButton from 'semantic-ui-react/dist/commonjs/elements/Button/Button';
import { isUndefined } from '@polkadot/util';

import translate from '../translate';
import { useTranslation } from '../translate';

interface Props extends I18nProps {
interface Props {
className?: string;
style?: any;
text?: string;
}

function ButtonOr ({ className, style, t, text }: Props): React.ReactElement<Props> {
export default function ButtonOr ({ className, style, text }: Props): React.ReactElement<Props> {
const { t } = useTranslation();

return (
<SUIButton.Or
className={className}
Expand All @@ -27,5 +29,3 @@ function ButtonOr ({ className, style, t, text }: Props): React.ReactElement<Pro
/>
);
}

export default translate(ButtonOr);
1 change: 1 addition & 0 deletions packages/react-components/src/ErrorBoundary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ interface State {
hasError: boolean;
}

// NOTE: This is the only way to do an error boundary, via extend
class ErrorBoundary extends React.Component<Props> {
state: State = { hasError: false };

Expand Down
10 changes: 4 additions & 6 deletions packages/react-components/src/InputConsts/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import { ConstantCodec } from '@polkadot/metadata/Decorated/types';
import { DropdownOptions } from '../util/types';
import { I18nProps } from '../types';
import { ConstValue, ConstValueBase } from './types';

import '../InputExtrinsic/InputExtrinsic.css';
Expand All @@ -14,18 +13,19 @@ import { ApiPromise } from '@polkadot/api';
import { useApi } from '@polkadot/react-hooks';

import Labelled from '../Labelled';
import translate from '../translate';
import SelectKey from './SelectKey';
import SelectSection from './SelectSection';
import keyOptions from './options/key';
import sectionOptions from './options/section';

interface Props extends I18nProps {
interface Props {
className?: string;
defaultValue: ConstValueBase;
help?: React.ReactNode;
isError?: boolean;
label: React.ReactNode;
onChange?: (value: ConstValue) => void;
style?: any;
withLabel?: boolean;
}

Expand All @@ -42,7 +42,7 @@ function getValue (api: ApiPromise, { method, section }: ConstValueBase): ConstV
};
}

function InputConsts ({ className, defaultValue, help, label, onChange, style, withLabel }: Props): React.ReactElement<Props> {
export default function InputConsts ({ className, defaultValue, help, label, onChange, style, withLabel }: Props): React.ReactElement<Props> {
const { api } = useApi();
const [optionsMethod, setOptionsMethod] = useState<DropdownOptions>(keyOptions(api, defaultValue.section));
const [optionsSection] = useState<DropdownOptions>(sectionOptions(api));
Expand Down Expand Up @@ -99,5 +99,3 @@ function InputConsts ({ className, defaultValue, help, label, onChange, style, w
</div>
);
}

export default translate(InputConsts);
10 changes: 4 additions & 6 deletions packages/react-components/src/InputExtrinsic/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// of the Apache-2.0 license. See the LICENSE file for details.

import { CallFunction } from '@polkadot/types/types';
import { I18nProps } from '../types';
import { DropdownOptions } from '../util/types';

import './InputExtrinsic.css';
Expand All @@ -12,24 +11,25 @@ import React, { useState } from 'react';
import { useApi } from '@polkadot/react-hooks';

import Labelled from '../Labelled';
import translate from '../translate';
import SelectMethod from './SelectMethod';
import SelectSection from './SelectSection';
import methodOptions from './options/method';
import sectionOptions from './options/section';

interface Props extends I18nProps {
interface Props {
className?: string;
defaultValue: CallFunction;
help?: React.ReactNode;
isDisabled?: boolean;
isError?: boolean;
isPrivate?: boolean;
label: React.ReactNode;
onChange: (value: CallFunction) => void;
style?: any;
withLabel?: boolean;
}

function InputExtrinsic ({ className, defaultValue, help, label, onChange, style, withLabel }: Props): React.ReactElement<Props> {
export default function InputExtrinsic ({ className, defaultValue, help, label, onChange, style, withLabel }: Props): React.ReactElement<Props> {
const { api } = useApi();
const [optionsMethod, setOptionsMethod] = useState<DropdownOptions>(methodOptions(api, defaultValue.section));
const [optionsSection] = useState<DropdownOptions>(sectionOptions(api));
Expand Down Expand Up @@ -84,5 +84,3 @@ function InputExtrinsic ({ className, defaultValue, help, label, onChange, style
</div>
);
}

export default translate(InputExtrinsic);
Loading