Skip to content

Add files view - #695

Merged
giuscris merged 6 commits into
2.xfrom
feature/files-view
Jun 3, 2025
Merged

Add files view#695
giuscris merged 6 commits into
2.xfrom
feature/files-view

Conversation

@giuscris

@giuscris giuscris commented Jun 1, 2025

Copy link
Copy Markdown
Member

No description provided.

@giuscris giuscris added this to the 2.0.0 milestone Jun 1, 2025
@giuscris giuscris self-assigned this Jun 1, 2025
@giuscris giuscris added the enhancement New feature or request label Jun 1, 2025
@giuscris
giuscris requested a review from Copilot June 1, 2025 01:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()));

Copilot AI Jun 1, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);

Copilot uses AI. Check for mistakes.
@giuscris
giuscris merged commit b507392 into 2.x Jun 3, 2025
@giuscris
giuscris deleted the feature/files-view branch June 3, 2025 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants