Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldambra committed Oct 24, 2024
1 parent c9e2d98 commit 05e3fca
Showing 1 changed file with 26 additions and 22 deletions.
48 changes: 26 additions & 22 deletions frontend/src/lib/components/PropertiesTable/PropertiesTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -222,29 +222,33 @@ export function PropertiesTable({
if (!properties || Array.isArray(properties) || !isObject(properties)) {
return []
}
let entries = Object.entries(properties).sort((a, b) => {
// if this is a posthog property we want to sort by its label
const propertyTypeMap: Record<PropertyDefinitionType, TaxonomicFilterGroupType> = {
[PropertyDefinitionType.Event]: TaxonomicFilterGroupType.EventProperties,
[PropertyDefinitionType.Person]: TaxonomicFilterGroupType.PersonProperties,
[PropertyDefinitionType.Group]: TaxonomicFilterGroupType.GroupsPrefix,
[PropertyDefinitionType.Session]: TaxonomicFilterGroupType.SessionProperties,
[PropertyDefinitionType.LogEntry]: TaxonomicFilterGroupType.LogEntries,
}

const propertyType = propertyTypeMap[type] || TaxonomicFilterGroupType.EventProperties

const left = getCoreFilterDefinition(a[0], propertyType)?.label || a[0]
const right = getCoreFilterDefinition(b[0], propertyType)?.label || b[0]

if (left < right) {
return -1
}
if (left > right) {
return 1
}
return 0
})
let entries = Object.entries(properties)
if (sortProperties) {
entries = entries.sort((a, b) => {
// if this is a posthog property we want to sort by its label
const propertyTypeMap: Record<PropertyDefinitionType, TaxonomicFilterGroupType> = {
[PropertyDefinitionType.Event]: TaxonomicFilterGroupType.EventProperties,
[PropertyDefinitionType.Person]: TaxonomicFilterGroupType.PersonProperties,
[PropertyDefinitionType.Group]: TaxonomicFilterGroupType.GroupsPrefix,
[PropertyDefinitionType.Session]: TaxonomicFilterGroupType.SessionProperties,
[PropertyDefinitionType.LogEntry]: TaxonomicFilterGroupType.LogEntries,
}

const propertyType = propertyTypeMap[type] || TaxonomicFilterGroupType.EventProperties

const left = getCoreFilterDefinition(a[0], propertyType)?.label || a[0]
const right = getCoreFilterDefinition(b[0], propertyType)?.label || b[0]

if (left < right) {
return -1
}
if (left > right) {
return 1
}
return 0
})
}

if (searchTerm) {
const normalizedSearchTerm = searchTerm.toLowerCase()
Expand Down

0 comments on commit 05e3fca

Please sign in to comment.