$ show cockpit-project/cockpit-files
This repository implements the Cockpit Files module, a file manager web application embedded in the Cockpit server administration console. It provides directory browsing in list/grid views, breadcrumbs and GTK bookmarks, file upload/download with conflict handling, copy/paste, create/delete/rename/symlink operations, permission and ownership editing (including recursion and SELinux context display), and a modal text editor with change detection. The UI is a React 18/TypeScript SPA using PatternFly 6, packaged as a Cockpit manifest module with translations in 20+ languages. Architecture is a browser-side React application that talks to the Linux host exclusively through Cockpit's bridge APIs: directory listing via FsInfoClient, file operations via cockpit.spawn invoking standard CLI tools, streamed upload/download via fsreplace1/fsread1 channels, and a small embedded Python helper for reading SELinux xattrs. The custom esbuild build system bundles src into dist, injecting generated file-type mappings and PO translations at build time. There is no server-side application logic or data pipeline; the code is all presentation and client orchestration. Code quality is professional: components are separated by concern, dialogs use a coherent framework, and the integration test suite exercises major workflows in a real VM through Cockpit's testlib. However, the module is tightly coupled to Cockpit's internal React libraries and bridge protocol, and several HACK comments document workarounds for bridge limitations. Maintenance is active, with CI, Weblate translation sync, and packaging for RPM/Debian/Arch. Outside Cockpit, only the file-type lookup/plugin components are portable; the rest is module-specific.
The LLM identified 3 files worth highlighting for reuse:
Pure JavaScript longest-extension lookup for classifying files by type. It receives generated JSON data from the build plugin and has no Cockpit dependencies, making it easily extractable into any frontend that needs file-type icons or category labels based on filename/extensions.
An esbuild plugin that compiles mime-db, GitHub language-map, and a hand-maintained archive-format list into a compact lookup table for the file-type module. Demonstrates a clean, reusable pattern for transforming npm data packages into optimized frontend assets at build time, portable to other projects using esbuild.
A small self-contained Python helper that reads security.selinux extended attributes to display SELinux context on files. It is embedded as text and executed by Cockpit's Python bridge, but the script itself is generic Linux xattr reading and could be reused in other file-management or system-admin tools.