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

fix: allow usage exceeded alert to be dismissed #20282

Merged
merged 21 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
364e195
allow usage exceeded alert to be dismissed
Feb 12, 2024
58f0a2d
Update UI snapshots for `chromium` (1)
github-actions[bot] Feb 12, 2024
057b76d
forgot a css change
Feb 12, 2024
349dcf9
reset dismissKey if status reverts to not usage exceeded
Feb 15, 2024
34cc9a9
Merge remote-tracking branch 'origin/master' into by/make-usage-limit…
Feb 15, 2024
6961ee1
fix the cookie reset logic
Feb 15, 2024
358bcdf
hide billing notice on intro screens
Feb 15, 2024
7792acf
Merge remote-tracking branch 'origin/master' into by/make-usage-limit…
Feb 15, 2024
662f8c3
Update UI snapshots for `webkit` (2)
github-actions[bot] Feb 15, 2024
61ca622
Update UI snapshots for `webkit` (2)
github-actions[bot] Feb 15, 2024
893c686
Revert "Update UI snapshots for `chromium` (1)"
Feb 16, 2024
5b8be11
temp for attempting to use logic to reset localstorage
Feb 21, 2024
d4336e7
Merge remote-tracking branch 'origin/master' into by/make-usage-limit…
Feb 21, 2024
b630a84
fix up my banner logic reset
Feb 21, 2024
8bd0079
Update UI snapshots for `webkit` (2)
github-actions[bot] Feb 21, 2024
cc8b660
Update UI snapshots for `chromium` (1)
github-actions[bot] Feb 21, 2024
9a70d4f
Update UI snapshots for `chromium` (2)
github-actions[bot] Feb 21, 2024
7c4356a
undo changes made for testing purposes
Feb 22, 2024
eaef40e
Revert "Update UI snapshots for `chromium` (2)"
Feb 22, 2024
7032210
Revert "Update UI snapshots for `webkit` (2)"
Feb 22, 2024
f920b3c
Revert "Update UI snapshots for `chromium` (1)"
Feb 22, 2024
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
2 changes: 1 addition & 1 deletion frontend/src/layout/navigation-3000/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export function Navigation({
sceneConfig?.layout === 'app-raw' && 'Navigation3000__scene--raw'
)}
>
<BillingAlertsV2 />
{!sceneConfig?.hideBillingNotice && <BillingAlertsV2 />}
{!sceneConfig?.hideProjectNotice && <ProjectNotice />}
{children}
</div>
Expand Down
11 changes: 7 additions & 4 deletions frontend/src/lib/components/BillingAlertsV2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,13 @@ export function BillingAlertsV2(): JSX.Element | null {
<LemonBanner
type={billingAlert.status}
action={showButton ? buttonProps : undefined}
onClose={() => {
billingAlert.status !== 'error' ? () => setAlertHidden(true) : undefined
billingAlert.onClose?.()
}}
onClose={
billingAlert.status !== 'error'
? () => setAlertHidden(true)
: billingAlert.onClose
? () => billingAlert.onClose?.()
: undefined
}
dismissKey={billingAlert.dismissKey}
>
<b>{billingAlert.title}</b>
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/lib/lemon-ui/LemonBanner/lemonBannerLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ export const lemonBannerLogic = kea<lemonBannerLogicType>([
props({} as LemonBannerLogicProps),
actions({
dismiss: true,
resetDismissKey: true,
}),
reducers({
isDismissed: [
false,
{ persist: true },
{
dismiss: () => true,
resetDismissKey: () => false,
},
],
}),
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/scenes/billing/billingLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { router, urlToAction } from 'kea-router'
import api from 'lib/api'
import { dayjs } from 'lib/dayjs'
import { LemonBannerAction } from 'lib/lemon-ui/LemonBanner/LemonBanner'
import { lemonBannerLogic } from 'lib/lemon-ui/LemonBanner/lemonBannerLogic'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { pluralize } from 'lib/utils'
import { eventUsageLogic } from 'lib/utils/eventUsageLogic'
Expand Down Expand Up @@ -234,9 +235,14 @@ export const billingLogic = kea<billingLogicType>([
message: `You have exceeded the usage limit for ${productOverLimit.name}. Please
${productOverLimit.subscribed ? 'increase your billing limit' : 'upgrade your plan'}
or data loss may occur.`,
dismissKey: 'usage-limit-exceeded',
xrdt marked this conversation as resolved.
Show resolved Hide resolved
}
}

lemonBannerLogic({ dismissKey: 'usage-limit-exceeded' }).mount()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Turns out I simply needed to manually mount this logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would you look at that:

Screen.Recording.2024-02-21.at.2.30.41.PM.mp4

lemonBannerLogic({ dismissKey: 'usage-limit-exceeded' }).actions.resetDismissKey()
lemonBannerLogic({ dismissKey: 'usage-limit-exceeded' }).unmount()

const productApproachingLimit = billing.products?.find(
(x) => x.percentage_usage > ALLOCATION_THRESHOLD_ALERT
)
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/scenes/sceneTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ export interface SceneConfig {
layout?: 'app' | 'app-raw' | 'app-container' | 'plain'
/** Hides project notice (ProjectNotice.tsx). */
hideProjectNotice?: boolean
/** Hides billing notice (BillingAlertsV2.tsx). */
hideBillingNotice?: boolean
/** Personal account management (used e.g. by breadcrumbs) */
personal?: boolean
/** Instance management (used e.g. by breadcrumbs) */
Expand Down
1 change: 1 addition & 0 deletions frontend/src/scenes/scenes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ export const sceneConfigurations: Record<Scene, SceneConfig> = {
},
[Scene.Onboarding]: {
projectBased: true,
hideBillingNotice: true,
hideProjectNotice: true,
},
[Scene.ToolbarLaunch]: {
Expand Down
Loading