Files
pipelines/app/lib/features/chat/files/files_upload_notice.dart
T
alan 4733d4b615 Rename, move and delete entries from the chat Files panel
Every row and tile menu gains Rename…, Move… and Delete… (folders now
have a menu too). Rename prefills the name with the file's stem selected
and applies the server's name rules inline. Move reuses the chat folder
picker through a FolderPickerPurpose: titled for the entry, confirmed
with Move here, never offering the entry's current folder and keeping a
moved folder's own subtree out of reach. Delete confirms, and when the
server reports a folder with contents asks once more before deleting
recursively. Holding an entry and dropping it on a folder row or tile
moves it there; the target highlights and refuses itself and ancestors.

FilesController performs each request through files_mutations.dart,
shows Renaming…/Moving…/Deleting… progress, reloads the shown folder
afterwards and keeps a refusal in the server's words in the panel's
notice until dismissed.
2026-11-09 01:46:28 +00:00

85 lines
2.6 KiB
Dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../ui/sessions/chat_adaptive.dart';
import 'files_controller.dart';
/// The Files panel's operation feedback: a progress strip while files are
/// being stored or an entry is being renamed, moved or deleted, and the
/// server's refusal (exists, sign in, too large, not empty, outside home)
/// until the operator dismisses it. These are separate from the folder error,
/// whose Retry reloads the listing.
class FilesUploadNotice extends StatelessWidget {
const FilesUploadNotice({super.key, required this.controller});
final FilesController controller;
@override
Widget build(BuildContext context) {
final cupertino =
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
final progress = controller.uploading > 0
? controller.uploadLabel
: controller.mutationLabel;
return Column(
children: [
if (progress != null)
Semantics(
label: progress,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
child: Row(
children: [
Expanded(
child: cupertino
? const CupertinoActivityIndicator()
: const LinearProgressIndicator(),
),
const SizedBox(width: 12),
Text(progress),
],
),
),
),
if (controller.uploadError != null)
_Refusal(
cupertino: cupertino,
message: controller.uploadError!,
onDismiss: controller.dismissUploadError,
),
if (controller.mutationError != null)
_Refusal(
cupertino: cupertino,
message: controller.mutationError!,
onDismiss: controller.dismissMutationError,
),
],
);
}
}
class _Refusal extends StatelessWidget {
const _Refusal({
required this.cupertino,
required this.message,
required this.onDismiss,
});
final bool cupertino;
final String message;
final VoidCallback onDismiss;
@override
Widget build(BuildContext context) => cupertino
? ChatCupertinoMessage(
message: message,
icon: CupertinoIcons.exclamationmark_circle,
actionLabel: 'Dismiss',
onAction: onDismiss,
)
: MaterialBanner(
content: Text(message),
actions: [
TextButton(onPressed: onDismiss, child: const Text('Dismiss')),
],
);
}