Fix file sharing: add backend routes for /orgs/files/{fileId}/share, update frontend ShareFileDialog to use correct paths and improve UI

This commit is contained in:
Leon Bösche
2026-01-24 22:47:27 +01:00
parent 228a5c9644
commit c7aab0b026
3 changed files with 48 additions and 9 deletions

View File

@@ -40,8 +40,8 @@ class _ShareFileDialogState extends State<ShareFileDialog> {
try {
final apiClient = getIt<ApiClient>();
final path = widget.orgId == 'files'
? '/user/files/${widget.fileId}/share'
final path = widget.orgId.isEmpty
? '/orgs/files/${widget.fileId}/share'
: '/orgs/${widget.orgId}/files/${widget.fileId}/share';
final response = await apiClient.getRaw(path);
@@ -68,8 +68,8 @@ class _ShareFileDialogState extends State<ShareFileDialog> {
try {
final apiClient = getIt<ApiClient>();
final path = widget.orgId == 'files'
? '/user/files/${widget.fileId}/share'
final path = widget.orgId.isEmpty
? '/orgs/files/${widget.fileId}/share'
: '/orgs/${widget.orgId}/files/${widget.fileId}/share';
final response = await apiClient.postRaw(path, data: {});
@@ -93,8 +93,8 @@ class _ShareFileDialogState extends State<ShareFileDialog> {
try {
final apiClient = getIt<ApiClient>();
final path = widget.orgId == 'files'
? '/user/files/${widget.fileId}/share'
final path = widget.orgId.isEmpty
? '/orgs/files/${widget.fileId}/share'
: '/orgs/${widget.orgId}/files/${widget.fileId}/share';
await apiClient.delete(path);
@@ -197,11 +197,39 @@ class _ShareFileDialogState extends State<ShareFileDialog> {
Row(
children: [
Expanded(
child: Text(
_shareUrl!,
child: TextField(
controller: TextEditingController(text: _shareUrl),
readOnly: true,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(color: AppTheme.primaryText),
decoration: InputDecoration(
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
borderSide: BorderSide(
color: AppTheme.secondaryText.withValues(
alpha: 0.3,
),
),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
borderSide: BorderSide(
color: AppTheme.secondaryText.withValues(
alpha: 0.3,
),
),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
borderSide: BorderSide(
color: AppTheme.accentColor,
),
),
contentPadding: const EdgeInsets.symmetric(
horizontal: 12,
vertical: 8,
),
),
),
),
const SizedBox(width: 16),

Binary file not shown.

View File

@@ -221,6 +221,17 @@ func NewRouter(cfg *config.Config, db *database.DB, jwtManager *jwt.Manager, aut
revokeUserFileShareLinkHandler(w, req, db)
})
// Share link management for personal files (alternative path for frontend compatibility)
r.Get("/orgs/files/{fileId}/share", func(w http.ResponseWriter, req *http.Request) {
getUserFileShareLinkHandler(w, req, db)
})
r.Post("/orgs/files/{fileId}/share", func(w http.ResponseWriter, req *http.Request) {
createUserFileShareLinkHandler(w, req, db)
})
r.Delete("/orgs/files/{fileId}/share", func(w http.ResponseWriter, req *http.Request) {
revokeUserFileShareLinkHandler(w, req, db)
})
// Org routes
r.Get("/orgs", func(w http.ResponseWriter, req *http.Request) {
listOrgsHandler(w, req, db)