ghost-portal/packages/page-generic-asset/src/AssetRow.tsx
Jaco Greeff 6a393256a4
Bump API, cater for new OpenTip structure (#3096)
* Bump API, cater for new OpenTip structure

* Simplify assignment

* Cleanups after latest typescript-eslint breakages

* More...

* Last-ish round
2020-06-30 13:43:06 +02:00

49 lines
1.3 KiB
TypeScript

// Copyright 2019 @polkadot/app-generic-asset 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 React, { useState } from 'react';
import { CopyButton } from '@polkadot/react-components';
import Row from '@polkadot/react-components/Row';
import { useTranslation } from './translate';
interface Props {
buttons?: React.ReactNode;
children?: React.ReactNode;
className?: string;
defaultName?: string;
isDisabled?: boolean;
isInline?: boolean;
onSaveName: (name: string) => void;
assetId: string;
}
export default function AssetRow ({ assetId, buttons, children, className, defaultName = 'New Asset', isDisabled, isInline, onSaveName }: Props): React.ReactElement<Props> {
const { t } =
useTranslation();
const [name, setName] = useState(defaultName);
return (
<Row
buttons={buttons}
className={className}
details={
<div>
<CopyButton value={assetId}>
<span>{t('Asset ID')}: {assetId}</span>
</CopyButton>
</div>
}
isDisabled={isDisabled}
isEditableName
isInline={isInline}
name={name}
onChangeName={setName}
onSaveName={onSaveName}
>
{children}
</Row>
);
}