diff --git a/webapp/channels/src/components/sidebar/__snapshots__/invite_members_button.test.tsx.snap b/webapp/channels/src/components/sidebar/__snapshots__/invite_members_button.test.tsx.snap index 809f40e20d..43eaebeb46 100644 --- a/webapp/channels/src/components/sidebar/__snapshots__/invite_members_button.test.tsx.snap +++ b/webapp/channels/src/components/sidebar/__snapshots__/invite_members_button.test.tsx.snap @@ -15,8 +15,6 @@ exports[`components/sidebar/invite_members_button should match snapshot 1`] = ` >
  • { }; const props = { - onClick: jest.fn(), - touchedInviteMembersButton: false, isAdmin: false, }; @@ -91,59 +89,4 @@ describe('components/sidebar/invite_members_button', () => { ); expect(wrapper.find('i').exists()).toBeFalsy(); }); - - test('should fire onClick prop on click', () => { - const mock = jest.fn(); - const wrapper = mountWithIntl( - - - , - ); - expect(mock).not.toHaveBeenCalled(); - wrapper.find('i').simulate('click'); - expect(mock).toHaveBeenCalled(); - }); - - test('should not be highlighted when button has been touched/clicked', () => { - const wrapper = mountWithIntl( - - - , - ); - expect(wrapper.find('li').prop('className')).not.toContain('untouched'); - }); - - test('should be highlighted when component has not been touched/clicked and has less than 10 users', () => { - const lessThan10Users = { - ...state.entities.users, - stats: { - total_users_count: 9, - }, - }; - const lessThan10UsersState = {...state, entities: {...state.entities, users: lessThan10Users}}; - const store = mockStore(lessThan10UsersState); - const wrapper = mountWithIntl( - - - , - ); - expect(wrapper.find('li').prop('className')).toContain('untouched'); - }); - - test('should not be highlighted when component has not been touched/clicked but the workspace has more than 10 users', () => { - const moreThan10Users = { - ...state.entities.users, - stats: { - total_users_count: 11, - }, - }; - const moreThan10UsersState = {...state, entities: {...state.entities, users: moreThan10Users}}; - const store = mockStore(moreThan10UsersState); - const wrapper = mountWithIntl( - - - , - ); - expect(wrapper.find('li').prop('className')).not.toContain('untouched'); - }); }); diff --git a/webapp/channels/src/components/sidebar/invite_members_button.tsx b/webapp/channels/src/components/sidebar/invite_members_button.tsx index 0f3f602d5f..ce36ae3dfe 100644 --- a/webapp/channels/src/components/sidebar/invite_members_button.tsx +++ b/webapp/channels/src/components/sidebar/invite_members_button.tsx @@ -1,20 +1,15 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import React, {useEffect} from 'react'; +import React from 'react'; import {useIntl, FormattedMessage} from 'react-intl'; -import {useSelector, useDispatch} from 'react-redux'; +import {useSelector} from 'react-redux'; import {Permissions} from 'mattermost-redux/constants'; -import {GlobalState} from 'types/store'; - import {getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams'; -import {DispatchFunc} from 'mattermost-redux/types/actions'; - -import {getTotalUsersStats} from 'mattermost-redux/actions/users'; import {trackEvent} from 'actions/telemetry_actions'; @@ -23,40 +18,22 @@ import InvitationModal from 'components/invitation_modal'; import TeamPermissionGate from 'components/permissions_gates/team_permission_gate'; import {getAnalyticsCategory} from 'components/onboarding_tasks'; -import Constants, {ModalIdentifiers} from 'utils/constants'; +import {ModalIdentifiers} from 'utils/constants'; type Props = { - touchedInviteMembersButton: boolean; className?: string; - onClick: () => void; isAdmin: boolean; } const InviteMembersButton = (props: Props): JSX.Element | null => { - const dispatch = useDispatch(); - const intl = useIntl(); const currentTeamId = useSelector(getCurrentTeamId); - const totalUserCount = useSelector((state: GlobalState) => state.entities.users.stats?.total_users_count); - - useEffect(() => { - if (!totalUserCount) { - dispatch(getTotalUsersStats()); - } - }, []); const handleButtonClick = () => { trackEvent(getAnalyticsCategory(props.isAdmin), 'click_sidebar_invite_members_button'); - props.onClick(); }; - let buttonClass = 'SidebarChannelNavigator__inviteMembersLhsButton'; - - if (!props.touchedInviteMembersButton && Number(totalUserCount) <= Constants.USER_LIMIT) { - buttonClass += ' SidebarChannelNavigator__inviteMembersLhsButton--untouched'; - } - - if (!currentTeamId || !totalUserCount) { + if (!currentTeamId) { return null; } @@ -74,7 +51,7 @@ const InviteMembersButton = (props: Props): JSX.Element | null => { onClick={handleButtonClick} >
  • diff --git a/webapp/channels/src/components/sidebar/sidebar_category/__snapshots__/sidebar_category.test.tsx.snap b/webapp/channels/src/components/sidebar/sidebar_category/__snapshots__/sidebar_category.test.tsx.snap index bbbfd1d50a..a005df6892 100644 --- a/webapp/channels/src/components/sidebar/sidebar_category/__snapshots__/sidebar_category.test.tsx.snap +++ b/webapp/channels/src/components/sidebar/sidebar_category/__snapshots__/sidebar_category.test.tsx.snap @@ -262,8 +262,6 @@ exports[`components/sidebar/sidebar_category should match snapshot when sorting `; @@ -387,8 +385,6 @@ exports[`components/sidebar/sidebar_category should match snapshot when the cate `; diff --git a/webapp/channels/src/components/sidebar/sidebar_category/index.ts b/webapp/channels/src/components/sidebar/sidebar_category/index.ts index 63db589841..47edbb831e 100644 --- a/webapp/channels/src/components/sidebar/sidebar_category/index.ts +++ b/webapp/channels/src/components/sidebar/sidebar_category/index.ts @@ -8,10 +8,8 @@ import {setCategoryCollapsed, setCategorySorting} from 'mattermost-redux/actions import {GenericAction} from 'mattermost-redux/types/actions'; import {savePreferences} from 'mattermost-redux/actions/preferences'; import {ChannelCategory} from '@mattermost/types/channel_categories'; -import {getBool} from 'mattermost-redux/selectors/entities/preferences'; import {getCurrentUser, getCurrentUserId} from 'mattermost-redux/selectors/entities/users'; import {isAdmin} from 'mattermost-redux/utils/user_utils'; -import {Preferences, Touched} from 'utils/constants'; import {getDraggingState, makeGetFilteredChannelIdsForCategory} from 'selectors/views/channel_sidebar'; import {GlobalState} from 'types/store'; @@ -29,7 +27,6 @@ function makeMapStateToProps() { return { channelIds: getChannelIdsForCategory(state, ownProps.category), draggingState: getDraggingState(state), - touchedInviteMembersButton: getBool(state, Preferences.TOUCHED, Touched.INVITE_MEMBERS), currentUserId: getCurrentUserId(state), isAdmin: isAdmin(getCurrentUser(state).roles), }; diff --git a/webapp/channels/src/components/sidebar/sidebar_category/sidebar_category.tsx b/webapp/channels/src/components/sidebar/sidebar_category/sidebar_category.tsx index a150e7005e..f806adc90a 100644 --- a/webapp/channels/src/components/sidebar/sidebar_category/sidebar_category.tsx +++ b/webapp/channels/src/components/sidebar/sidebar_category/sidebar_category.tsx @@ -14,7 +14,7 @@ import {trackEvent} from 'actions/telemetry_actions'; import OverlayTrigger from 'components/overlay_trigger'; import Tooltip from 'components/tooltip'; import {DraggingState} from 'types/store'; -import Constants, {A11yCustomEventTypes, DraggingStateTypes, DraggingStates, Preferences, Touched} from 'utils/constants'; +import Constants, {A11yCustomEventTypes, DraggingStateTypes, DraggingStates} from 'utils/constants'; import {t} from 'utils/i18n'; import {isKeyPressed} from 'utils/keyboard'; import SidebarChannel from '../sidebar_channel'; @@ -38,7 +38,6 @@ type Props = { isNewCategory: boolean; draggingState: DraggingState; currentUserId: string; - touchedInviteMembersButton: boolean; isAdmin: boolean; actions: { setCategoryCollapsed: (categoryId: string, collapsed: boolean) => void; @@ -325,21 +324,7 @@ export default class SidebarCategory extends React.PureComponent { inviteMembersButton = ( { - if (!this.props.touchedInviteMembersButton) { - this.props.actions.savePreferences( - this.props.currentUserId, - [{ - category: Preferences.TOUCHED, - user_id: this.props.currentUserId, - name: Touched.INVITE_MEMBERS, - value: 'true', - }], - ); - } - }} /> ); } diff --git a/webapp/channels/src/utils/constants.tsx b/webapp/channels/src/utils/constants.tsx index 45a98bc49b..f3aa701f3d 100644 --- a/webapp/channels/src/utils/constants.tsx +++ b/webapp/channels/src/utils/constants.tsx @@ -156,7 +156,6 @@ export const Preferences = { // For one off things that have a special, attention-grabbing UI until you interact with them export const Touched = { - INVITE_MEMBERS: 'invite_members', ADD_CHANNELS_CTA: 'add_channels_cta', };