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:
@@ -40,8 +40,8 @@ class _ShareFileDialogState extends State<ShareFileDialog> {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
final apiClient = getIt<ApiClient>();
|
final apiClient = getIt<ApiClient>();
|
||||||
final path = widget.orgId == 'files'
|
final path = widget.orgId.isEmpty
|
||||||
? '/user/files/${widget.fileId}/share'
|
? '/orgs/files/${widget.fileId}/share'
|
||||||
: '/orgs/${widget.orgId}/files/${widget.fileId}/share';
|
: '/orgs/${widget.orgId}/files/${widget.fileId}/share';
|
||||||
final response = await apiClient.getRaw(path);
|
final response = await apiClient.getRaw(path);
|
||||||
|
|
||||||
@@ -68,8 +68,8 @@ class _ShareFileDialogState extends State<ShareFileDialog> {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
final apiClient = getIt<ApiClient>();
|
final apiClient = getIt<ApiClient>();
|
||||||
final path = widget.orgId == 'files'
|
final path = widget.orgId.isEmpty
|
||||||
? '/user/files/${widget.fileId}/share'
|
? '/orgs/files/${widget.fileId}/share'
|
||||||
: '/orgs/${widget.orgId}/files/${widget.fileId}/share';
|
: '/orgs/${widget.orgId}/files/${widget.fileId}/share';
|
||||||
final response = await apiClient.postRaw(path, data: {});
|
final response = await apiClient.postRaw(path, data: {});
|
||||||
|
|
||||||
@@ -93,8 +93,8 @@ class _ShareFileDialogState extends State<ShareFileDialog> {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
final apiClient = getIt<ApiClient>();
|
final apiClient = getIt<ApiClient>();
|
||||||
final path = widget.orgId == 'files'
|
final path = widget.orgId.isEmpty
|
||||||
? '/user/files/${widget.fileId}/share'
|
? '/orgs/files/${widget.fileId}/share'
|
||||||
: '/orgs/${widget.orgId}/files/${widget.fileId}/share';
|
: '/orgs/${widget.orgId}/files/${widget.fileId}/share';
|
||||||
await apiClient.delete(path);
|
await apiClient.delete(path);
|
||||||
|
|
||||||
@@ -197,11 +197,39 @@ class _ShareFileDialogState extends State<ShareFileDialog> {
|
|||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text(
|
child: TextField(
|
||||||
_shareUrl!,
|
controller: TextEditingController(text: _shareUrl),
|
||||||
|
readOnly: true,
|
||||||
maxLines: 2,
|
maxLines: 2,
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: TextStyle(color: AppTheme.primaryText),
|
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),
|
const SizedBox(width: 16),
|
||||||
|
|||||||
BIN
go_cloud/api
BIN
go_cloud/api
Binary file not shown.
@@ -221,6 +221,17 @@ func NewRouter(cfg *config.Config, db *database.DB, jwtManager *jwt.Manager, aut
|
|||||||
revokeUserFileShareLinkHandler(w, req, db)
|
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
|
// Org routes
|
||||||
r.Get("/orgs", func(w http.ResponseWriter, req *http.Request) {
|
r.Get("/orgs", func(w http.ResponseWriter, req *http.Request) {
|
||||||
listOrgsHandler(w, req, db)
|
listOrgsHandler(w, req, db)
|
||||||
|
|||||||
Reference in New Issue
Block a user