Skip to content

feat: rename a folder/file (WPB-18314) #4080

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ import com.wire.kalium.cells.domain.usecase.CreateFolderUseCase
import com.wire.kalium.cells.domain.usecase.DeleteCellAssetUseCase
import com.wire.kalium.cells.domain.usecase.DownloadCellFileUseCase
import com.wire.kalium.cells.domain.usecase.GetFoldersUseCase
import com.wire.kalium.cells.domain.usecase.GetPaginatedNodesUseCase
import com.wire.kalium.cells.domain.usecase.GetPaginatedFilesFlowUseCase
import com.wire.kalium.cells.domain.usecase.GetPaginatedNodesUseCase
import com.wire.kalium.cells.domain.usecase.MoveNodeUseCase
import com.wire.kalium.cells.domain.usecase.ObserveAttachmentDraftsUseCase
import com.wire.kalium.cells.domain.usecase.PublishAttachmentsUseCase
import com.wire.kalium.cells.domain.usecase.RefreshCellAssetStateUseCase
import com.wire.kalium.cells.domain.usecase.RemoveAttachmentDraftUseCase
import com.wire.kalium.cells.domain.usecase.RemoveAttachmentDraftsUseCase
import com.wire.kalium.cells.domain.usecase.RenameNodeUseCase
import com.wire.kalium.cells.domain.usecase.RestoreNodeFromRecycleBinUseCase
import com.wire.kalium.cells.domain.usecase.RetryAttachmentUploadUseCase
import com.wire.kalium.cells.domain.usecase.SetWireCellForConversationUseCase
Expand Down Expand Up @@ -141,4 +142,9 @@ class CellsModule {
@Provides
fun provideRestoreNodeFromRecycleBinUseCase(cellsScope: CellsScope): RestoreNodeFromRecycleBinUseCase =
cellsScope.restoreNodeFromRecycleBin

@ViewModelScoped
@Provides
fun provideRenameNodeUseCase(cellsScope: CellsScope): RenameNodeUseCase =
cellsScope.renameNodeUseCase
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import com.wire.android.feature.cells.ui.destinations.CreateFolderScreenDestinat
import com.wire.android.feature.cells.ui.destinations.MoveToFolderScreenDestination
import com.wire.android.feature.cells.ui.destinations.PublicLinkScreenDestination
import com.wire.android.feature.cells.ui.destinations.RecycleBinScreenDestination
import com.wire.android.feature.cells.ui.destinations.RenameNodeScreenDestination
import com.wire.android.feature.sketch.destinations.DrawingCanvasScreenDestination
import com.wire.android.ui.NavGraphs

Expand All @@ -39,6 +40,7 @@ object WireMainNavGraph : NavGraphSpec {
.plus(CreateFolderScreenDestination)
.plus(MoveToFolderScreenDestination)
.plus(RecycleBinScreenDestination)
.plus(RenameNodeScreenDestination)
override val destinationsByRoute = destinations.associateBy { it.route }
override val nestedNavGraphs = NavGraphs.root.nestedNavGraphs
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import androidx.compose.ui.platform.LocalSoftwareKeyboardController
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import com.wire.android.R
import com.wire.android.ui.common.ShakeAnimation
import com.wire.android.ui.common.animation.ShakeAnimation
import com.wire.android.ui.common.error.CoreFailureErrorDialog
import com.wire.android.ui.common.textfield.DefaultEmailDone
import com.wire.android.ui.common.textfield.WireTextField
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardType
import com.wire.android.R
import com.wire.android.ui.common.Icon
import com.wire.android.ui.common.ShakeAnimation
import com.wire.android.ui.common.animation.ShakeAnimation
import com.wire.android.ui.common.button.WireButtonState
import com.wire.android.ui.common.button.WirePrimaryButton
import com.wire.android.ui.common.dimensions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import com.ramcosta.composedestinations.spec.DestinationStyle
import com.wire.android.R
import com.wire.android.navigation.Navigator
import com.wire.android.navigation.annotation.app.WireDestination
import com.wire.android.ui.common.ShakeAnimation
import com.wire.android.ui.common.animation.ShakeAnimation
import com.wire.android.ui.common.button.WireButtonState.Default
import com.wire.android.ui.common.button.WireButtonState.Disabled
import com.wire.android.ui.common.button.WirePrimaryButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ import com.ramcosta.composedestinations.annotation.RootNavGraph
import com.ramcosta.composedestinations.result.ResultBackNavigator
import com.ramcosta.composedestinations.spec.DestinationStyle
import com.wire.android.R
import com.wire.android.model.DisplayNameState
import com.wire.android.navigation.Navigator
import com.wire.android.navigation.annotation.app.WireDestination
import com.wire.android.ui.common.Icon
import com.wire.android.ui.common.ShakeAnimation
import com.wire.android.ui.common.animation.ShakeAnimation
import com.wire.android.ui.common.button.WireButtonState.Default
import com.wire.android.ui.common.button.WireButtonState.Disabled
import com.wire.android.ui.common.button.WirePrimaryButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.wire.android.model.DisplayNameState
import com.wire.android.ui.common.textfield.textAsFlow
import com.wire.kalium.logic.feature.user.DisplayNameUpdateResult
import com.wire.kalium.logic.feature.user.GetSelfUserUseCase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import androidx.compose.foundation.text.input.setTextAndPlaceCursorAtEnd
import com.wire.android.config.CoroutineTestExtension
import com.wire.android.config.SnapshotExtension
import com.wire.android.framework.TestUser
import com.wire.android.model.DisplayNameState
import com.wire.kalium.common.error.CoreFailure
import com.wire.kalium.logic.feature.user.DisplayNameUpdateResult
import com.wire.kalium.logic.feature.user.GetSelfUserUseCase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Wire
* Copyright (C) 2024 Wire Swiss GmbH
* Copyright (C) 2025 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -16,7 +16,7 @@
* along with this program. If not, see http://www.gnu.org/licenses/.
*/

package com.wire.android.ui.home.settings.account.displayname
package com.wire.android.model

data class DisplayNameState(
val loading: Boolean = false,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Wire
* Copyright (C) 2024 Wire Swiss GmbH
* Copyright (C) 2025 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -16,7 +16,7 @@
* along with this program. If not, see http://www.gnu.org/licenses/.
*/

package com.wire.android.ui.common
package com.wire.android.ui.common.animation

import androidx.compose.animation.core.Animatable
import androidx.compose.animation.core.keyframes
Expand All @@ -27,6 +27,7 @@ import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.unit.Dp
import com.wire.android.ui.common.dimensions
import kotlinx.coroutines.launch

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ fun AllFilesScreen(
)
)
},
showMoveToFolderScreen = { _, _, _ -> }
showMoveToFolderScreen = { _, _, _ -> },
showRenameScreen = {}
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ internal fun CellScreenContent(
downloadFileState: StateFlow<CellNodeUi.File?>,
menuState: Flow<MenuOptions?>,
showPublicLinkScreen: (PublicLinkScreenData) -> Unit,
showRenameScreen: (CellNodeUi) -> Unit,
showMoveToFolderScreen: (String, String, String) -> Unit,
isAllFiles: Boolean,
isSearchResult: Boolean = false,
Expand Down Expand Up @@ -164,7 +165,7 @@ internal fun CellScreenContent(
isFolder = action.cellNode is CellNodeUi.Folder
)
)

is ShowRenameScreen -> showRenameScreen(action.cellNode)
is ShowMoveToFolderScreen -> showMoveToFolderScreen(action.currentPath, action.nodeToMovePath, action.uuid)
is RefreshData -> pagingListItems.refresh()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class CellViewModel @Inject constructor(
sendAction(ShowError(CellError.OTHER_ERROR))
return@launch
}
//

val (nodeName, nodeRemotePath) = when (node) {
is CellNodeUi.File -> Pair(node.name, node.remotePath)
is CellNodeUi.Folder -> Pair(node.name + ZIP_EXTENSION, node.remotePath + ZIP_EXTENSION)
Expand Down Expand Up @@ -262,6 +262,7 @@ class CellViewModel @Inject constructor(
add(NodeBottomSheetAction.PUBLIC_LINK)
}
add(NodeBottomSheetAction.MOVE)
add(NodeBottomSheetAction.RENAME)
add(NodeBottomSheetAction.DELETE)
}
}
Expand All @@ -280,6 +281,7 @@ class CellViewModel @Inject constructor(
add(NodeBottomSheetAction.SHARE)
add(NodeBottomSheetAction.DOWNLOAD)
add(NodeBottomSheetAction.MOVE)
add(NodeBottomSheetAction.RENAME)
add(NodeBottomSheetAction.DELETE)
}
}
Expand Down Expand Up @@ -315,6 +317,7 @@ class CellViewModel @Inject constructor(
)
}

NodeBottomSheetAction.RENAME -> sendAction(ShowRenameScreen(node))
NodeBottomSheetAction.DOWNLOAD -> downloadNode(node)
NodeBottomSheetAction.RESTORE -> sendAction(ShowRestoreConfirmation(node = node))
NodeBottomSheetAction.DELETE -> sendAction(ShowDeleteConfirmation(node = node, isPermanentDelete = false))
Expand Down Expand Up @@ -407,6 +410,7 @@ internal data class ShowDeleteConfirmation(val node: CellNodeUi, val isPermanent
internal data class ShowRestoreConfirmation(val node: CellNodeUi) : CellViewAction
internal data class ShowError(val error: CellError) : CellViewAction
internal data class ShowPublicLinkScreen(val cellNode: CellNodeUi) : CellViewAction
internal data class ShowRenameScreen(val cellNode: CellNodeUi) : CellViewAction
internal data class ShowMoveToFolderScreen(val currentPath: String, val nodeToMovePath: String, val uuid: String) : CellViewAction
internal data object RefreshData : CellViewAction

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import com.wire.android.feature.cells.ui.destinations.CreateFolderScreenDestinat
import com.wire.android.feature.cells.ui.destinations.MoveToFolderScreenDestination
import com.wire.android.feature.cells.ui.destinations.PublicLinkScreenDestination
import com.wire.android.feature.cells.ui.destinations.RecycleBinScreenDestination
import com.wire.android.feature.cells.ui.destinations.RenameNodeScreenDestination
import com.wire.android.feature.cells.ui.dialog.CellsNewActionBottomSheet
import com.wire.android.feature.cells.ui.dialog.CellsOptionsBottomSheet
import com.wire.android.feature.cells.ui.model.CellNodeUi
Expand Down Expand Up @@ -227,6 +228,18 @@ fun ConversationFilesScreenContent(
)
)
)
},
showRenameScreen = { cellNodeUi ->
navigator.navigate(
NavigationCommand(
RenameNodeScreenDestination(
uuid = cellNodeUi.uuid,
currentPath = cellNodeUi.remotePath,
isFolder = cellNodeUi is CellNodeUi.Folder,
nodeName = cellNodeUi.name,
)
)
)
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ enum class NodeBottomSheetAction(
SHARE(R.string.share_label, R.drawable.ic_share),
PUBLIC_LINK(R.string.public_link, R.drawable.ic_file_link),
MOVE(R.string.move_label, R.drawable.ic_folder),
RENAME(R.string.rename_label, R.drawable.ic_rename),
DOWNLOAD(R.string.download_label, R.drawable.ic_save),
RESTORE(R.string.restore_label, R.drawable.ic_restore),
DELETE(R.string.delete_label, R.drawable.ic_delete, true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ fun RecycleBinScreen(
)
)
)
}
},
showRenameScreen = { }
)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Wire
* Copyright (C) 2025 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
package com.wire.android.feature.cells.ui.rename

data class RenameNodeNavArgs(
val uuid: String? = null,
val currentPath: String? = null,
val isFolder: Boolean? = null,
val nodeName: String? = null
)
Loading
Loading