mirror of
https://github.com/coollabsio/coolify.git
synced 2026-08-28 18:14:35 -05:00
Address review feedback and UX issues on the file browser. Editor - Replace the TipTap editor with Monaco, reusing the self-hosted assets. The editor is kept mounted (wire:ignore) and preloaded on page init, and receives content + language via the load-file-editor event, applying the language with setModelLanguage so highlighting is correct without recreating the instance. - Keep the Monaco instance on the DOM node, not in Alpine reactive state, so its object graph is never proxied (that hung and crashed the tab). - Drop @tiptap/*, lowlight and highlight.js; remove the TipTap CSS and JS. - Broaden guessLanguage to Monaco ids and common extension-less/dotfiles. Listing / read (perf) - List a directory in one stat call instead of a per-entry loop (embedding a real tab, since stat -c does not expand \t), and surface owner/group columns. - Fold the read size-cap, binary probe and base64 into one SSH round trip. Actions - Collapse the per-row Edit/Download/Rename/Delete buttons into a 3-dots menu. - Fix actions silently failing on names with apostrophes: the entry name now lives in the row's Alpine scope instead of passing @js() through a component attribute (which double-encodes the quotes). Hardening - Lock client-controllable state (container/type/resource) with #[Locked]. - Re-check guard() in open/goTo/refresh; sanitize upload filenames; clean up the download temp file and report errors; route >96KiB writes through docker cp. Tests updated and extended (32 passing). Frontend rebuild (npm run build) is still needed only to drop TipTap from the bundle; the editor works without it.
44 lines
893 B
PHP
44 lines
893 B
PHP
<?php
|
|
|
|
namespace App\Data;
|
|
|
|
class FileEntry
|
|
{
|
|
public function __construct(
|
|
public string $name,
|
|
public string $type,
|
|
public int $size,
|
|
public int $mtime,
|
|
public string $perms = '',
|
|
public string $owner = '',
|
|
public string $group = '',
|
|
) {}
|
|
|
|
public function isDir(): bool
|
|
{
|
|
return $this->type === 'dir';
|
|
}
|
|
|
|
public function isEditableCandidate(): bool
|
|
{
|
|
return ! $this->isDir();
|
|
}
|
|
|
|
/**
|
|
* @param array<int, self> $entries
|
|
* @return array<int, self>
|
|
*/
|
|
public static function sort(array $entries): array
|
|
{
|
|
usort($entries, function (self $a, self $b) {
|
|
if ($a->isDir() !== $b->isDir()) {
|
|
return $a->isDir() ? -1 : 1;
|
|
}
|
|
|
|
return strcasecmp($a->name, $b->name);
|
|
});
|
|
|
|
return $entries;
|
|
}
|
|
}
|