diff --git a/guide/results-viewer-react/src/components/Modal/index.tsx b/guide/results-viewer-react/src/components/Modal/index.tsx index d20d0d2c..71bc1ec2 100644 --- a/guide/results-viewer-react/src/components/Modal/index.tsx +++ b/guide/results-viewer-react/src/components/Modal/index.tsx @@ -93,6 +93,7 @@ interface ModalProps { children?: React.ReactNode; isReady?: boolean; scrollable?: boolean; + initialDisplay?: boolean; } export interface ModalObject { @@ -136,9 +137,10 @@ export const Modal = forwardRef(({ submitText = "submit", children, isReady, - scrollable + scrollable, + initialDisplay = false }: ModalProps, ref: Ref) => { - const [display, setDisplay] = useState(false); + const [display, setDisplay] = useState(initialDisplay); let windowOffset: number = 0; useImperativeHandle(ref, () => { diff --git a/guide/results-viewer-react/src/components/YamlUrls/QueryParamsView.tsx b/guide/results-viewer-react/src/components/YamlUrls/QueryParamsView.tsx new file mode 100644 index 00000000..2932b0b0 --- /dev/null +++ b/guide/results-viewer-react/src/components/YamlUrls/QueryParamsView.tsx @@ -0,0 +1,68 @@ +import { PewPewHeader, PewPewQueryParam } from "../../util/yamlwriter"; +import { PewPewQueryParamStringType } from "."; +import React from "react"; + +export interface QueryParamsViewProps { + id: string; + queryParamList: PewPewQueryParam[]; + removeParam: (param: PewPewQueryParam) => void; + changeParam: (paramIndex: number, type: PewPewQueryParamStringType, value: string) => void; + addParam: () => void; +} + +function QueryParamsView ({ id, queryParamList, removeParam, changeParam, addParam }: QueryParamsViewProps): JSX.Element { + const styles: Record = { + headersDisplay: { + marginTop: "10px", + maxHeight: "300px", + overflow: "auto" + }, + gridContainer: { + display: "grid", + gap: "10px" + }, + gridHeader: { + display: "grid", + gridTemplateColumns: "auto 1fr 2fr", + gap: "10px", + fontWeight: "bold", + height: "20px" + }, + gridRows: { + display: "grid", + gridTemplateColumns: "auto 1fr 2fr", + gap: "10px", + alignItems: "stretch" + }, + input: { + boxSizing: "border-box" + }, + button: { + boxSizing: "border-box", + whiteSpace: "nowrap" + } + }; + return ( + +
+
+
+ + Name + Value +
+ {queryParamList.length === 0 && No Query Params yet, click "+" to create one} + {queryParamList.map((param: PewPewHeader, index: number) => ( +
+ + changeParam(index, "name", event.target.value)} /> + changeParam(index, "value", event.target.value)} /> +
+ ))} +
+
+
+ ); +} + +export default QueryParamsView; \ No newline at end of file diff --git a/guide/results-viewer-react/src/components/YamlUrls/RequestBodyView.tsx b/guide/results-viewer-react/src/components/YamlUrls/RequestBodyView.tsx new file mode 100644 index 00000000..7ef86b34 --- /dev/null +++ b/guide/results-viewer-react/src/components/YamlUrls/RequestBodyView.tsx @@ -0,0 +1,46 @@ +import { LogLevel, log } from "../../util/log"; +import React from "react"; + +export interface RequestBodyViewProps { + requestBody: object | undefined; + updateRequestBody: (newRequestBody: object) => void; +} + +function RequestBodyView ({ requestBody, updateRequestBody }: RequestBodyViewProps): JSX.Element { + const [requestBodyInEdit, setRequestBodyInEdit] = React.useState(JSON.stringify(requestBody, null, 2).replace(/\\n/g, "\n").replace(/^"|"$/g, "")); + + const requestBodyDisplayStyle: React.CSSProperties = { + fontFamily: "monospace", + width: "100%", + height: "270px", + overflow: "auto", + border: "1px solid #ccc", + padding: "10px", + backgroundColor: "#2e3438", + resize: "none", + tabSize: 2, + boxSizing: "border-box" + }; + + const handleEditorInput = (event: React.ChangeEvent) => { + const newRequestBody = event.target.value; + setRequestBodyInEdit(newRequestBody); + try { + updateRequestBody(JSON.parse(newRequestBody)); + } catch (error) { + log("Invalid JSON", LogLevel.WARN, error); + } + }; + + return ( + +