Skip to content

Commit

Permalink
Merge pull request #1955 from ardriveapp/PE-7408-user-cant-rename-a-d…
Browse files Browse the repository at this point in the history
…rive-if-the-name-is-already-in-use-by-another-drive

PE-7408: fix(rename drive)
  • Loading branch information
thiagocarvalhodev authored Jan 10, 2025
2 parents d0dc5df + 9cf3b9a commit 062caa0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
3 changes: 2 additions & 1 deletion lib/blocs/drive_rename/drive_rename_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class DriveRenameCubit extends Cubit<DriveRenameState> {

Future<void> submit({
required String newName,
bool proceedIfHasConflicts = false,
}) async {
try {
final profile = _profileCubit.state as ProfileLoggedIn;
Expand All @@ -47,7 +48,7 @@ class DriveRenameCubit extends Cubit<DriveRenameState> {
return;
}

if (await _fileWithSameNameExistis(newName)) {
if (await _fileWithSameNameExistis(newName) && !proceedIfHasConflicts) {
final previousState = state;
emit(DriveNameAlreadyExists(newName));
emit(previousState);
Expand Down
30 changes: 23 additions & 7 deletions lib/components/drive_rename_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class _DriveRenameFormState extends State<DriveRenameForm> {
showProgressDialog(
context,
title: appLocalizationsOf(context).renamingDriveEmphasized,
useNewArDriveUI: true,
);
} else if (state is DriveRenameSuccess) {
context.read<DriveDetailCubit>().refreshDriveDataTable();
Expand All @@ -87,20 +88,35 @@ class _DriveRenameFormState extends State<DriveRenameForm> {
} else if (state is DriveNameAlreadyExists) {
showStandardDialog(
context,
title: appLocalizationsOf(context).error,
description: appLocalizationsOf(context).entityAlreadyExists(
state.driveName,
),
title: 'Warning',
description:
'A drive with this name already exists. Do you want to proceed?',
useNewArDriveUI: true,
actions: [
ModalAction(
action: () => Navigator.of(context).pop(),
title: 'Cancel',
),
ModalAction(
action: () {
Navigator.of(context).pop();
return context.read<DriveRenameCubit>().submit(
newName: controller.text,
proceedIfHasConflicts: true,
);
},
title: 'Proceed',
),
],
);
Navigator.pop(context);
}
},
builder: (context, state) => ArDriveStandardModal(
builder: (context, state) => ArDriveStandardModalNew(
title: appLocalizationsOf(context).renameDriveEmphasized,
content: state is! FsEntryRenameInitializing
? SizedBox(
width: kMediumDialogWidth,
child: ArDriveTextField(
child: ArDriveTextFieldNew(
controller: controller,
autofocus: true,
validator: (value) {
Expand Down

0 comments on commit 062caa0

Please sign in to comment.