-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add files dialog to inspect build files (#114)
* allow viewing files * introduce files dialog to inspect build files * add file dialog to playwright tests * format
- Loading branch information
Showing
15 changed files
with
107 additions
and
3 deletions.
There are no files selected for viewing
File renamed without changes.
Binary file removed
BIN
-64.2 KB
playwright-tests/snapshots/qucikstart-page.spec.ts-Quickstart-Pagelg.png
Binary file not shown.
Binary file removed
BIN
-48.3 KB
playwright-tests/snapshots/qucikstart-page.spec.ts-Quickstart-Pagemd.png
Binary file not shown.
Binary file removed
BIN
-26.7 KB
playwright-tests/snapshots/qucikstart-page.spec.ts-Quickstart-Pagexs.png
Binary file not shown.
Binary file added
BIN
+67.7 KB
playwright-tests/snapshots/quickstart-page.spec.ts-Quickstart-Pagelg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+51.5 KB
playwright-tests/snapshots/quickstart-page.spec.ts-Quickstart-Pagemd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+30.6 KB
playwright-tests/snapshots/quickstart-page.spec.ts-Quickstart-Pagexs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+63.1 KB
playwright-tests/snapshots/view-snippet.spec.ts-view-snippet-files.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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,69 @@ | ||
import React, { useState } from "react" | ||
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "../ui/dialog" | ||
import { ScrollArea } from "../ui/scroll-area" | ||
import { cn } from "@/lib/utils" | ||
import { createUseDialog } from "./create-use-dialog" | ||
import { useSnippet } from "@/hooks/use-snippet" | ||
|
||
interface FilesDialogProps { | ||
open: boolean | ||
onOpenChange: (open: boolean) => void | ||
snippetId: string | ||
} | ||
|
||
export const FilesDialog: React.FC<FilesDialogProps> = ({ | ||
open, | ||
onOpenChange, | ||
snippetId, | ||
}) => { | ||
const { data: snippet } = useSnippet(snippetId) | ||
|
||
const files = Object.entries({ | ||
"dist/index.d.ts": snippet?.dts || "", | ||
"index.ts": snippet?.code || "", | ||
"dist/index.js": snippet?.compiled_js || "", | ||
}) | ||
.sort(([a], [b]) => a.localeCompare(b)) | ||
.reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {}) | ||
|
||
const [selectedFile, setSelectedFile] = useState<string | null>("index.ts") | ||
|
||
return ( | ||
<Dialog open={open} onOpenChange={onOpenChange}> | ||
<DialogContent className="max-w-4xl w-full h-[80vh] flex flex-col"> | ||
<DialogHeader> | ||
<DialogTitle>Files</DialogTitle> | ||
</DialogHeader> | ||
<div className="flex flex-grow overflow-hidden"> | ||
<div className="w-1/4 border-r"> | ||
<ScrollArea className="h-full"> | ||
{Object.keys(files).map((filePath) => ( | ||
<div | ||
key={filePath} | ||
className={cn( | ||
"px-4 py-2 cursor-pointer hover:bg-gray-100 text-xs", | ||
selectedFile === filePath && "bg-gray-200", | ||
)} | ||
onClick={() => setSelectedFile(filePath)} | ||
> | ||
{filePath} | ||
</div> | ||
))} | ||
</ScrollArea> | ||
</div> | ||
<div className="w-3/4 overflow-hidden"> | ||
<ScrollArea className="h-full"> | ||
<pre className="p-4 text-xs whitespace-pre-wrap"> | ||
{selectedFile | ||
? files[selectedFile as keyof typeof files] | ||
: "Select a file"} | ||
</pre> | ||
</ScrollArea> | ||
</div> | ||
</div> | ||
</DialogContent> | ||
</Dialog> | ||
) | ||
} | ||
|
||
export const useFilesDialog = createUseDialog(FilesDialog) |
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