Skip to content
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

feat: Add option to manage team [#WPB-14873] #3753

Merged
merged 6 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -25,6 +25,7 @@ import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.gestures.scrollable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.defaultMinSize
Expand All @@ -43,6 +44,7 @@ import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
Expand Down Expand Up @@ -208,6 +210,7 @@ private fun SelfUserProfileContent(
isUserInCall: () -> Boolean
) {
val snackbarHostState = LocalSnackbarHostState.current
val uriHandler = LocalUriHandler.current

state.errorMessageCode?.let { errorCode ->
val errorMessage = mapErrorCodeToString(errorCode)
Expand Down Expand Up @@ -345,7 +348,13 @@ private fun SelfUserProfileContent(

Divider(color = MaterialTheme.wireColorScheme.outline)

Box(modifier = Modifier.padding(dimensions().spacing16x)) {
Column(
modifier = Modifier.padding(dimensions().spacing16x),
verticalArrangement = Arrangement.spacedBy(dimensions().spacing8x)
) {
if (isTeamAdminOrOwner) {
ManageTeamButton(uriHandler::openUri)
}
NewTeamButton(onAddAccountClick, isUserInCall, context)
}
}
Expand Down Expand Up @@ -440,6 +449,20 @@ private fun CurrentSelfUserStatus(
}
}

@Composable
private fun ManageTeamButton(
onManageTeamClick: (String) -> Unit
) {
val teamManagementLink = stringResource(R.string.url_team_management_login)
m-zagorski marked this conversation as resolved.
Show resolved Hide resolved
WireSecondaryButton(
text = stringResource(R.string.user_profile_account_management),
onClickDescription = stringResource(R.string.content_description_self_profile_manage_team_btn),
onClick = {
onManageTeamClick(teamManagementLink)
}
)
}

@Composable
private fun NewTeamButton(
onAddAccountClick: () -> Unit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ data class SelfUserProfileState(
val fullName: String = "",
val userName: String = "",
val teamName: String? = "", // maybe teamId is better here
val isTeamAdminOrOwner: Boolean = false,
val otherAccounts: List<OtherAccount> = emptyList(),
val statusDialogData: StatusDialogData? = null, // null means no dialog to display
val isAvatarLoading: Boolean = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import com.wire.kalium.logic.data.user.SelfUser
import com.wire.kalium.logic.data.user.UserAssetId
import com.wire.kalium.logic.data.user.UserAvailabilityStatus
import com.wire.kalium.logic.data.user.UserId
import com.wire.kalium.logic.data.user.type.UserType
import com.wire.kalium.logic.feature.auth.LogoutUseCase
import com.wire.kalium.logic.feature.call.usecase.EndCallUseCase
import com.wire.kalium.logic.feature.call.usecase.ObserveEstablishedCallsUseCase
Expand Down Expand Up @@ -176,6 +177,7 @@ class SelfUserProfileViewModel @Inject constructor(
fullName = name.orEmpty(),
userName = handle.orEmpty(),
teamName = selfTeam?.name,
isTeamAdminOrOwner = userType == UserType.OWNER || userType == UserType.ADMIN,
otherAccounts = otherAccounts,
avatarAsset = userProfileState.avatarAsset,
isAvatarLoading = false,
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@
<string name="content_description_self_profile_team">Team name, %s</string>
<string name="content_description_self_profile_change_status">change availability status</string>
<string name="content_description_self_profile_new_account_btn">Create a new team or personal account or log in</string>
<string name="content_description_self_profile_manage_team_btn">Manage team</string>
<string name="content_description_change_picture_back_btn">Go back to your profile overview</string>
<string name="content_description_welcome_screen_close_btn">Close new team creation and login view</string>
<string name="content_description_login_back_btn">Go back to new team creation and login view</string>
Expand Down Expand Up @@ -612,6 +613,7 @@
<string name="user_profile_status_away">Away</string>
<string name="user_profile_status_none">None</string>
<string name="user_profile_new_account_text">New Team or Add Account</string>
<string name="user_profile_account_management">Manage Team</string>
<string name="user_profile_details_tab">Details</string>
<string name="user_profile_devices_tab">Devices</string>
<string name="user_profile_group_tab">Group</string>
Expand Down
Loading