Skip to content

Commit

Permalink
copy to clipbnoard big hficex
Browse files Browse the repository at this point in the history
  • Loading branch information
LinceMathew committed Aug 21, 2024
1 parent 59e8a67 commit 940f566
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 20 deletions.
3 changes: 3 additions & 0 deletions src/panels/RequestPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@ export class Lama2Panel {
case "alert":
vscode.window.showErrorMessage(message.text)
return
case 'showNotification':
vscode.window.showInformationMessage(message.text);
break;
}
},
undefined,
Expand Down
11 changes: 9 additions & 2 deletions webview/src/modules/IconPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,16 @@ interface IconPanelProps {
toggleIcon: (icon: string) => void
isHtmlContent: boolean
showTerminal: () => void
copyContent: () => void
}

const IconPanel: React.FC<IconPanelProps> = ({ highlightedIcon, toggleIcon, isHtmlContent, showTerminal }) => (
const IconPanel: React.FC<IconPanelProps> = ({
highlightedIcon,
toggleIcon,
isHtmlContent,
showTerminal,
copyContent,
}) => (
<div className="icon-box">
<div className="icon-box-toggle">
<div
Expand All @@ -28,7 +35,7 @@ const IconPanel: React.FC<IconPanelProps> = ({ highlightedIcon, toggleIcon, isHt
<i className="codicon codicon-table"></i>
</div>
</div>
<div className="bordered-icon">
<div className="bordered-icon" onClick={copyContent}>
<i className="codicon codicon-copy"></i>
</div>
<div className="bordered-icon" onClick={showTerminal}>
Expand Down
4 changes: 2 additions & 2 deletions webview/src/modules/JsonView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ interface JsonViewProps {
}

const JsonView: React.FC<JsonViewProps> = ({ data }) => (
<ReactJson src={data} theme="monokai" displayDataTypes={false} />
);
<ReactJson src={data} theme="monokai" displayDataTypes={false} name={false} />
)

export default JsonView;
39 changes: 23 additions & 16 deletions webview/src/pages/Response.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,22 +157,29 @@ const Response: React.FC = () => {
</div>
)
}

const responseContent = (
<>
<div className="meta-icon-section">
<Metadata {...apiMetrics} />
<IconPanel
highlightedIcon={highlightedIcon}
toggleIcon={toggleIcon}
isHtmlContent={!!htmlContent}
showTerminal={toggleTerminal}
/>
</div>

<div>{htmlContent ? <HtmlView content={htmlContent} /> : <JsonView data={body} />}</div>
</>
)
const copyContent = () => {
const copyBody = htmlContent || JSON.stringify(body, null, 2)
navigator.clipboard.writeText(copyBody).then(() => {
vscode.postMessage({ command: "showNotification", text: "Copied to clipboard" })
})
}

const responseContent = (
<>
<div className="meta-icon-section">
<Metadata {...apiMetrics} />
<IconPanel
highlightedIcon={highlightedIcon}
toggleIcon={toggleIcon}
isHtmlContent={!!htmlContent}
showTerminal={toggleTerminal}
copyContent={copyContent}
/>
</div>

<div>{htmlContent ? <HtmlView content={htmlContent} /> : <JsonView data={body} />}</div>
</>
)

const headersContent = (
<div className="card">
Expand Down

0 comments on commit 940f566

Please sign in to comment.