Commit c7cae51
feat(editor)!!: fully refactored package based editor for dx and new features (#1149)
* feat(FileSidebar, CodeEditor, CodeAndPreview): implement file deletion functionality
- Added a dropdown menu in FileSidebar for deleting files, integrating the handleDeleteFile function.
- Updated CodeAndPreview and CodeEditor components to support file deletion, including necessary state management and error handling.
- Introduced DeleteFileProps interface for type safety in file deletion operations.
- Enhanced useFileManagement hook to include handleDeleteFile logic, ensuring proper API interaction and user feedback through toast notifications.
* refactor(CodeAndPreview, useFileManagement, useUpdatePackageFilesMutation): enhance file management logic
- Improved the hasUnsavedChanges logic in CodeAndPreview to account for file count discrepancies.
- Refactored handleDeleteFile in useFileManagement to streamline file deletion and state updates.
- Added logic in useUpdatePackageFilesMutation to handle deletion of files that no longer exist in the package, ensuring proper API interaction and state management.
* Update CodeAndPreview.tsx
* refactor(FileSidebar): improve file path handling and variable naming
- Updated variable names for clarity, changing 'path' to 'filePath', 'parts' to 'pathSegments', 'current' to 'currentNode', and 'isFile' to 'isLeafNode'.
- Enhanced logic for constructing file paths and handling file selection, ensuring consistency and readability.
- Adjusted conditions for file and folder identification to improve code maintainability.
* refactor: update currentFile type to allow null in multiple components
- Changed the type of currentFile from string to string | null in FileSidebar, CodeAndPreview, CodeEditor, and CodeEditorHeader components to handle cases where no file is selected.
- Updated related logic to ensure proper handling of null values, improving robustness and preventing potential runtime errors.
* refactor(CodeAndPreview, useUpdatePackageFilesMutation): rename initialFilesLoad to initiallyLoadedFiles
- Updated the variable name from 'initialFilesLoad' to 'initiallyLoadedFiles' in CodeAndPreview and useUpdatePackageFilesMutation for improved clarity and consistency.
- Adjusted related logic to reflect the new naming, ensuring the functionality remains intact while enhancing code readability.
* refactor(useUpdatePackageFilesMutation): rename newpackage to newPackage for consistency
- Updated the variable name from 'newpackage' to 'newPackage' in useUpdatePackageFilesMutation to enhance clarity and maintain consistency with naming conventions.
- Adjusted related logic to ensure the functionality remains intact while improving code readability.
* refactor(CodeAndPreview, useFileManagement): consolidate file management logic and enhance save functionality
- Moved the handleSave and fsMap functions from CodeAndPreview to useFileManagement for better separation of concerns and improved code organization.
- Updated handleSave to utilize the new parameters and ensure proper state management and file saving logic.
- Refactored the file existence checks in handleCreateFile and handleDeleteFile to use the packageFilesWithContent prop for consistency.
- Enhanced toast notifications for better user feedback during file operations.
* Update src/components/package-port/CodeEditorHeader.tsx
Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
* 1 - local files amangement
* refactor: improve file management logic and enhance code readability across multiple components
* test: add test for create_or_update allowing empty content_text in package files
* 69
* fix: ensure currentFile is defined before formatting and streamline file extension handling in CodeEditorHeader
* fix: correct currentFile access in CodeEditorHeader to ensure proper content retrieval
* fix: refine currentFile handling in CodeEditorHeader for improved file type detection and toast messaging
* feat: implement toggleSidebar function in FileSidebar for improved sidebar management and reset state
* style: update DropdownMenuContent styling in FileSidebar for improved appearance and positioning
* style: adjust width of Select component in CodeEditorHeader for better layout consistency
* fix: update item ID generation in FileSidebar and ensure TreeActions always reflects selection state
* refactor: streamline file selection logic in useFileManagement and update related components for consistency
---------
Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>1 parent c880e5d commit c7cae51
10 files changed
Lines changed: 566 additions & 398 deletions
File tree
- bun-tests/fake-snippets-api/routes/package_files
- fake-snippets-api/routes/api/package_files
- src
- components
- package-port
- ui
- hooks
Lines changed: 26 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
278 | 278 | | |
279 | 279 | | |
280 | 280 | | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
281 | 307 | | |
282 | 308 | | |
283 | 309 | | |
| |||
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
139 | | - | |
| 139 | + | |
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
| |||
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
170 | | - | |
| 170 | + | |
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
9 | 21 | | |
10 | 22 | | |
11 | 23 | | |
12 | 24 | | |
13 | | - | |
| 25 | + | |
14 | 26 | | |
15 | 27 | | |
16 | 28 | | |
17 | | - | |
| 29 | + | |
| 30 | + | |
18 | 31 | | |
19 | 32 | | |
20 | 33 | | |
| |||
24 | 37 | | |
25 | 38 | | |
26 | 39 | | |
| 40 | + | |
27 | 41 | | |
28 | 42 | | |
29 | 43 | | |
30 | 44 | | |
31 | 45 | | |
| 46 | + | |
32 | 47 | | |
33 | 48 | | |
34 | 49 | | |
| |||
38 | 53 | | |
39 | 54 | | |
40 | 55 | | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
45 | 62 | | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
53 | 71 | | |
54 | | - | |
55 | | - | |
| 72 | + | |
| 73 | + | |
56 | 74 | | |
57 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
58 | 78 | | |
59 | 79 | | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
68 | 130 | | |
69 | 131 | | |
70 | 132 | | |
71 | | - | |
72 | | - | |
| 133 | + | |
| 134 | + | |
73 | 135 | | |
74 | 136 | | |
75 | 137 | | |
| |||
90 | 152 | | |
91 | 153 | | |
92 | 154 | | |
93 | | - | |
| 155 | + | |
94 | 156 | | |
95 | | - | |
| 157 | + | |
96 | 158 | | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
101 | 162 | | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
102 | 175 | | |
103 | 176 | | |
104 | 177 | | |
| |||
110 | 183 | | |
111 | 184 | | |
112 | 185 | | |
113 | | - | |
| 186 | + | |
114 | 187 | | |
115 | 188 | | |
116 | 189 | | |
| |||
129 | 202 | | |
130 | 203 | | |
131 | 204 | | |
| 205 | + | |
132 | 206 | | |
133 | 207 | | |
134 | 208 | | |
| |||
149 | 223 | | |
150 | 224 | | |
151 | 225 | | |
152 | | - | |
| 226 | + | |
153 | 227 | | |
154 | 228 | | |
155 | 229 | | |
| |||
0 commit comments