|
1 |
| -import React from "react"; |
| 1 | +import React, { useState } from "react"; |
2 | 2 | import { RouteComponentProps } from "react-router-dom";
|
3 | 3 | import { GoThreeBars, GoX } from "react-icons/go";
|
4 | 4 | import { BsArrowRightShort } from "react-icons/bs";
|
@@ -37,6 +37,7 @@ interface RepoDetailProps extends RouteComponentProps<Repo> {}
|
37 | 37 | export function RepoDetail(props: RepoDetailProps) {
|
38 | 38 | const { match } = props;
|
39 | 39 | const { owner, name } = match.params;
|
| 40 | + const [showSql, setShowSql] = useState(false); |
40 | 41 | const [filename, setFilename] = useQueryParam("filename", StringParam);
|
41 | 42 | const [selectedSha, setSelectedSha] = useQueryParam("sha", StringParam);
|
42 | 43 | const disclosure = useDisclosureState();
|
@@ -226,6 +227,26 @@ export function RepoDetail(props: RepoDetailProps) {
|
226 | 227 | </a>
|
227 | 228 | </div>
|
228 | 229 | )}
|
| 230 | + |
| 231 | + {Boolean(filename) && ( |
| 232 | + <div className="min-w-0 space-y-2"> |
| 233 | + <div className="mt-6 flex items-center bg-indigo-700 hover:bg-indigo-800 focus:bg-indigo-800 h-9 p-2 rounded text-white text-xs focus:outline-none focus:ring-2 focus:ring-indigo-400 w-full lg:max-w-md"> |
| 234 | + <label className="flex items-center space-x-2 w-full"> |
| 235 | + <input |
| 236 | + checked={showSql} |
| 237 | + onChange={(e) => { |
| 238 | + setShowSql(e.target.checked); |
| 239 | + }} |
| 240 | + className="text-indigo-700 hover:text-indigo-800 focus:text-indigo-800" |
| 241 | + type="checkbox" |
| 242 | + /> |
| 243 | + <span className="text-xs font-medium text-indigo-200 select-none"> |
| 244 | + Show SQL UI |
| 245 | + </span> |
| 246 | + </label> |
| 247 | + </div> |
| 248 | + </div> |
| 249 | + )} |
229 | 250 | </div>
|
230 | 251 | );
|
231 | 252 |
|
@@ -277,22 +298,26 @@ export function RepoDetail(props: RepoDetailProps) {
|
277 | 298 | </div>
|
278 | 299 |
|
279 | 300 | <React.Fragment>
|
280 |
| - {selectedSha && Boolean(filename) && filesStatus !== "error" && ( |
281 |
| - <DBExplorer |
282 |
| - sha={selectedSha} |
283 |
| - filename={filename || ""} |
284 |
| - owner={owner as string} |
285 |
| - name={name as string} |
286 |
| - /> |
287 |
| - // <JSONDetail |
288 |
| - // key={selectedSha} |
289 |
| - // filename={filename || ""} |
290 |
| - // owner={owner as string} |
291 |
| - // name={name as string} |
292 |
| - // previousSha={selectedShaPrevious} |
293 |
| - // sha={selectedSha} |
294 |
| - // /> |
295 |
| - )} |
| 301 | + {selectedSha && |
| 302 | + Boolean(filename) && |
| 303 | + filesStatus !== "error" && |
| 304 | + (showSql ? ( |
| 305 | + <DBExplorer |
| 306 | + sha={selectedSha} |
| 307 | + filename={filename || ""} |
| 308 | + owner={owner as string} |
| 309 | + name={name as string} |
| 310 | + /> |
| 311 | + ) : ( |
| 312 | + <JSONDetail |
| 313 | + key={selectedSha} |
| 314 | + filename={filename || ""} |
| 315 | + owner={owner as string} |
| 316 | + name={name as string} |
| 317 | + previousSha={selectedShaPrevious} |
| 318 | + sha={selectedSha} |
| 319 | + /> |
| 320 | + ))} |
296 | 321 | </React.Fragment>
|
297 | 322 | {match &&
|
298 | 323 | !(files || []).length &&
|
|
0 commit comments