Add files view - #695
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a new files view in the panel and updates the related file management functionality in both the frontend and backend. Key changes include:
- Implementation of a FilesList component with sorting, search, and file replacement functionality.
- Updates to routes, modals, and SCSS to support the new file management interface.
- Major refactoring of file-related controllers (FilesController and PagesController) to use updated permission names, route structures, and enhanced file handling.
Reviewed Changes
Copilot reviewed 42 out of 42 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| panel/src/ts/components/fileslist.ts | New FilesList component with sorting and file actions |
| panel/src/ts/components/files.ts | Instantiation of the new FilesList component |
| panel/src/scss/components/* | Various SCSS updates for improved layout and responsiveness |
| panel/routes.php | Updated file routes and removal of legacy routes |
| formwork/src/Panel/Controllers/PagesController.php | Transition from page鈥恌ile actions to file鈥恠pecific actions |
| formwork/src/Panel/Controllers/FilesController.php | Extensive refactoring to handle file operations |
| formwork/src/Http/* and others | Auxiliary changes to support file uploads and processing |
| formwork/src/Cms/Site.php and formwork/routes.php | Integration of file collections into the site model |
Comment on lines
+306
to
+320
| private function getFiles(): array | ||
| { | ||
| $files = []; | ||
|
|
||
| foreach ($this->site->files() as $fileCollectionItem) { | ||
| $files[] = [$fileCollectionItem, $this->site]; | ||
| } | ||
|
|
||
| foreach ($this->site->descendants() as $pageCollection) { | ||
| foreach ($pageCollection->files() as $fileCollectionItem) { | ||
| $files[] = [$fileCollectionItem, $pageCollection]; | ||
| } | ||
| } | ||
|
|
||
| return Arr::sort($files, sortBy: fn(array $a, array $b) => strnatcasecmp($a[0]->name(), $b[0]->name())); |
There was a problem hiding this comment.
The getFiles() method builds a complete file listing by iterating over all site descendants. This approach may impact performance in large sites, so consider implementing lazy loading or pagination for scalability.
Suggested change
| private function getFiles(): array | |
| { | |
| $files = []; | |
| foreach ($this->site->files() as $fileCollectionItem) { | |
| $files[] = [$fileCollectionItem, $this->site]; | |
| } | |
| foreach ($this->site->descendants() as $pageCollection) { | |
| foreach ($pageCollection->files() as $fileCollectionItem) { | |
| $files[] = [$fileCollectionItem, $pageCollection]; | |
| } | |
| } | |
| return Arr::sort($files, sortBy: fn(array $a, array $b) => strnatcasecmp($a[0]->name(), $b[0]->name())); | |
| private function getFiles(int $offset = 0, int $limit = 50): array | |
| { | |
| $files = []; | |
| // Fetch site files | |
| foreach ($this->site->files() as $fileCollectionItem) { | |
| $files[] = [$fileCollectionItem, $this->site]; | |
| } | |
| // Fetch descendant files | |
| foreach ($this->site->descendants() as $pageCollection) { | |
| foreach ($pageCollection->files() as $fileCollectionItem) { | |
| $files[] = [$fileCollectionItem, $pageCollection]; | |
| } | |
| } | |
| // Sort files | |
| $sortedFiles = Arr::sort($files, sortBy: fn(array $a, array $b) => strnatcasecmp($a[0]->name(), $b[0]->name())); | |
| // Apply pagination | |
| return array_slice($sortedFiles, $offset, $limit); |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.