- {panelUIDetails.body && (
-
- )}
+ {panelUIDetails.body &&
+ (panelUIDetails.hideBody
+ ? !panelUIDetails.hideBody(panel)
+ : true) && (
+
+ )}
{results.exception instanceof PanelPlayWarning ? (
void;
disableAutoDetect?: boolean;
inMemoryEval: boolean;
+ label?: string;
}) {
return (
{
@@ -156,19 +158,40 @@ export function HTTPInfo() {
)}
- Use the textarea to supply a HTTP request body. This will be ignored for{' '}
- GET
and HEAD
requests.
+ Use the textarea to supply a HTTP request body.
);
}
+export function HTTPPanelBody({
+ updatePanel,
+ panel,
+ keyboardShortcuts,
+}: PanelBodyProps) {
+ return (
+ {
+ panel.content = value;
+ updatePanel(panel);
+ }}
+ language="javascript"
+ className="editor"
+ />
+ );
+}
+
export const httpPanel: PanelUIDetails = {
icon: 'http',
eval: evalHTTPPanel,
id: 'http',
label: 'HTTP',
details: HTTPPanelDetails,
- body: null,
+ hideBody: (panel: HTTPPanelInfo) =>
+ !['PUT', 'POST', 'PATCH'].includes(panel.http.http.method.toUpperCase()),
+ body: HTTPPanelBody,
previewable: true,
factory: () => new HTTPPanelInfo(),
info: HTTPInfo,
diff --git a/ui/panels/LiteralPanel.tsx b/ui/panels/LiteralPanel.tsx
index 6c663ee4a..1c7660d15 100644
--- a/ui/panels/LiteralPanel.tsx
+++ b/ui/panels/LiteralPanel.tsx
@@ -7,6 +7,7 @@ import { parseArrayBuffer } from '../../shared/text';
import { panelRPC } from '../asyncRPC';
import { CodeEditor } from '../components/CodeEditor';
import { ContentTypePicker } from '../components/ContentTypePicker';
+import { FormGroup } from '../components/FormGroup';
import { PanelBodyProps, PanelDetailsProps, PanelUIDetails } from './types';
export async function evalLiteralPanel(panel: LiteralPanelInfo) {
@@ -39,7 +40,7 @@ export function LiteralPanelDetails({
updatePanel,
}: PanelDetailsProps) {
return (
-
+
-
+
);
}
diff --git a/ui/panels/types.ts b/ui/panels/types.ts
index 0dfeca59b..0279cf358 100644
--- a/ui/panels/types.ts
+++ b/ui/panels/types.ts
@@ -33,6 +33,7 @@ export interface PanelUIDetails {
label: string;
details: React.ElementType>;
body: React.ElementType> | null;
+ hideBody?: (p: T) => boolean;
previewable: boolean;
hasStdout: boolean;
info: ({ panel }: { panel: T }) => React.ReactElement | null;