2019-07-08 20:58:33 +02:00
|
|
|
// @flow
|
|
|
|
import React from 'react';
|
2019-11-22 22:13:00 +01:00
|
|
|
import classnames from 'classnames';
|
2019-07-08 20:58:33 +02:00
|
|
|
import { clipboard } from 'electron';
|
|
|
|
import Button from 'component/button';
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
shortUrl: ?string,
|
|
|
|
uri: string,
|
|
|
|
doToast: ({ message: string }) => void,
|
2019-11-22 22:13:00 +01:00
|
|
|
inline?: boolean,
|
2020-02-11 20:32:49 +01:00
|
|
|
noShortUrl?: boolean,
|
2019-07-08 20:58:33 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
function ClaimUri(props: Props) {
|
2020-02-11 20:32:49 +01:00
|
|
|
const { shortUrl, uri, doToast, inline = false, noShortUrl = false } = props;
|
2019-07-08 20:58:33 +02:00
|
|
|
|
|
|
|
return (
|
|
|
|
<Button
|
2019-11-22 22:13:00 +01:00
|
|
|
className={classnames('media__uri', { 'media__uri--inline': inline })}
|
2019-07-08 20:58:33 +02:00
|
|
|
button="alt"
|
2020-02-11 20:32:49 +01:00
|
|
|
label={noShortUrl ? uri : shortUrl || uri}
|
2019-07-08 20:58:33 +02:00
|
|
|
onClick={() => {
|
|
|
|
clipboard.writeText(shortUrl || uri);
|
|
|
|
doToast({
|
|
|
|
message: __('Copied'),
|
|
|
|
});
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ClaimUri;
|