diff --git a/app/src/frontend/building/data-components/data-title.tsx b/app/src/frontend/building/data-components/data-title.tsx index f36022c3..d108adf3 100644 --- a/app/src/frontend/building/data-components/data-title.tsx +++ b/app/src/frontend/building/data-components/data-title.tsx @@ -3,7 +3,13 @@ import PropTypes from 'prop-types'; import Tooltip from '../../components/tooltip'; -const DataTitle: React.FunctionComponent = (props) => { + +interface DataTitleProps { + title: string; + tooltip: string; +} + +const DataTitle: React.FunctionComponent = (props) => { return (
{ props.title } @@ -17,7 +23,16 @@ DataTitle.propTypes = { tooltip: PropTypes.string } -const DataTitleCopyable: React.FunctionComponent = (props) => { // TODO: remove any + +interface DataTitleCopyableProps { + title: string; + tooltip: string; + slug: string; + disabled?: boolean; + copy: any; // TODO: type should be CopyProps, but that clashes with propTypes in some obscure way +} + +const DataTitleCopyable: React.FunctionComponent = (props) => { // TODO: remove any return (
{ props.tooltip? : null } @@ -48,7 +63,8 @@ DataTitleCopyable.propTypes = { copy: PropTypes.shape({ copying: PropTypes.bool, copyingKey: PropTypes.func, - toggleCopyAttribute: PropTypes.func + toggleCopyAttribute: PropTypes.func, + toggleCopying: PropTypes.func }) } diff --git a/app/src/frontend/building/data-container.tsx b/app/src/frontend/building/data-container.tsx index 66bcb098..821a4374 100644 --- a/app/src/frontend/building/data-container.tsx +++ b/app/src/frontend/building/data-container.tsx @@ -24,10 +24,17 @@ interface DataContainerProps { interface DataContainerState { error: string; copying: boolean; - keys_to_copy: object; + keys_to_copy: {[key: string]: boolean}; building: Building } +interface CopyProps { + copying: boolean; + toggleCopying: () => void; + toggleCopyAttribute: (key: string) => void; + copyingKey: (key: string) => boolean; +} + /** * Shared functionality for view/edit forms * @@ -212,11 +219,11 @@ const withCopyEdit = (WrappedComponent) => { values_to_copy[key] = this.state.building[key] } const data_string = JSON.stringify(values_to_copy); - const copy = { + const copy: CopyProps = { copying: this.state.copying, toggleCopying: this.toggleCopying, toggleCopyAttribute: this.toggleCopyAttribute, - copyingKey: (key) => this.state.keys_to_copy[key] + copyingKey: (key: string) => this.state.keys_to_copy[key] } return (
{ } export default withCopyEdit; + +export { + CopyProps +};