Skip to content

Commit

Permalink
Fix copy button on response headers (#1409)
Browse files Browse the repository at this point in the history
Co-authored-by: Millicent Achieng <[email protected]>
  • Loading branch information
Onokaev and millicentachieng authored Feb 2, 2022
1 parent 59e2ddc commit e52cc64
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions src/app/views/query-response/headers/ResponseHeaders.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@

import { IconButton } from '@fluentui/react';
import React from 'react';
import { useSelector } from 'react-redux';
import { RESPONSE_HEADERS_COPY_BUTTON } from '../../../../telemetry/component-names';
import { IRootState } from '../../../../types/root';
import { translateMessage } from '../../../utils/translate-messages';

import { Monaco } from '../../common';
import { trackedGenericCopy } from '../../common/copy';
import { convertVhToPx, getResponseHeight } from '../../common/dimensions-adjustment';
import { CopyButton } from '../../common/copy/CopyButton';

const ResponseHeaders = () => {
const { dimensions: { response }, graphResponse, responseAreaExpanded, sampleQuery } =
Expand All @@ -17,22 +16,18 @@ const ResponseHeaders = () => {

const height = convertVhToPx(getResponseHeight(response.height, responseAreaExpanded), 100);

const handleCopy = async () => trackedGenericCopy(JSON.stringify(headers), RESPONSE_HEADERS_COPY_BUTTON, sampleQuery)

if (headers) {
return (
<div>
<IconButton
<>
<CopyButton
handleOnClick={handleCopy}
isIconButton={true}
style={{ float: 'right', zIndex: 1 }}
ariaLabel={translateMessage('Copy')}
iconProps={{ iconName: 'copy' }}
onClick={
async () =>
trackedGenericCopy(
JSON.stringify(headers),
RESPONSE_HEADERS_COPY_BUTTON,
sampleQuery)}
/>
<Monaco body={headers} height={height} />
</div>
</>
);
}

Expand Down

0 comments on commit e52cc64

Please sign in to comment.