From 34eece7462533f2ac3e73e4ab028a04068f0ba28 Mon Sep 17 00:00:00 2001 From: Conor Macpherson Date: Wed, 12 Apr 2023 13:44:56 -0400 Subject: [PATCH] revert changes to overage users banner in favor of getting self hoste expansion modal pushed through faster. --- .../enterprise_edition_left_panel.test.tsx | 11 ++++++- .../overage_users_banner/index.tsx | 15 ++------- .../overage_users_banner_notice/index.tsx | 31 ++----------------- .../index.test.tsx | 1 - 4 files changed, 15 insertions(+), 43 deletions(-) diff --git a/webapp/channels/src/components/admin_console/license_settings/enterprise_edition/enterprise_edition_left_panel.test.tsx b/webapp/channels/src/components/admin_console/license_settings/enterprise_edition/enterprise_edition_left_panel.test.tsx index 551af99212..3c8a8f4697 100644 --- a/webapp/channels/src/components/admin_console/license_settings/enterprise_edition/enterprise_edition_left_panel.test.tsx +++ b/webapp/channels/src/components/admin_console/license_settings/enterprise_edition/enterprise_edition_left_panel.test.tsx @@ -22,6 +22,15 @@ import * as useCanSelfHostedExpand from 'components/common/hooks/useCanSelfHoste import EnterpriseEditionLeftPanel, {EnterpriseEditionProps} from './enterprise_edition_left_panel'; +jest.mock('react-router-dom', () => ({ + ...jest.requireActual('react-router-dom') as typeof import('react-router-dom'), + useLocation: () => { + return { + pathname: '', + }; + }, +})); + describe('components/admin_console/license_settings/enterprise_edition/enterprise_edition_left_panel', () => { const license = { IsLicensed: 'true', @@ -113,7 +122,7 @@ describe('components/admin_console/license_settings/enterprise_edition/enterpris return n.children().length === 2 && n.childAt(0).type() === 'span' && !n.childAt(0).text().includes('ACTIVE') && - n.childAt(0).text().includes('USERS'); + n.childAt(0).text().includes('LICENSED SEATS'); }); expect(item.text()).toContain('1,000'); diff --git a/webapp/channels/src/components/announcement_bar/overage_users_banner/index.tsx b/webapp/channels/src/components/announcement_bar/overage_users_banner/index.tsx index ab53ac8be9..d22fe6389f 100644 --- a/webapp/channels/src/components/announcement_bar/overage_users_banner/index.tsx +++ b/webapp/channels/src/components/announcement_bar/overage_users_banner/index.tsx @@ -4,7 +4,6 @@ import React, {useMemo} from 'react'; import {FormattedMessage} from 'react-intl'; import {useDispatch, useSelector} from 'react-redux'; -import {useHistory} from 'react-router-dom'; import {getCurrentUser, isCurrentUserSystemAdmin} from 'mattermost-redux/selectors/entities/users'; import {GlobalState} from 'types/store'; @@ -17,10 +16,9 @@ import {makeGetCategory} from 'mattermost-redux/selectors/entities/preferences'; import {PreferenceType} from '@mattermost/types/preferences'; import {useExpandOverageUsersCheck} from 'components/common/hooks/useExpandOverageUsersCheck'; import useOpenSalesLink from 'components/common/hooks/useOpenSalesLink'; -import {StatTypes, Preferences, AnnouncementBarTypes, ConsolePages} from 'utils/constants'; +import {StatTypes, Preferences, AnnouncementBarTypes} from 'utils/constants'; import './overage_users_banner.scss'; -import useCWSAvailabilityCheck from 'components/common/hooks/useCWSAvailabilityCheck'; type AdminHasDismissedItArgs = { preferenceName: string; @@ -58,8 +56,6 @@ const OverageUsersBanner = () => { const prefixPreferences = isOver10PercerntPurchasedSeats ? 'error' : 'warn'; const prefixLicenseId = (license.Id || '').substring(0, 8); const preferenceName = `${prefixPreferences}_overage_seats_${prefixLicenseId}`; - const history = useHistory(); - const isAirGapped = !useCWSAvailabilityCheck(); const overageByUsers = activeUsers - seatsPurchased; @@ -90,14 +86,7 @@ const OverageUsersBanner = () => { const handleUpdateSeatsSelfServeClick = (e: React.MouseEvent) => { e.preventDefault(); trackEventFn('Self Serve'); - - if (isAirGapped) { - window.open(expandableLink(license.Id), '_blank'); - } - - if (isExpandable) { - history.push(`${ConsolePages.LICENSE}?action=show_expansion_modal`); - } + window.open(expandableLink(license.Id), '_blank'); }; const handleContactSalesClick = (e: React.MouseEvent) => { diff --git a/webapp/channels/src/components/invitation_modal/overage_users_banner_notice/index.tsx b/webapp/channels/src/components/invitation_modal/overage_users_banner_notice/index.tsx index f72ec26388..ce1cd6a1c3 100644 --- a/webapp/channels/src/components/invitation_modal/overage_users_banner_notice/index.tsx +++ b/webapp/channels/src/components/invitation_modal/overage_users_banner_notice/index.tsx @@ -16,13 +16,10 @@ import {savePreferences} from 'mattermost-redux/actions/preferences'; import {makeGetCategory} from 'mattermost-redux/selectors/entities/preferences'; import {PreferenceType} from '@mattermost/types/preferences'; import {useExpandOverageUsersCheck} from 'components/common/hooks/useExpandOverageUsersCheck'; -import {LicenseLinks, StatTypes, Preferences, ConsolePages} from 'utils/constants'; +import {LicenseLinks, StatTypes, Preferences} from 'utils/constants'; import './overage_users_banner_notice.scss'; import ExternalLink from 'components/external_link'; -import useControlSelfHostedExpansionModal from 'components/common/hooks/useControlSelfHostedExpansionModal'; -import {NavLink} from 'react-router-dom'; -import useCWSAvailabilityCheck from 'components/common/hooks/useCWSAvailabilityCheck'; type AdminHasDismissedArgs = { preferenceName: string; @@ -56,16 +53,15 @@ const OverageUsersBannerNotice = () => { const prefixLicenseId = (license.Id || '').substring(0, 8); const preferenceName = `${prefixPreferences}_overage_seats_${prefixLicenseId}`; - const isAirGapped = !useCWSAvailabilityCheck(); const overageByUsers = activeUsers - seatsPurchased; const isOverageState = isBetween5PercerntAnd10PercentPurchasedSeats || isOver10PercerntPurchasedSeats; const hasPermission = isAdmin && isOverageState && !isCloud; const { cta, + expandableLink, trackEventFn, getRequestState, isExpandable, - expandableLink, } = useExpandOverageUsersCheck({ shouldRequest: hasPermission && !adminHasDismissed({overagePreferences, preferenceName}), licenseId: license.Id, @@ -73,8 +69,6 @@ const OverageUsersBannerNotice = () => { banner: 'invite modal', }); - const selfHostedExpansionModal = useControlSelfHostedExpansionModal({trackingLocation: 'overage_user_banner_notice'}); - if (!hasPermission || adminHasDismissed({overagePreferences, preferenceName})) { return null; } @@ -102,31 +96,12 @@ const OverageUsersBannerNotice = () => { const handleClick = () => { trackEventFn(isExpandable ? 'Self Serve' : 'Contact Sales'); - if (isExpandable) { - selfHostedExpansionModal.open(); - } }; - if (isAirGapped) { - window.open(expandableLink(license.Id), '_blank'); - } - - if (isExpandable) { - return ( - - {cta} - - ); - } - return ( {cta} diff --git a/webapp/channels/src/components/self_hosted_purchases/self_hosted_expansion_modal/index.test.tsx b/webapp/channels/src/components/self_hosted_purchases/self_hosted_expansion_modal/index.test.tsx index 2d2931483e..8a6efee355 100644 --- a/webapp/channels/src/components/self_hosted_purchases/self_hosted_expansion_modal/index.test.tsx +++ b/webapp/channels/src/components/self_hosted_purchases/self_hosted_expansion_modal/index.test.tsx @@ -162,7 +162,6 @@ const initialState: DeepPartial = { license: { SkuName: productName, Sku: productName, - SkuName: productName, Users: '50', ExpiresAt: licenseExpiry.valueOf().toString(), },