-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(feat) add header tab for response (#20)
* (feat) add tabs for response window * (fix) fix editor height * (improv) add teable to headers * (improv) map response headers * (improv) remove response cookies * (improv) use height % instead of flex * (improv) minor css change * (improv) change size of icon * (improv) minor editor css change
- Loading branch information
1 parent
94f08ed
commit 8bc2173
Showing
23 changed files
with
385 additions
and
264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.request-options-window-wrapper { | ||
flex: 1; | ||
padding: 5px 20px 10px 20px; | ||
overflow: scroll; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import * as React from "react"; | ||
import { ResponseTab } from "../../features/response/ResponseTab"; | ||
import { ResponseWindow } from "../../features/response/ResponseWindow"; | ||
import { ReactComponent as PackageIcon } from "../../icons/package.svg"; | ||
import "./styles.css"; | ||
import { useAppSelector } from "../../redux/hooks"; | ||
import { selectResponse } from "../../features/response/responseSlice"; | ||
import { supportedLangs } from "../../constants/supported-langs"; | ||
|
||
export const Response = () => { | ||
const response = useAppSelector(selectResponse); | ||
const [selected, setSelected] = React.useState("body"); | ||
const [language, setLanguage] = React.useState(supportedLangs[0].value); | ||
|
||
if (response.loading) { | ||
return ( | ||
<div className="loader-wrapper"> | ||
<div>Sending request ...</div> | ||
<div className="loader" /> | ||
</div> | ||
); | ||
} else if (response.initial) { | ||
return ( | ||
<div className="initial-response-wrapper"> | ||
<div className="initial-text">Hit Send to get a response</div> | ||
<PackageIcon className="img-initial-response" /> | ||
</div> | ||
); | ||
} else if (response.error) { | ||
return ( | ||
<div className="error-response-wrapper"> | ||
<div>Could not send request</div> | ||
<div className="error-message">{`Error: ${response.error.message}`}</div> | ||
<PackageIcon className="img-error-response" /> | ||
</div> | ||
); | ||
} else { | ||
return ( | ||
<div className="response-body-wrapper"> | ||
<ResponseTab | ||
selected={selected} | ||
setSelected={setSelected} | ||
language={language} | ||
setLanguage={setLanguage} | ||
/> | ||
<ResponseWindow selected={selected} language={language} /> | ||
</div> | ||
); | ||
} | ||
}; |
85 changes: 30 additions & 55 deletions
85
...iew/features/response/Response/styles.css → webview/components/Response/styles.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export const responseOptions = [ | ||
{ | ||
name: "Body", | ||
value: "body", | ||
}, | ||
{ | ||
name: "Headers", | ||
value: "headers", | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,5 @@ | |
} | ||
|
||
.raw-editor { | ||
height: 100%; | ||
height: 95%; | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import * as React from "react"; | ||
import "./styles.css"; | ||
import { useAppSelector } from "../../../redux/hooks"; | ||
import { selectResponse } from "../responseSlice"; | ||
import * as propTypes from "prop-types"; | ||
|
||
const Editor = React.lazy(() => import("../../../shared/Editor")); | ||
|
||
export const ResponseBody = (props) => { | ||
const { language } = props; | ||
const response = useAppSelector(selectResponse); | ||
|
||
return ( | ||
<div className="response-window"> | ||
<React.Suspense fallback={<div>loading</div>}> | ||
<Editor | ||
className="response-editor" | ||
value={response.data || ""} | ||
language={language} | ||
readOnly | ||
copyButton | ||
format | ||
/> | ||
</React.Suspense> | ||
</div> | ||
); | ||
}; | ||
|
||
ResponseBody.propTypes = { | ||
language: propTypes.string.isRequired, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.response-window { | ||
height: 100%; | ||
} | ||
|
||
.response-editor { | ||
height: 95%; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import * as React from "react"; | ||
import { useAppSelector } from "../../../redux/hooks"; | ||
import { KeyValueTable } from "../../../shared/KeyValueTable"; | ||
import { selectResponseHeaders } from "../responseSlice"; | ||
import "./styles.css"; | ||
|
||
export const ResponseHeaders = () => { | ||
const headers = useAppSelector(selectResponseHeaders); | ||
|
||
return ( | ||
<div className="response-headers"> | ||
<KeyValueTable data={headers} fixed /> | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.