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

chore(ui): announcement cleanup #6975

Merged
merged 4 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 9 additions & 29 deletions src/homepageExperience/ClickThroughAnnouncementHandler.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
// Libraries
import {FC, useEffect} from 'react'
import {useSelector, useDispatch} from 'react-redux'
import {useDispatch} from 'react-redux'
import {useLocalStorageState} from 'use-local-storage-state'

// Selectors
import {selectCurrentIdentity} from 'src/identity/selectors'

// Utils
import {showOverlay, dismissOverlay} from 'src/overlays/actions/overlays'
import {isFlagEnabled} from 'src/shared/utils/featureFlag'
import {event} from 'src/cloud/utils/reporting'

export enum AnnouncementID {
MqttEol = 'mqttEolClickThroughAnnouncement',
PriceIncrease = 'pricingClickThroughAnnouncement',
None = 'none',
}

enum AnnouncementState {
Dismissed = 'dismissed',
Display = 'display',
Disabled = 'disabled',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this new state being used anywhere?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's not. I added it for a different solution and forgot to remove it.

}

export const ClickThroughAnnouncementHandler: FC = () => {
const dispatch = useDispatch()
const {account} = useSelector(selectCurrentIdentity)

const [announcementState, setAnnouncementState] = useLocalStorageState(
'clickThroughAnnouncement',
Expand Down Expand Up @@ -51,6 +46,10 @@ export const ClickThroughAnnouncementHandler: FC = () => {
}

const handleDisplayAnnouncement = (announcementID: string): void => {
if (announcementID === AnnouncementID.None) {
return null
}

initAnnouncement(announcementID)

if (announcementState[announcementID] === AnnouncementState.Display) {
Expand All @@ -66,27 +65,8 @@ export const ClickThroughAnnouncementHandler: FC = () => {
}

useEffect(() => {
// MQTT Audience: Cloud users with MQTT feature flag enabled
const isMqttAudience = isFlagEnabled('subscriptionsUI')

// PAYG Pricing Increase Audience: Pay As You Go & Direct Signups
const isPaygAccount = account.type === 'pay_as_you_go'
const isDirectSignup = account.billingProvider === 'zuora'
const isPriceIncreaseAudience = isPaygAccount && isDirectSignup

// Sequentially display announcements in order of priority
if (
isMqttAudience &&
announcementState[AnnouncementID.MqttEol] !== AnnouncementState.Dismissed
) {
handleDisplayAnnouncement(AnnouncementID.MqttEol)
} else if (
isPriceIncreaseAudience &&
announcementState[AnnouncementID.PriceIncrease] !==
AnnouncementState.Dismissed
) {
handleDisplayAnnouncement(AnnouncementID.PriceIncrease)
}
// Sequentially display announcements in order of priority (use AnnouncementID.None to disable)
handleDisplayAnnouncement(AnnouncementID.None)
}, [announcementState])

return null
Expand Down
34 changes: 3 additions & 31 deletions src/me/components/ClickThroughAnnouncementOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import {useSelector} from 'react-redux'

// Components
import {Overlay} from '@influxdata/clockface'
import {PaygPriceIncreaseAnnouncement} from 'src/me/components/announcements/PaygPriceIncreaseAnnouncement'
import {MqttEolAnnouncement} from 'src/me/components/announcements/MqttEolAnnouncement'

// Utils
import {event} from 'src/cloud/utils/reporting'
Expand All @@ -20,43 +18,17 @@ interface ClickThroughAnnouncementOverlayProps {

export const ClickThroughAnnouncementOverlay: FC<
ClickThroughAnnouncementOverlayProps
> = ({onClose}) => {
> = () => {
const {announcementID} = useSelector(getOverlayParams)

useEffect(() => {
event(`${announcementID}.displayed`)
}, [])

const handleDetailsClick = () => {
event(`${announcementID}.details.clicked`)
}

const handleContactUsClick = () => {
event(`${announcementID}.contactUs.clicked`)
}

const handleAcknowledgeClick = () => {
event(`${announcementID}.acknowledge.clicked`)
onClose()
}

const announcementContents = (): JSX.Element => {
switch (announcementID) {
case AnnouncementID.PriceIncrease:
return (
<PaygPriceIncreaseAnnouncement
handleAcknowledgeClick={handleAcknowledgeClick}
handleContactUsClick={handleContactUsClick}
handleDetailsClick={handleDetailsClick}
/>
)
case AnnouncementID.MqttEol:
return (
<MqttEolAnnouncement
handleAcknowledgeClick={handleAcknowledgeClick}
handleDetailsClick={handleDetailsClick}
/>
)
case AnnouncementID.None:
return null
default:
return null
}
Expand Down
151 changes: 0 additions & 151 deletions src/me/components/announcements/MqttEolAnnouncement.tsx

This file was deleted.

This file was deleted.

Loading
Loading