MM-17953 Do not show deactivated users in autocomplete (#3251)
* MM-17953 Do not show deactivated users in autocomplete * feedback review
This commit is contained in:
parent
1f88356557
commit
0ef2156b3f
5 changed files with 113 additions and 8 deletions
|
|
@ -484,7 +484,7 @@ exports[`ChannelItem should match snapshot for deactivated user and is searchRes
|
|||
channelId="channel_id"
|
||||
hasDraft={false}
|
||||
isActive={false}
|
||||
isArchived={true}
|
||||
isArchived={false}
|
||||
isBot={false}
|
||||
isInfo={false}
|
||||
isUnread={true}
|
||||
|
|
@ -550,7 +550,107 @@ exports[`ChannelItem should match snapshot for deactivated user and is searchRes
|
|||
</AnimatedComponent>
|
||||
`;
|
||||
|
||||
exports[`ChannelItem should match snapshot for deactivated user and not searchResults or currentChannel 1`] = `null`;
|
||||
exports[`ChannelItem should match snapshot for deactivated user and not searchResults or currentChannel 1`] = `
|
||||
<AnimatedComponent>
|
||||
<TouchablePreview
|
||||
onPress={[Function]}
|
||||
onPressIn={[Function]}
|
||||
touchableComponent={[Function]}
|
||||
underlayColor="rgba(69,120,191,0.5)"
|
||||
>
|
||||
<View
|
||||
style={
|
||||
Array [
|
||||
Object {
|
||||
"flex": 1,
|
||||
"flexDirection": "row",
|
||||
"height": 44,
|
||||
},
|
||||
undefined,
|
||||
null,
|
||||
]
|
||||
}
|
||||
>
|
||||
<View
|
||||
style={
|
||||
Array [
|
||||
Object {
|
||||
"alignItems": "center",
|
||||
"flex": 1,
|
||||
"flexDirection": "row",
|
||||
"paddingLeft": 16,
|
||||
},
|
||||
undefined,
|
||||
]
|
||||
}
|
||||
>
|
||||
<ChannelIcon
|
||||
channelId="channel_id"
|
||||
hasDraft={false}
|
||||
isActive={false}
|
||||
isArchived={false}
|
||||
isBot={false}
|
||||
isInfo={false}
|
||||
isUnread={true}
|
||||
membersCount={1}
|
||||
size={16}
|
||||
status="online"
|
||||
theme={
|
||||
Object {
|
||||
"awayIndicator": "#ffbc42",
|
||||
"buttonBg": "#166de0",
|
||||
"buttonColor": "#ffffff",
|
||||
"centerChannelBg": "#ffffff",
|
||||
"centerChannelColor": "#3d3c40",
|
||||
"codeTheme": "github",
|
||||
"dndIndicator": "#f74343",
|
||||
"errorTextColor": "#fd5960",
|
||||
"linkColor": "#2389d7",
|
||||
"mentionBj": "#ffffff",
|
||||
"mentionColor": "#145dbf",
|
||||
"mentionHighlightBg": "#ffe577",
|
||||
"mentionHighlightLink": "#166de0",
|
||||
"newMessageSeparator": "#ff8800",
|
||||
"onlineIndicator": "#06d6a0",
|
||||
"sidebarBg": "#145dbf",
|
||||
"sidebarHeaderBg": "#1153ab",
|
||||
"sidebarHeaderTextColor": "#ffffff",
|
||||
"sidebarText": "#ffffff",
|
||||
"sidebarTextActiveBorder": "#579eff",
|
||||
"sidebarTextActiveColor": "#ffffff",
|
||||
"sidebarTextHoverBg": "#4578bf",
|
||||
"sidebarUnreadText": "#ffffff",
|
||||
"type": "Mattermost",
|
||||
}
|
||||
}
|
||||
type="D"
|
||||
/>
|
||||
<Text
|
||||
ellipsizeMode="tail"
|
||||
numberOfLines={1}
|
||||
style={
|
||||
Array [
|
||||
Object {
|
||||
"alignSelf": "center",
|
||||
"color": "rgba(255,255,255,0.4)",
|
||||
"flex": 1,
|
||||
"fontSize": 14,
|
||||
"fontWeight": "600",
|
||||
"paddingRight": 10,
|
||||
},
|
||||
Object {
|
||||
"color": "#ffffff",
|
||||
},
|
||||
]
|
||||
}
|
||||
>
|
||||
display_name
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
</TouchablePreview>
|
||||
</AnimatedComponent>
|
||||
`;
|
||||
|
||||
exports[`ChannelItem should match snapshot for no displayName 1`] = `null`;
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ export default class ChannelItem extends PureComponent {
|
|||
channel: PropTypes.object,
|
||||
currentChannelId: PropTypes.string.isRequired,
|
||||
displayName: PropTypes.string.isRequired,
|
||||
isArchived: PropTypes.bool,
|
||||
isChannelMuted: PropTypes.bool,
|
||||
currentUserId: PropTypes.string.isRequired,
|
||||
isUnread: PropTypes.bool,
|
||||
|
|
@ -44,6 +45,7 @@ export default class ChannelItem extends PureComponent {
|
|||
};
|
||||
|
||||
static defaultProps = {
|
||||
isArchived: false,
|
||||
mentions: 0,
|
||||
};
|
||||
|
||||
|
|
@ -89,6 +91,7 @@ export default class ChannelItem extends PureComponent {
|
|||
channelId,
|
||||
currentChannelId,
|
||||
displayName,
|
||||
isArchived,
|
||||
isChannelMuted,
|
||||
currentUserId,
|
||||
isUnread,
|
||||
|
|
@ -102,8 +105,6 @@ export default class ChannelItem extends PureComponent {
|
|||
isLandscape,
|
||||
} = this.props;
|
||||
|
||||
const isArchived = channel.delete_at > 0;
|
||||
|
||||
// Only ever show an archived channel if it's the currently viewed channel.
|
||||
// It should disappear as soon as one navigates to another channel.
|
||||
if (isArchived && (currentChannelId !== channelId) && !isSearchResult) {
|
||||
|
|
|
|||
|
|
@ -115,6 +115,7 @@ describe('ChannelItem', () => {
|
|||
...baseProps,
|
||||
channel: channelObj,
|
||||
currentChannelId: 'channel_id',
|
||||
isArchived: true,
|
||||
};
|
||||
|
||||
const wrapper = shallow(
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ function makeMapStateToProps() {
|
|||
let displayName = channel.display_name;
|
||||
let isBot = false;
|
||||
let isGuest = false;
|
||||
let isArchived = channel.delete_at > 0;
|
||||
|
||||
if (channel.type === General.DM_CHANNEL) {
|
||||
if (ownProps.isSearchResult) {
|
||||
|
|
@ -39,6 +40,7 @@ function makeMapStateToProps() {
|
|||
} else {
|
||||
const teammateId = getUserIdFromChannelName(currentUserId, channel.name);
|
||||
const teammate = getUser(state, teammateId);
|
||||
isArchived = teammate.delete_at > 0;
|
||||
const teammateNameDisplay = getTeammateNameDisplaySetting(state);
|
||||
displayName = displayUsername(teammate, teammateNameDisplay, false);
|
||||
if (teammate && teammate.is_bot) {
|
||||
|
|
@ -75,6 +77,7 @@ function makeMapStateToProps() {
|
|||
channel,
|
||||
currentChannelId,
|
||||
displayName,
|
||||
isArchived,
|
||||
isChannelMuted: isChannelMuted(member),
|
||||
currentUserId,
|
||||
hasDraft: Boolean(channelDraft.draft.trim() || channelDraft.files.length),
|
||||
|
|
|
|||
|
|
@ -74,12 +74,12 @@ export const filterMembersInChannel = createSelector(
|
|||
let profiles;
|
||||
if (matchTerm) {
|
||||
profiles = profilesInChannel.filter((p) => {
|
||||
return ((p.id !== currentUserId) && (
|
||||
return ((p.id !== currentUserId && p.delete_at === 0) && (
|
||||
p.username.toLowerCase().includes(matchTerm) || p.email.toLowerCase().includes(matchTerm) ||
|
||||
p.first_name.toLowerCase().includes(matchTerm) || p.last_name.toLowerCase().includes(matchTerm)));
|
||||
});
|
||||
} else {
|
||||
profiles = profilesInChannel.filter((p) => p.id !== currentUserId);
|
||||
profiles = profilesInChannel.filter((p) => p.id !== currentUserId && p.delete_at === 0);
|
||||
}
|
||||
|
||||
// already sorted
|
||||
|
|
@ -99,12 +99,12 @@ export const filterMembersNotInChannel = createSelector(
|
|||
let profiles;
|
||||
if (matchTerm) {
|
||||
profiles = profilesNotInChannel.filter((p) => {
|
||||
return ((p.id !== currentUserId) && (
|
||||
return ((p.id !== currentUserId && p.detele_at === 0) && (
|
||||
p.username.toLowerCase().includes(matchTerm) || p.email.toLowerCase().includes(matchTerm) ||
|
||||
p.first_name.toLowerCase().includes(matchTerm) || p.last_name.toLowerCase().includes(matchTerm)));
|
||||
});
|
||||
} else {
|
||||
profiles = profilesNotInChannel;
|
||||
profiles = profilesNotInChannel.filter((p) => p.delete_at === 0);
|
||||
}
|
||||
|
||||
return profiles.map((p) => p.id);
|
||||
|
|
|
|||
Loading…
Reference in a new issue