Unverified Commit d5d1353e authored by Agniva De Sarker's avatar Agniva De Sarker Committed by GitHub
Browse files

MM-27135: Deactivated users show in channel members dropdown (#5951) (#5987)

* MM-27135: Deactivated users show in channel members dropdown

We filter the user list by only activated users.

* incorporate review comments

* incorporate review comments
parent 7a09a974
......@@ -90,6 +90,7 @@ exports[`components/PopoverListMembers should match snapshot 1`] = `
status="online"
user={
Object {
"delete_at": 0,
"id": "member_id_1",
}
}
......@@ -101,6 +102,7 @@ exports[`components/PopoverListMembers should match snapshot 1`] = `
status="offline"
user={
Object {
"delete_at": 0,
"id": "member_id_2",
}
}
......@@ -202,6 +204,7 @@ exports[`components/PopoverListMembers should match snapshot with archived chann
status="online"
user={
Object {
"delete_at": 0,
"id": "member_id_1",
}
}
......@@ -213,6 +216,7 @@ exports[`components/PopoverListMembers should match snapshot with archived chann
status="offline"
user={
Object {
"delete_at": 0,
"id": "member_id_2",
}
}
......@@ -323,6 +327,7 @@ exports[`components/PopoverListMembers should match snapshot with group-constrai
status="online"
user={
Object {
"delete_at": 0,
"id": "member_id_1",
}
}
......@@ -334,6 +339,7 @@ exports[`components/PopoverListMembers should match snapshot with group-constrai
status="offline"
user={
Object {
"delete_at": 0,
"id": "member_id_2",
}
}
......
......@@ -9,6 +9,7 @@ import {FormattedMessage} from 'react-intl';
import {browserHistory} from 'utils/browser_history';
import {Constants, ModalIdentifiers} from 'utils/constants';
import {isActive} from 'utils/filter_users';
import * as Utils from 'utils/utils.jsx';
import ChannelMembersModal from 'components/channel_members_modal';
import OverlayTrigger from 'components/overlay_trigger';
......@@ -100,7 +101,8 @@ export default class PopoverListMembers extends React.PureComponent {
render() {
const isDirectChannel = this.props.channel.type === Constants.DM_CHANNEL;
const items = this.props.sortedUsers.map((user) => (
const activeUsers = this.props.sortedUsers.filter(isActive);
const items = activeUsers.map((user) => (
<PopoverListMembersItem
key={user.id}
onItemClick={this.handleShowDirectChannel}
......
......@@ -25,8 +25,9 @@ describe('components/PopoverListMembers', () => {
type: Constants.DM_CHANNEl,
};
const users = [
{id: 'member_id_1'},
{id: 'member_id_2'},
{id: 'member_id_1', delete_at: 0},
{id: 'member_id_2', delete_at: 0},
{id: 'member_id_3', delete_at: 1234},
];
const statuses = {
member_id_1: 'online',
......@@ -47,7 +48,7 @@ describe('components/PopoverListMembers', () => {
memberCount: 2,
currentUserId: 'current_user_id',
actions,
sortedUsers: [{id: 'member_id_1'}, {id: 'member_id_2'}],
sortedUsers: [{id: 'member_id_1', delete_at: 0}, {id: 'member_id_2', delete_at: 0}, {id: 'member_id_3', delete_at: 1234}],
};
test('should match snapshot', () => {
......
......@@ -2,6 +2,8 @@
// See LICENSE.txt for license information.
import {UserSearchOptions, UserListOptions, UserFilters} from 'utils/constants';
const NEVER = 0;
// userSelectorOptionsFromFilter will convert a string UI filter to an options object
// for selecting users out of redux state
// Note: this is currently the same as getUserOptionsFromFilter but wrapped to be clear
......@@ -38,3 +40,8 @@ export function searchUserOptionsFromFilter(filter) {
}
return options;
}
// isActive returns whether a user is active or not.
export function isActive(user) {
return user.delete_at === NEVER;
}
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {getUserOptionsFromFilter, searchUserOptionsFromFilter} from './filter_users';
import {getUserOptionsFromFilter, searchUserOptionsFromFilter, isActive} from './filter_users';
describe('filter_users', () => {
describe('getUserOptionsFromFilter', () => {
......@@ -45,4 +45,14 @@ describe('filter_users', () => {
expect(filters).toEqual({allow_inactive: true});
});
});
describe('isActive', () => {
it('should return true for an active user', () => {
const active = isActive({delete_at: 0});
expect(active).toEqual(true);
});
it('should return false for an inactive user', () => {
const active = isActive({delete_at: 1});
expect(active).toEqual(false);
});
});
});
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment