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

Channel Actions - Only show Leave Group options if user has "leave-channel" permission #630

Conversation

bpollman
Copy link
Contributor

@bpollman bpollman commented Oct 29, 2024

🔗 Issue Link

Jira or Github issue link, if applicable.

🎯 Goal

Hide the " Leave Group" button/actions if the user doesnt have the permissions.

🛠 Implementation

NOTE: Depends on update to mocks main swift rep: GetStream/stream-chat-swift#3478

The code checks for"delete-channel" but not "leave-channel"

This new code

    public var shouldShowLeaveConversationButton: Bool {
        if channel.isDirectMessageChannel {
            return channel.ownCapabilities.contains(.deleteChannel)
        } else {
            return channel.ownCapabilities.contains(.leaveChannel)
        }
    }

properly reflect the existing logic that sets the leave/delete title here.

    public var leaveButtonTitle: String {
        if channel.isDirectMessageChannel {
            return L10n.Alert.Actions.deleteChannelTitle
        } else {
            return L10n.Alert.Actions.leaveGroupTitle
        }
    }

🧪 Testing

Describe the steps how this change can be tested (or why it can't be tested).

I've tested this with DM's, and channel types with and without the permissions

🎨 Changes

Add relevant screenshots or videos showcasing the changes.

☑️ Checklist

  • I have signed the Stream CLA (required)
  • Changelog is updated with client-facing changes
  • New code is covered by unit tests
  • Affected documentation updated (docusaurus, tutorial, CMS (task created)

@bpollman bpollman requested a review from a team as a code owner October 29, 2024 05:43
@nuno-vieira
Copy link
Member

Thank you for the PR @bpollman,

If you have the time, would be nice if you could update the shouldShowLeaveConversationButton tests with the new logic 👍

Otherwise, we will pick it up as soon as we can.

Best,
Nuno

@bpollman
Copy link
Contributor Author

Thank you for the PR @bpollman,

If you have the time, would be nice if you could update the shouldShowLeaveConversationButton tests with the new logic 👍

Otherwise, we will pick it up as soon as we can.

Best, Nuno

Hey no problem,

I had to create another PR to update ChatChannel.mockDMChannel() to support channel capabilities. Package change is in a separate commit that can changed once the other PR is merged.

@nuno-vieira nuno-vieira changed the base branch from develop to fix/leave-channel-permissions October 31, 2024 12:09
@nuno-vieira nuno-vieira merged commit dff8f87 into GetStream:fix/leave-channel-permissions Oct 31, 2024
5 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants