Skip to content

Commit

Permalink
Merge branch 'master' into dn-chore/upgrade-playwright
Browse files Browse the repository at this point in the history
  • Loading branch information
daibhin committed Nov 22, 2023
2 parents 8043c9e + 81da5f3 commit 928a68d
Show file tree
Hide file tree
Showing 51 changed files with 402 additions and 79 deletions.
23 changes: 17 additions & 6 deletions ee/api/test/test_organization.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import datetime as dt
import random
from unittest.mock import ANY, patch
from unittest import mock
from unittest.mock import ANY, call, patch

from freezegun.api import freeze_time
from rest_framework import status
Expand Down Expand Up @@ -104,11 +105,21 @@ def test_delete_last_organization(self, mock_capture):
"Did not return a 404 on trying to delete a nonexistent org",
)

mock_capture.assert_called_once_with(
self.user.distinct_id,
"organization deleted",
organization_props,
groups={"instance": ANY, "organization": str(org_id)},
mock_capture.assert_has_calls(
[
call(
self.user.distinct_id,
"membership level changed",
properties={"new_level": 15, "previous_level": 1},
groups=mock.ANY,
),
call(
self.user.distinct_id,
"organization deleted",
organization_props,
groups={"instance": mock.ANY, "organization": str(org_id)},
),
]
)

def test_no_delete_organization_not_owning(self):
Expand Down
2 changes: 1 addition & 1 deletion ee/clickhouse/models/test/__snapshots__/test_property.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
---
# name: test_parse_groups_persons_edge_case_with_single_filter
<class 'tuple'> (
'AND ( has(%(vglobalperson_0)s, replaceRegexpAll(JSONExtractRaw(person_props, %(kglobalperson_0)s), \'^"|"$\', \'\')))',
'AND ( has(%(vglobalperson_0)s, "pmat_email"))',
<class 'dict'> {
'kglobalperson_0': 'email',
'vglobalperson_0': <class 'list'> [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# name: ClickhouseTestExperimentSecondaryResults.test_basic_secondary_metric_results
'
/* user_id:133 celery:posthog.celery.sync_insight_caching_state */
/* user_id:131 celery:posthog.celery.sync_insight_caching_state */
SELECT team_id,
date_diff('second', max(timestamp), now()) AS age
FROM events
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/__snapshots__/lemon-ui-lemon-banner--closable.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/__snapshots__/lemon-ui-lemon-banner--dismissable.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/__snapshots__/lemon-ui-lemon-banner--error.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/__snapshots__/lemon-ui-lemon-banner--info.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/__snapshots__/lemon-ui-lemon-banner--success.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/__snapshots__/lemon-ui-lemon-banner--warning.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/__snapshots__/lemon-ui-lemon-button--as-links.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/__snapshots__/scenes-app-batchexports--create-export.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/__snapshots__/scenes-app-notebooks--notebooks-list.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/__snapshots__/scenes-app-pipeline--pipeline-app-logs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/__snapshots__/scenes-app-surveys--surveys-list.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/__snapshots__/scenes-other-login--sso-error.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/__snapshots__/scenes-other-settings--settings-project.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/__snapshots__/scenes-other-settings--settings-user.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
overflow: hidden;
height: calc(1.2em * (1 - var(--breadcrumbs-compaction-rate)));
box-sizing: content-box;
font-family: var(--font-sans) !important;

> * {
position: absolute;
Expand Down
21 changes: 11 additions & 10 deletions frontend/src/layout/navigation-3000/sidebars/personsAndGroups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,17 @@ export const personsAndGroupsSidebarLogic = kea<personsAndGroupsSidebarLogicType
groupType.name_singular || `${groupType.group_type} group`,
groupType.name_plural || `${groupType.group_type} groups`,
],
items: groups[groupType.group_type_index].results.map((group) => {
const { searchTerm } = values
const displayId = groupDisplayId(group.group_key, group.group_properties)
return {
key: group.group_key,
name: displayId,
url: urls.group(groupType.group_type_index, group.group_key),
searchMatch: findSearchTermInItemName(displayId, searchTerm),
} as BasicListItem
}),
items:
groups[groupType.group_type_index]?.results.map((group) => {
const { searchTerm } = values
const displayId = groupDisplayId(group.group_key, group.group_properties)
return {
key: group.group_key,
name: displayId,
url: urls.group(groupType.group_type_index, group.group_key),
searchMatch: findSearchTermInItemName(displayId, searchTerm),
} as BasicListItem
}) || [],
loading: groupsLoading[groupType.group_type_index],
// FIXME: Add remote
} as SidebarCategory)
Expand Down
14 changes: 11 additions & 3 deletions frontend/src/lib/components/BillingAlertsV2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,26 @@ export function BillingAlertsV2(): JSX.Element | null {
const [alertHidden, setAlertHidden] = useState(false)

useEffect(() => {
if (billingAlert?.pathName && currentLocation.pathname !== billingAlert?.pathName) {
setAlertHidden(true)
} else {
setAlertHidden(false)
}
if (billingAlert) {
reportBillingAlertShown(billingAlert)
}
}, [billingAlert])
}, [billingAlert, currentLocation])

if (!billingAlert || alertHidden) {
return null
}

const showButton = billingAlert.contactSupport || currentLocation.pathname !== urls.organizationBilling()
const showButton =
billingAlert.action || billingAlert.contactSupport || currentLocation.pathname !== urls.organizationBilling()

const buttonProps = billingAlert.contactSupport
const buttonProps = billingAlert.action
? billingAlert.action
: billingAlert.contactSupport
? {
to: 'mailto:[email protected]',
children: billingAlert.buttonCTA || 'Contact support',
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/lib/components/BridgePage/BridgePage.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
flex-direction: column;
flex: 1;
overflow: hidden;
height: 100vh;
min-height: 100vh;
height: 100%;

&::-webkit-scrollbar {
width: 0 !important;
Expand Down
8 changes: 7 additions & 1 deletion frontend/src/lib/components/CompactList/CompactList.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@
padding: 0 0.5rem 0.5rem;
}

.LemonButton {
font-family: var(--font-sans) !important;
}

.secondary-text {
color: var(--text-secondary);
.posthog-3000 & {
color: var(--text-secondary);
}
}
}
9 changes: 5 additions & 4 deletions frontend/src/lib/lemon-ui/LemonBanner/LemonBanner.scss
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
.LemonBanner {
align-items: center;
border-radius: var(--radius);
padding: 0.5rem 0.75rem;
border: solid 1px var(--border-3000);
color: var(--primary-alt);
font-weight: 500;
display: flex;
align-items: center;
text-align: left;
font-weight: 500;
gap: 0.5rem;
min-height: 3rem;
padding: 0.5rem 0.75rem;
text-align: left;

&.LemonBanner--info {
background-color: var(--primary-alt-highlight);
Expand Down
35 changes: 22 additions & 13 deletions frontend/src/lib/lemon-ui/LemonButton/LemonButton.scss
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
.LemonButton {
position: relative;
transition: background-color 200ms ease, color 200ms ease, border 200ms ease, opacity 200ms ease,
transform 100ms ease;
display: flex;
flex-direction: row;
flex-shrink: 0;
align-items: center;
justify-content: flex-start;
padding: 0.25rem 0.75rem;
gap: 0.5rem;
appearance: none !important; // Important as this gets overridden by Ant styles...
background: none;
border-radius: var(--radius);
border: none;
cursor: pointer;
display: flex;
flex-direction: row;

.posthog-3000 & {
font-family: var(--font-title);
}

flex-shrink: 0;
font-size: 0.875rem;
text-align: left;
line-height: 1.5rem;
font-weight: 500;
cursor: pointer;
gap: 0.5rem;
justify-content: flex-start;
line-height: 1.5rem;
padding: 0.25rem 0.75rem;
position: relative;
text-align: left;
transition: background-color 200ms ease, color 200ms ease, border 200ms ease, opacity 200ms ease,
transform 100ms ease;
user-select: none;
appearance: none !important; // Important as this gets overridden by Ant styles...

.font-normal {
font-family: var(--font-sans);
}

> span {
display: flex;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
.PropertyGroupFilters {
.property-group {
background-color: var(--side);

.posthog-3000 & {
border-width: 1px;
}

padding: 0.5rem;
border-radius: 4px;
}
Expand Down
7 changes: 5 additions & 2 deletions frontend/src/scenes/billing/BillingLimitInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ import { billingProductLogic } from './billingProductLogic'
import { LemonButton, LemonInput } from '@posthog/lemon-ui'
import { Tooltip } from 'lib/lemon-ui/Tooltip'
import clsx from 'clsx'
import { useRef } from 'react'

export const BillingLimitInput = ({ product }: { product: BillingProductV2Type }): JSX.Element | null => {
const limitInputRef = useRef<HTMLInputElement | null>(null)
const { billing, billingLoading } = useValues(billingLogic)
const { updateBillingLimits } = useActions(billingLogic)
const { isEditingBillingLimit, showBillingLimitInput, billingLimitInput, customLimitUsd } = useValues(
billingProductLogic({ product })
billingProductLogic({ product, billingLimitInputRef: limitInputRef })
)
const { setIsEditingBillingLimit, setBillingLimitInput } = useActions(billingProductLogic({ product }))

Expand Down Expand Up @@ -78,7 +80,7 @@ export const BillingLimitInput = ({ product }: { product: BillingProductV2Type }
return null
}
return (
<div className="border-t border-border p-8">
<div className="border-t border-border p-8" data-attr={`billing-limit-input-${product.type}`}>
<div className="flex">
<div className="flex items-center gap-1">
{!isEditingBillingLimit ? (
Expand All @@ -104,6 +106,7 @@ export const BillingLimitInput = ({ product }: { product: BillingProductV2Type }
<>
<div className="max-w-40">
<LemonInput
ref={limitInputRef}
type="number"
fullWidth={false}
value={billingLimitInput}
Expand Down
31 changes: 28 additions & 3 deletions frontend/src/scenes/billing/billingLogic.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { kea, path, actions, connect, afterMount, selectors, listeners, reducers } from 'kea'
import { loaders } from 'kea-loaders'
import api from 'lib/api'
import { BillingProductV2Type, BillingV2Type } from '~/types'
import { BillingProductV2Type, BillingV2Type, ProductKey } from '~/types'
import { router, urlToAction } from 'kea-router'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { dayjs } from 'lib/dayjs'
Expand All @@ -13,6 +13,7 @@ import { pluralize } from 'lib/utils'
import type { billingLogicType } from './billingLogicType'
import { forms } from 'kea-forms'
import { eventUsageLogic } from 'lib/utils/eventUsageLogic'
import { LemonBannerAction } from 'lib/lemon-ui/LemonBanner/LemonBanner'

export const ALLOCATION_THRESHOLD_ALERT = 0.85 // Threshold to show warning of event usage near limit
export const ALLOCATION_THRESHOLD_BLOCK = 1.2 // Threshold to block usage
Expand All @@ -24,6 +25,8 @@ export interface BillingAlertConfig {
contactSupport?: boolean
buttonCTA?: string
dismissKey?: string
action?: LemonBannerAction
pathName?: string
}

const parseBillingResponse = (data: Partial<BillingV2Type>): BillingV2Type => {
Expand Down Expand Up @@ -53,6 +56,8 @@ const parseBillingResponse = (data: Partial<BillingV2Type>): BillingV2Type => {
export const billingLogic = kea<billingLogicType>([
path(['scenes', 'billing', 'billingLogic']),
actions({
setProductSpecificAlert: (productSpecificAlert: BillingAlertConfig | null) => ({ productSpecificAlert }),
setScrollToProductKey: (scrollToProductKey: ProductKey | null) => ({ scrollToProductKey }),
setShowLicenseDirectInput: (show: boolean) => ({ show }),
reportBillingAlertShown: (alertConfig: BillingAlertConfig) => ({ alertConfig }),
reportBillingAlertActionClicked: (alertConfig: BillingAlertConfig) => ({ alertConfig }),
Expand All @@ -66,6 +71,18 @@ export const billingLogic = kea<billingLogicType>([
actions: [userLogic, ['loadUser'], eventUsageLogic, ['reportProductUnsubscribed']],
}),
reducers({
scrollToProductKey: [
null as ProductKey | null,
{
setScrollToProductKey: (_, { scrollToProductKey }) => scrollToProductKey,
},
],
productSpecificAlert: [
null as BillingAlertConfig | null,
{
setProductSpecificAlert: (_, { productSpecificAlert }) => productSpecificAlert,
},
],
showLicenseDirectInput: [
false,
{
Expand Down Expand Up @@ -144,8 +161,12 @@ export const billingLogic = kea<billingLogicType>([
},
],
billingAlert: [
(s) => [s.billing, s.preflight, s.projectedTotalAmountUsd],
(billing, preflight, projectedTotalAmountUsd): BillingAlertConfig | undefined => {
(s) => [s.billing, s.preflight, s.projectedTotalAmountUsd, s.productSpecificAlert],
(billing, preflight, projectedTotalAmountUsd, productSpecificAlert): BillingAlertConfig | undefined => {
if (productSpecificAlert) {
return productSpecificAlert
}

if (!billing || !preflight?.cloud) {
return
}
Expand Down Expand Up @@ -320,6 +341,10 @@ export const billingLogic = kea<billingLogicType>([
actions.setActivateLicenseValues({ license: hash.license })
actions.submitActivateLicense()
}
if (_search.products) {
const products = _search.products.split(',')
actions.setScrollToProductKey(products[0])
}
actions.setRedirectPath()
actions.setIsOnboarding()
},
Expand Down
Loading

0 comments on commit 928a68d

Please sign in to comment.