// Copyright 2017-2019 @polkadot/app-js 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 { BareProps, I18nProps } from '@polkadot/ui-app/types'; import React from 'react'; import { Button as SUIB, Popup } from 'semantic-ui-react'; import { Button, Input } from '@polkadot/ui-app'; import translate from './translate'; type Props = BareProps & I18nProps & { isCustomExample: boolean; isRunning: boolean; generateLink: () => void; removeSnippet: () => void; runJs: () => void; saveSnippet: (snippetName: string) => void; snippetName?: string; stopJs: () => void; }; interface State { isOpen: boolean; shareText: string; snippetName: string; } class ActionButtons extends React.PureComponent { public state: State = { isOpen: false, shareText: this.props.t('Generate link to share code example'), snippetName: '' }; public render (): React.ReactNode { const { props: { isCustomExample, isRunning, removeSnippet, runJs, stopJs, t }, state: { isOpen, shareText, snippetName } } = this; return (
} wide='very' /> { // FIXME: The event trigger on='hover' does not work together with the ui-app' //
); } private generateLink = (): void => { const { generateLink, t } = this.props; this.setState({ shareText: t('Copied to clipboard') }); generateLink(); } private onShareClose = (): void => { this.setState({ shareText: this.props.t('Generate link to share code example') }); } private onChangeName = (snippetName: string): void => { this.setState({ snippetName }); } private saveSnippet = (): void => { const { state: { snippetName }, props: { saveSnippet } } = this; saveSnippet(snippetName); this.setState({ snippetName: '', isOpen: false }); } private onPopupOpen = (): void => { this.setState({ isOpen: true, snippetName: this.props.snippetName || '' }); } private onPopupClose = (): void => { this.setState({ snippetName: '', isOpen: false }); } } export default translate(ActionButtons);