Skip to content

Commit

Permalink
merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
anirudhpillai committed Aug 20, 2024
2 parents efa261b + c333823 commit 21fb104
Show file tree
Hide file tree
Showing 233 changed files with 2,157 additions and 6,850 deletions.
7 changes: 2 additions & 5 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"cwd": "${workspaceFolder}",
"presentation": {
"group": "main"
}
},
"skipFiles": ["${workspaceFolder}/node_modules/kea-typegen/**/*.js"]
},
{
"name": "Frontend (https)",
Expand Down Expand Up @@ -50,7 +51,6 @@
},
"envFile": "${workspaceFolder}/.env",
"console": "integratedTerminal",
"python": "${workspaceFolder}/env/bin/python",
"cwd": "${workspaceFolder}",
"presentation": {
"group": "main"
Expand All @@ -77,7 +77,6 @@
"CLOUD_DEPLOYMENT": "dev"
},
"console": "integratedTerminal",
"python": "${workspaceFolder}/env/bin/python",
"cwd": "${workspaceFolder}",
"presentation": {
"group": "main"
Expand All @@ -96,7 +95,6 @@
"program": "${workspaceFolder}/manage.py",
"args": ["run_autoreload_celery", "--type=worker"],
"console": "integratedTerminal",
"python": "${workspaceFolder}/env/bin/python",
"cwd": "${workspaceFolder}",
"env": {
"SKIP_ASYNC_MIGRATIONS_SETUP": "0",
Expand Down Expand Up @@ -146,7 +144,6 @@
"PRINT_SQL": "1"
},
"console": "integratedTerminal",
"python": "${workspaceFolder}/env/bin/python",
"cwd": "${workspaceFolder}",
"presentation": {
"group": "main"
Expand Down
10 changes: 10 additions & 0 deletions cypress/e2e/persons.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,14 @@ describe('Persons', () => {
cy.wait(200)
cy.get('[data-row-key]').its('length').should('be.gte', 0)
})

it('Deleting person from list', () => {
cy.get('[data-attr=persons-search]').type('hodge').type('{enter}')
cy.contains('tr', '[email protected]').find('[data-attr=delete-person]').click()
cy.get('h3').should('have.text', 'Are you sure you want to delete "[email protected]"?')
cy.get('label').contains('I understand').click() // Acknowledge deletion
cy.get('.LemonButton--secondary').contains('Delete person').click()
cy.get('.Toastify__toast-body').contains('[email protected] was removed from the project')
cy.get('tr').contains('[email protected]').should('not.exist')
})
})
2 changes: 1 addition & 1 deletion ee/api/billing.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class LicenseKeySerializer(serializers.Serializer):

class BillingViewset(TeamAndOrgViewSetMixin, viewsets.GenericViewSet):
serializer_class = BillingSerializer
derive_current_team_from_user_only = True
param_derived_from_user_current_team = "team_id"

scope_object = "INTERNAL"

Expand Down
2 changes: 1 addition & 1 deletion ee/api/dashboard_collaborator.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class DashboardCollaboratorViewSet(
queryset = DashboardPrivilege.objects.select_related("dashboard").filter(user__is_active=True)
lookup_field = "user__uuid"
serializer_class = DashboardCollaboratorSerializer
filter_rewrite_rules = {"team_id": "dashboard__team_id"}
filter_rewrite_rules = {"project_id": "dashboard__team__project_id"}

def get_serializer_context(self) -> dict[str, Any]:
context = super().get_serializer_context()
Expand Down
2 changes: 1 addition & 1 deletion ee/clickhouse/views/person.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ def calculate_funnel_correlation_persons(


class LegacyEnterprisePersonViewSet(EnterprisePersonViewSet):
derive_current_team_from_user_only = True
param_derived_from_user_current_team = "team_id"
16 changes: 9 additions & 7 deletions ee/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,35 +51,37 @@ def extend_api_router(
project_feature_flags_router.register(
r"role_access",
feature_flag_role_access.FeatureFlagRoleAccessViewSet,
"feature_flag_role_access",
["team_id", "feature_flag_id"],
"project_feature_flag_role_access",
["project_id", "feature_flag_id"],
)
organizations_router.register(
r"resource_access",
organization_resource_access.OrganizationResourceAccessViewSet,
"organization_resource_access",
["organization_id"],
)
projects_router.register(r"hooks", hooks.HookViewSet, "project_hooks", ["team_id"])
projects_router.register(r"hooks", hooks.HookViewSet, "environment_hooks", ["team_id"])
projects_router.register(
r"explicit_members",
explicit_team_member.ExplicitTeamMemberViewSet,
"project_explicit_members",
"environment_explicit_members",
["team_id"],
)
project_dashboards_router.register(
r"collaborators",
dashboard_collaborator.DashboardCollaboratorViewSet,
"project_dashboard_collaborators",
["team_id", "dashboard_id"],
["project_id", "dashboard_id"],
)

projects_router.register(r"subscriptions", subscription.SubscriptionViewSet, "subscriptions", ["team_id"])
projects_router.register(
r"subscriptions", subscription.SubscriptionViewSet, "environment_subscriptions", ["team_id"]
)
projects_router.register(
r"session_recording_playlists",
session_recording_playlist.SessionRecordingPlaylistViewSet,
"project_session_recording_playlists",
["team_id"],
["project_id"],
)


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 not shown.
Binary file not shown.
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__/exporter-exporter--dashboard--dark.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__/exporter-exporter--dashboard--light.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.
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.
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__/insights-insightstable--hourly--dark.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.
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-dashboards--edit--dark.png
Binary file modified frontend/__snapshots__/scenes-app-dashboards--edit--light.png
Binary file modified frontend/__snapshots__/scenes-app-dashboards--show--dark.png
Binary file modified frontend/__snapshots__/scenes-app-dashboards--show--light.png
1 change: 1 addition & 0 deletions frontend/src/exporter/Exporter.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const Template: StoryFn<typeof Exporter> = (props) => {
</div>
)
}
Template.tags = ['test-skip'] // :FIXME: flaky tests, most likely due to resize observer changes

export const TrendsLineInsight: Story = Template.bind({})
TrendsLineInsight.args = { insight: require('../mocks/fixtures/api/projects/team_id/insights/trendsLine.json') }
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/exporter/Exporter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { teamLogic } from 'scenes/teamLogic'

import { ExportedInsight } from '~/exporter/ExportedInsight/ExportedInsight'
import { ExportedData, ExportType } from '~/exporter/types'
import { getQueryBasedDashboard } from '~/queries/nodes/InsightViz/utils'
import { Logo } from '~/toolbar/assets/Logo'
import { DashboardPlacement } from '~/types'

Expand Down Expand Up @@ -78,7 +79,7 @@ export function Exporter(props: ExportedData): JSX.Element {
) : dashboard ? (
<Dashboard
id={String(dashboard.id)}
dashboard={dashboard}
dashboard={getQueryBasedDashboard(dashboard)!}
placement={type === ExportType.Image ? DashboardPlacement.Export : DashboardPlacement.Public}
/>
) : recording ? (
Expand Down
15 changes: 6 additions & 9 deletions frontend/src/layout/navigation-3000/sidebars/insights.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import { urls } from 'scenes/urls'

import { navigation3000Logic } from '~/layout/navigation-3000/navigationLogic'
import { insightsModel } from '~/models/insightsModel'
import { getQueryBasedInsightModel } from '~/queries/nodes/InsightViz/utils'
import { InsightModel } from '~/types'
import { QueryBasedInsightModel } from '~/types'

import { BasicListItem, SidebarCategory } from '../types'
import type { insightsSidebarLogicType } from './insightsType'
Expand All @@ -36,11 +35,11 @@ export const insightsSidebarLogic = kea<insightsSidebarLogicType>([
})),
reducers(() => ({
infiniteInsights: [
[] as (InsightModel | undefined)[],
[] as (QueryBasedInsightModel | undefined)[],
{
[savedInsightsLogic.actionTypes.loadInsightsSuccess]: (state, { insights }) => {
// Reset array if offset is 0
const items: (InsightModel | undefined)[] = insights.offset === 0 ? [] : state.slice()
const items: (QueryBasedInsightModel | undefined)[] = insights.offset === 0 ? [] : state.slice()
for (let i = 0; i < insights.results.length; i++) {
items[insights.offset + i] = insights.results[i]
}
Expand All @@ -61,13 +60,11 @@ export const insightsSidebarLogic = kea<insightsSidebarLogicType>([
key: 'insights',
noun: 'insight',
onAdd: urls.insightNew(),
items: infiniteInsights.map((legacyInsight) => {
if (!legacyInsight) {
items: infiniteInsights.map((insight) => {
if (!insight) {
return undefined
}

const insight = getQueryBasedInsightModel(legacyInsight)

return {
key: insight.short_id,
name: insight.name || insight.derived_name || 'Untitled',
Expand Down Expand Up @@ -121,7 +118,7 @@ export const insightsSidebarLogic = kea<insightsSidebarLogicType>([
const updatedItem = await insightsApi.update(
insight.id,
{ name: newName },
{ writeAsQuery: values.queryBasedInsightSaving, readAsQuery: false }
{ writeAsQuery: values.queryBasedInsightSaving, readAsQuery: true }
)
insightsModel.actions.renameInsightSuccess(updatedItem)
},
Expand Down
12 changes: 8 additions & 4 deletions frontend/src/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import {
PluginLogEntry,
PropertyDefinition,
PropertyDefinitionType,
QueryBasedInsightModel,
RawAnnotationType,
RawBatchExportRun,
RoleMemberType,
Expand Down Expand Up @@ -306,15 +307,15 @@ class ApiRequest {
return this.projectsDetail(teamId).addPathComponent('insights')
}

public insight(id: InsightModel['id'], teamId?: TeamType['id']): ApiRequest {
public insight(id: QueryBasedInsightModel['id'], teamId?: TeamType['id']): ApiRequest {
return this.insights(teamId).addPathComponent(id)
}

public insightsActivity(teamId?: TeamType['id']): ApiRequest {
return this.insights(teamId).addPathComponent('activity')
}

public insightSharing(id: InsightModel['id'], teamId?: TeamType['id']): ApiRequest {
public insightSharing(id: QueryBasedInsightModel['id'], teamId?: TeamType['id']): ApiRequest {
return this.insight(id, teamId).addPathComponent('sharing')
}

Expand Down Expand Up @@ -914,6 +915,9 @@ const api = {
)
.get()
},
async get(id: number): Promise<InsightModel | null> {
return await new ApiRequest().insight(id).get()
},
async create(data: any): Promise<InsightModel> {
return await new ApiRequest().insights().create({ data })
},
Expand Down Expand Up @@ -1558,7 +1562,7 @@ const api = {
recordingId,
}: {
dashboardId?: DashboardType['id']
insightId?: InsightModel['id']
insightId?: QueryBasedInsightModel['id']
recordingId?: SessionRecordingType['id']
}): Promise<SharingConfigurationType | null> {
return dashboardId
Expand All @@ -1577,7 +1581,7 @@ const api = {
recordingId,
}: {
dashboardId?: DashboardType['id']
insightId?: InsightModel['id']
insightId?: QueryBasedInsightModel['id']
recordingId?: SessionRecordingType['id']
},
data: Partial<SharingConfigurationType>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/lib/components/AddToDashboard/AddToDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { IconWithCount } from 'lib/lemon-ui/icons'
import { LemonButton } from 'lib/lemon-ui/LemonButton'

import { dashboardsModel } from '~/models/dashboardsModel'
import { InsightModel } from '~/types'
import { QueryBasedInsightModel } from '~/types'

interface SaveToDashboardProps {
insight: Partial<InsightModel>
insight: Partial<QueryBasedInsightModel>
setOpenModal: (open: boolean) => void
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const addToDashboardModalLogic = kea<addToDashboardModalLogicType>([
key(keyForInsightLogicProps('new')),
path((key) => ['lib', 'components', 'AddToDashboard', 'saveToDashboardModalLogic', key]),
connect((props: InsightLogicProps) => ({
values: [insightLogic(props), ['queryBasedInsight']],
values: [insightLogic(props), ['insight']],
actions: [
insightLogic(props),
['updateInsight', 'updateInsightSuccess', 'updateInsightFailure'],
Expand Down Expand Up @@ -69,7 +69,7 @@ export const addToDashboardModalLogic = kea<addToDashboardModalLogicType>([
: nameSortedDashboards,
],
currentDashboards: [
(s) => [s.filteredDashboards, s.queryBasedInsight],
(s) => [s.filteredDashboards, s.insight],
(filteredDashboards, insight): DashboardBasicType[] =>
filteredDashboards.filter((d) => insight.dashboard_tiles?.map((dt) => dt.dashboard_id)?.includes(d.id)),
],
Expand Down Expand Up @@ -102,7 +102,7 @@ export const addToDashboardModalLogic = kea<addToDashboardModalLogicType>([
// either patch dashboard_tiles on the insight or add a dashboard_tiles API
actions.updateInsight(
{
dashboards: [...(values.queryBasedInsight.dashboards || []), dashboardId],
dashboards: [...(values.insight.dashboards || []), dashboardId],
},
() => {
actions.reportSavedInsightToDashboard()
Expand All @@ -119,8 +119,8 @@ export const addToDashboardModalLogic = kea<addToDashboardModalLogicType>([
removeFromDashboard: async ({ dashboardId }): Promise<void> => {
actions.updateInsight(
{
dashboards: (values.queryBasedInsight.dashboards || []).filter((d) => d !== dashboardId),
dashboard_tiles: (values.queryBasedInsight.dashboard_tiles || []).filter(
dashboards: (values.insight.dashboards || []).filter((d) => d !== dashboardId),
dashboard_tiles: (values.insight.dashboard_tiles || []).filter(
(dt) => dt.dashboard_id !== dashboardId
),
},
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/lib/components/Alerts/AlertDeletionWarning.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { insightLogic } from 'scenes/insights/insightLogic'
import { alertsLogic } from './alertsLogic'

export function AlertDeletionWarning(): JSX.Element | null {
const { insightProps, queryBasedInsight: insight } = useValues(insightLogic)
const { insightProps, insight } = useValues(insightLogic)

const { shouldShowAlertDeletionWarning } = useValues(
alertsLogic({ insightShortId: insight.short_id ?? '', insightLogicProps: insightProps })
alertsLogic({ insightShortId: insight.short_id!, insightLogicProps: insightProps })
)

if (!shouldShowAlertDeletionWarning || !insight.short_id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export function AnnotationsOverlay({
const { insightProps } = useValues(insightLogic)
const { tickIntervalPx, firstTickLeftPx } = useAnnotationsPositioning(chart, chartWidth, chartHeight)

// FIXME: This pollutes insightProps with dates and ticks, which is not ideal
const annotationsOverlayLogicProps: AnnotationsOverlayLogicProps = {
...insightProps,
dashboardId: insightProps.dashboardId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ import {
DashboardType,
DatedAnnotationType,
InsightLogicProps,
InsightModel,
IntervalType,
QueryBasedInsightModel,
} from '~/types'

import type { annotationsOverlayLogicType } from './annotationsOverlayLogicType'

export interface AnnotationsOverlayLogicProps extends Omit<InsightLogicProps, 'dashboardId'> {
dashboardId: DashboardType['id'] | undefined
insightNumericId: InsightModel['id'] | 'new'
insightNumericId: QueryBasedInsightModel['id'] | 'new'
dates: string[]
ticks: Tick[]
}
Expand Down
Loading

0 comments on commit 21fb104

Please sign in to comment.