Skip to content

Commit

Permalink
fix(environments): Update API calls for using currentProjectId (#26550
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Twixes authored Dec 3, 2024
1 parent 9de5673 commit a3e9d05
Show file tree
Hide file tree
Showing 29 changed files with 141 additions and 127 deletions.
12 changes: 6 additions & 6 deletions frontend/src/layout/navigation-3000/sidebars/featureFlags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import { deleteWithUndo } from 'lib/utils/deleteWithUndo'
import { featureFlagLogic } from 'scenes/feature-flags/featureFlagLogic'
import { groupFilters } from 'scenes/feature-flags/FeatureFlags'
import { featureFlagsLogic } from 'scenes/feature-flags/featureFlagsLogic'
import { projectLogic } from 'scenes/projectLogic'
import { sceneLogic } from 'scenes/sceneLogic'
import { Scene } from 'scenes/sceneTypes'
import { teamLogic } from 'scenes/teamLogic'
import { urls } from 'scenes/urls'

import { groupsModel } from '~/models/groupsModel'
Expand All @@ -35,8 +35,8 @@ export const featureFlagsSidebarLogic = kea<featureFlagsSidebarLogicType>([
values: [
featureFlagsLogic,
['featureFlags', 'featureFlagsLoading'],
teamLogic,
['currentTeamId'],
projectLogic,
['currentProjectId'],
sceneLogic,
['activeScene', 'sceneParams'],
groupsModel,
Expand All @@ -46,8 +46,8 @@ export const featureFlagsSidebarLogic = kea<featureFlagsSidebarLogicType>([
}),
selectors(({ actions }) => ({
contents: [
(s) => [s.relevantFeatureFlags, s.featureFlagsLoading, s.currentTeamId, s.aggregationLabel],
(relevantFeatureFlags, featureFlagsLoading, currentTeamId, aggregationLabel) => [
(s) => [s.relevantFeatureFlags, s.featureFlagsLoading, s.currentProjectId, s.aggregationLabel],
(relevantFeatureFlags, featureFlagsLoading, currentProjectId, aggregationLabel) => [
{
key: 'feature-flags',
noun: 'feature flag',
Expand Down Expand Up @@ -147,7 +147,7 @@ export const featureFlagsSidebarLogic = kea<featureFlagsSidebarLogicType>([
label: 'Delete feature flag',
onClick: () => {
void deleteWithUndo({
endpoint: `projects/${currentTeamId}/feature_flags`,
endpoint: `projects/${currentProjectId}/feature_flags`,
object: { name: featureFlag.key, id: featureFlag.id },
callback: () => {
actions.loadFeatureFlags()
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/layout/navigation-3000/sidebars/insights.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { afterMount, connect, kea, listeners, path, reducers, selectors } from '
import { subscriptions } from 'kea-subscriptions'
import { deleteInsightWithUndo } from 'lib/utils/deleteWithUndo'
import { insightsApi } from 'scenes/insights/utils/api'
import { projectLogic } from 'scenes/projectLogic'
import { INSIGHTS_PER_PAGE, savedInsightsLogic } from 'scenes/saved-insights/savedInsightsLogic'
import { sceneLogic } from 'scenes/sceneLogic'
import { Scene } from 'scenes/sceneTypes'
import { teamLogic } from 'scenes/teamLogic'
import { urls } from 'scenes/urls'

import { navigation3000Logic } from '~/layout/navigation-3000/navigationLogic'
Expand Down Expand Up @@ -46,8 +46,8 @@ export const insightsSidebarLogic = kea<insightsSidebarLogicType>([
})),
selectors(({ actions, values, cache }) => ({
contents: [
(s) => [s.insights, s.infiniteInsights, s.insightsLoading, teamLogic.selectors.currentTeamId],
(insights, infiniteInsights, insightsLoading, currentTeamId) => [
(s) => [s.insights, s.infiniteInsights, s.insightsLoading, projectLogic.selectors.currentProjectId],
(insights, infiniteInsights, insightsLoading, currentProjectId) => [
{
key: 'insights',
noun: 'insight',
Expand Down Expand Up @@ -92,7 +92,7 @@ export const insightsSidebarLogic = kea<insightsSidebarLogicType>([
onClick: () => {
void deleteInsightWithUndo({
object: insight,
endpoint: `projects/${currentTeamId}/insights`,
endpoint: `projects/${currentProjectId}/insights`,
callback: actions.loadInsights,
})
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { dayjs } from 'lib/dayjs'
import { LemonMarkdown } from 'lib/lemon-ui/LemonMarkdown'
import { toParams } from 'lib/utils'
import posthog from 'posthog-js'
import { teamLogic } from 'scenes/teamLogic'
import { projectLogic } from 'scenes/projectLogic'

import { ActivityFilters, activityForSceneLogic } from './activityForSceneLogic'
import type { sidePanelActivityLogicType } from './sidePanelActivityLogicType'
Expand All @@ -34,7 +34,7 @@ export enum SidePanelActivityTab {
export const sidePanelActivityLogic = kea<sidePanelActivityLogicType>([
path(['scenes', 'navigation', 'sidepanel', 'sidePanelActivityLogic']),
connect({
values: [activityForSceneLogic, ['sceneActivityFilters']],
values: [activityForSceneLogic, ['sceneActivityFilters'], projectLogic, ['currentProjectId']],
}),
actions({
togglePolling: (pageIsVisible: boolean) => ({ pageIsVisible }),
Expand Down Expand Up @@ -104,7 +104,7 @@ export const sidePanelActivityLogic = kea<sidePanelActivityLogicType>([
}

await api.create(
`api/projects/${teamLogic.values.currentTeamId}/activity_log/bookmark_activity_notification`,
`api/projects/${values.currentProjectId}/activity_log/bookmark_activity_notification`,
{
bookmark: latestNotification.created_at.toISOString(),
}
Expand All @@ -123,7 +123,7 @@ export const sidePanelActivityLogic = kea<sidePanelActivityLogicType>([

try {
const response = await api.get<ChangesResponse>(
`api/projects/${teamLogic.values.currentTeamId}/activity_log/important_changes?` +
`api/projects/${values.currentProjectId}/activity_log/important_changes?` +
toParams({ unread: onlyUnread })
)

Expand Down
6 changes: 3 additions & 3 deletions frontend/src/models/groupPropertiesModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { connect, events, kea, path, selectors } from 'kea'
import { loaders } from 'kea-loaders'
import api from 'lib/api'
import { groupsAccessLogic } from 'lib/introductions/groupsAccessLogic'
import { teamLogic } from 'scenes/teamLogic'
import { projectLogic } from 'scenes/projectLogic'

import { GroupTypeProperties, PersonProperty } from '~/types'

Expand All @@ -11,15 +11,15 @@ import type { groupPropertiesModelType } from './groupPropertiesModelType'
export const groupPropertiesModel = kea<groupPropertiesModelType>([
path(['models', 'groupPropertiesModel']),
connect({
values: [teamLogic, ['currentTeamId'], groupsAccessLogic, ['groupsEnabled']],
values: [projectLogic, ['currentProjectId'], groupsAccessLogic, ['groupsEnabled']],
}),
loaders(({ values }) => ({
allGroupProperties: [
{} as GroupTypeProperties,
{
loadAllGroupProperties: async () => {
if (values.groupsEnabled) {
return await api.get(`api/projects/${values.currentTeamId}/groups/property_definitions`)
return await api.get(`api/projects/${values.currentProjectId}/groups/property_definitions`)
}
return {}
},
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/models/groupsModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { subscriptions } from 'kea-subscriptions'
import api from 'lib/api'
import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
import { groupsAccessLogic, GroupsAccessStatus } from 'lib/introductions/groupsAccessLogic'
import { teamLogic } from 'scenes/teamLogic'
import { projectLogic } from 'scenes/projectLogic'

import { GroupType, GroupTypeIndex } from '~/types'

Expand All @@ -18,19 +18,19 @@ export interface Noun {
export const groupsModel = kea<groupsModelType>([
path(['models', 'groupsModel']),
connect({
values: [teamLogic, ['currentTeamId'], groupsAccessLogic, ['groupsEnabled', 'groupsAccessStatus']],
values: [projectLogic, ['currentProjectId'], groupsAccessLogic, ['groupsEnabled', 'groupsAccessStatus']],
}),
loaders(({ values }) => ({
groupTypesRaw: [
[] as Array<GroupType>,
{
loadAllGroupTypes: async () => {
return await api.get(`api/projects/${values.currentTeamId}/groups_types`)
return await api.get(`api/projects/${values.currentProjectId}/groups_types`)
},
updateGroupTypesMetadata: async (payload: Array<GroupType>) => {
if (values.groupsEnabled) {
return await api.update(
`/api/projects/${teamLogic.values.currentTeamId}/groups_types/update_metadata`,
`/api/projects/${values.currentProjectId}/groups_types/update_metadata`,
payload
)
}
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/models/notebooksModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type { notebookLogicType } from 'scenes/notebooks/Notebook/notebookLogicT
import { defaultNotebookContent, EditorFocusPosition, JSONContent } from 'scenes/notebooks/Notebook/utils'
import { notebookPanelLogic } from 'scenes/notebooks/NotebookPanel/notebookPanelLogic'
import { LOCAL_NOTEBOOK_TEMPLATES } from 'scenes/notebooks/NotebookTemplates/notebookTemplates'
import { teamLogic } from 'scenes/teamLogic'
import { projectLogic } from 'scenes/projectLogic'
import { urls } from 'scenes/urls'

import { InsightVizNode, Node } from '~/queries/schema'
Expand Down Expand Up @@ -75,7 +75,7 @@ export const notebooksModel = kea<notebooksModelType>([
createNotebookFromDashboard: (dashboard: DashboardType<QueryBasedInsightModel>) => ({ dashboard }),
}),
connect({
values: [teamLogic, ['currentTeamId']],
values: [projectLogic, ['currentProjectId']],
}),

reducers({
Expand Down Expand Up @@ -105,7 +105,7 @@ export const notebooksModel = kea<notebooksModelType>([

deleteNotebook: async ({ shortId, title }) => {
await deleteWithUndo({
endpoint: `projects/${values.currentTeamId}/notebooks`,
endpoint: `projects/${values.currentProjectId}/notebooks`,
object: { name: title || shortId, id: shortId },
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useCallback } from 'react'
import { dataWarehouseJoinsLogic } from 'scenes/data-warehouse/external/dataWarehouseJoinsLogic'
import { dataWarehouseSceneLogic } from 'scenes/data-warehouse/settings/dataWarehouseSceneLogic'
import { viewLinkLogic } from 'scenes/data-warehouse/viewLinkLogic'
import { teamLogic } from 'scenes/teamLogic'
import { projectLogic } from 'scenes/projectLogic'
import { urls } from 'scenes/urls'

import { DatabaseSchemaTable, DatabaseSerializedFieldType } from '~/queries/schema'
Expand Down Expand Up @@ -46,7 +46,7 @@ const isNonEditableSchemaType = (schemaType: unknown): schemaType is NonEditable
return typeof schemaType === 'string' && nonEditableSchemaTypes.includes(schemaType as NonEditableSchemaTypes)
}
const JoinsMoreMenu = ({ tableName, fieldName }: { tableName: string; fieldName: string }): JSX.Element => {
const { currentTeamId } = useValues(teamLogic)
const { currentProjectId } = useValues(projectLogic)
const { toggleEditJoinModal } = useActions(viewLinkLogic)
const { joins, joinsLoading } = useValues(dataWarehouseJoinsLogic)
const { loadJoins } = useActions(dataWarehouseJoinsLogic)
Expand All @@ -68,7 +68,7 @@ const JoinsMoreMenu = ({ tableName, fieldName }: { tableName: string; fieldName:
fullWidth
onClick={() => {
void deleteWithUndo({
endpoint: `projects/${currentTeamId}/warehouse_view_link`,
endpoint: `projects/${currentProjectId}/warehouse_view_link`,
object: {
id: join.id,
name: `${join.field_name} on ${join.source_table_name}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { loaders } from 'kea-loaders'
import api from 'lib/api'
import { dayjs, dayjsUtcToTimezone } from 'lib/dayjs'
import { range } from 'lib/utils'
import { projectLogic } from 'scenes/projectLogic'
import { Scene } from 'scenes/sceneTypes'
import { urls } from 'scenes/urls'

Expand Down Expand Up @@ -31,15 +32,15 @@ export const ingestionWarningsLogic = kea<ingestionWarningsLogicType>([
path(['scenes', 'data-management', 'ingestion-warnings', 'ingestionWarningsLogic']),

connect({
values: [teamLogic, ['currentTeamId', 'timezone']],
values: [teamLogic, ['timezone'], projectLogic, ['currentProjectId']],
}),

loaders(({ values }) => ({
data: [
[] as IngestionWarningSummary[],
{
loadData: async () => {
const { results } = await api.get(`api/projects/${values.currentTeamId}/ingestion_warnings`)
const { results } = await api.get(`api/projects/${values.currentProjectId}/ingestion_warnings`)
return results
},
},
Expand Down
Loading

0 comments on commit a3e9d05

Please sign in to comment.