diff --git a/src/core/components/copy-to-clipboard-btn.jsx b/src/core/components/copy-to-clipboard-btn.jsx new file mode 100644 index 00000000..67025181 --- /dev/null +++ b/src/core/components/copy-to-clipboard-btn.jsx @@ -0,0 +1,26 @@ +import React from "react" +import { CopyToClipboard } from "react-copy-to-clipboard" +import PropTypes from "prop-types" + +/** + * @param {{ textToCopy: string }} props + * @returns {JSX.Element} + * @constructor + */ +export default class CopyToClipboardBtn extends React.Component { + render() { + return ( +
+ + + + + +
+ ) + } + + static propTypes = { + textToCopy: PropTypes.string.isRequired, + } +} diff --git a/src/core/components/operation-summary.jsx b/src/core/components/operation-summary.jsx index bdfafe7d..be89a23d 100644 --- a/src/core/components/operation-summary.jsx +++ b/src/core/components/operation-summary.jsx @@ -58,6 +58,7 @@ export default class OperationSummary extends PureComponent { const OperationSummaryMethod = getComponent("OperationSummaryMethod") const OperationSummaryPath = getComponent("OperationSummaryPath") const JumpToPath = getComponent("JumpToPath", true) + const CopyToClipboardBtn = getComponent("CopyToClipboardBtn", true) const hasSecurity = security && !!security.count() const securityIsOptional = hasSecurity && security.size === 1 && security.first().isEmpty() @@ -96,6 +97,7 @@ export default class OperationSummary extends PureComponent { }} /> } + {/* TODO: use wrapComponents here, swagger-ui doesn't care about jumpToPath */} ) diff --git a/src/core/components/svg-assets.jsx b/src/core/components/svg-assets.jsx index 9db9517d..8686b832 100644 --- a/src/core/components/svg-assets.jsx +++ b/src/core/components/svg-assets.jsx @@ -35,6 +35,12 @@ const SvgAssets = () => + + + + + + diff --git a/src/core/presets/base.js b/src/core/presets/base.js index 625806e7..ddfe3331 100644 --- a/src/core/presets/base.js +++ b/src/core/presets/base.js @@ -63,6 +63,7 @@ import Info, { } from "core/components/info" import InfoContainer from "core/containers/info" import JumpToPath from "core/components/jump-to-path" +import CopyToClipboardBtn from "core/components/copy-to-clipboard-btn" import Footer from "core/components/footer" import FilterContainer from "core/containers/filter" import ParamBody from "core/components/param-body" @@ -113,6 +114,7 @@ export default function() { info: Info, InfoContainer, JumpToPath, + CopyToClipboardBtn, onlineValidatorBadge: OnlineValidatorBadge, operations: Operations, operation: Operation, diff --git a/src/style/_buttons.scss b/src/style/_buttons.scss index 1c5db3b3..55dbd268 100644 --- a/src/style/_buttons.scss +++ b/src/style/_buttons.scss @@ -205,3 +205,10 @@ button height: 18px; } } + +// overrides for copy to clipboard button +.opblock .opblock-summary .view-line-link.copy-to-clipboard +{ + height: 26px; + position: unset; +} \ No newline at end of file diff --git a/src/style/_layout.scss b/src/style/_layout.scss index 39962d67..82110e01 100644 --- a/src/style/_layout.scss +++ b/src/style/_layout.scss @@ -376,6 +376,10 @@ { width: 18px; margin: 0 5px; + + &.copy-to-clipboard { + width: 24px; + } } } }