Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions assets/js/src/core/constants/versionConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@

export enum VersionCategoryName {
SYSTEM_DATA = 'systemData',
PROPERTIES = 'properties',
META = 'meta'
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ interface IObjectVersionsFieldsViewProps {
isExpandedUnmodifiedFields: boolean
}

const SECTIONS_WITH_TRANSLATION: string[] = [VersionCategoryName.SYSTEM_DATA]
const SECTIONS_WITH_TRANSLATION: string[] = [VersionCategoryName.SYSTEM_DATA, VersionCategoryName.PROPERTIES]
const SECTIONS_WITH_COMPLEX_TYPES: string[] = [DynamicTypesList.BLOCK, DynamicTypesList.FIELD_COLLECTIONS]

export const ObjectVersionsFieldsView = ({ breadcrumbsList, versionViewData, versionKeysList, isExpandedUnmodifiedFields }: IObjectVersionsFieldsViewProps): React.JSX.Element => {
Expand Down Expand Up @@ -64,7 +64,8 @@ export const ObjectVersionsFieldsView = ({ breadcrumbsList, versionViewData, ver
const renderFieldTitle = ({ key, locale, isCommonSection }: { key: string, locale: string, isCommonSection: boolean }): React.JSX.Element => {
if (isEmptyValue(key)) return <></>

const textValue = isCommonSection ? t(`version.${key}`) : t(key)
const isSystemDataField = breadcrumbKey === VersionCategoryName.SYSTEM_DATA
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

breadcrumbKey should be passed as an argument to renderFieldTitle, and isCommonSection can be deleted.

const textValue = isSystemDataField ? t(`version.${key}`) : t(key)

return (
<Text className={ styles.fieldTitle }>
Expand All @@ -76,7 +77,7 @@ export const ObjectVersionsFieldsView = ({ breadcrumbsList, versionViewData, ver
return (
<>
{breadcrumbsList?.map((breadcrumb, index) => {
const isCommonSection = breadcrumb.key === VersionCategoryName.SYSTEM_DATA
const isCommonSection = breadcrumb.key === VersionCategoryName.SYSTEM_DATA || breadcrumb.key === VersionCategoryName.PROPERTIES

return (
<div key={ `${index}-${breadcrumb.key}` }>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,41 @@ export const getFormattedDataStructure = async ({ objectId, layout, versionData,
return result
}

const getPropertiesData = (): IFormattedDataStructureData[] => {
return versionData.properties.map((property) => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I propose to add the fallback:
if (isEmpty(versionData?.properties) || !isArray(versionData?.properties)) return []

This helps us avoid typing errors and prevent potential data mismatches.

let fieldtype = 'input'
let fieldValue = property.data

if (['asset', 'document', 'object'].includes(property.type)) {
if (property.data && typeof property.data === 'object' && 'id' in property.data) {
fieldValue = `${property.type} [ID: ${property.data.id}]`
} else {
fieldValue = property.data
}
} else if (property.type === 'bool') {
fieldtype = 'checkbox'
}

return {
fieldBreadcrumbTitle: 'properties',
fieldData: {
title: property.key,
name: property.key,
fieldtype,
config: property.config
} as any,
fieldValue,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In IFormattedDataStructureData, we have the fieldPath. Please just add fieldPath: ''.

versionId,
versionCount
}
})
}

const layoutData = await processLayoutData({ data: layout })
const generalSystemData = getGeneralSystemData()
const propertiesData = getPropertiesData()

return [...generalSystemData, ...layoutData]
return [...generalSystemData, ...propertiesData, ...layoutData]
}

const getUniqFieldKey = (item: any): string => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { api } from "@sdk/api";
import { DataProperty } from "../properties/properties-api-slice-enhanced";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We need to remove this code ;)

export const addTagTypes = ["Versions"] as const;
const injectedRtkApi = api
.enhanceEndpoints({
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions public/build/1d60c40a-4e29-408c-ab8d-d8a4af85b984/entrypoints.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions public/build/1d60c40a-4e29-408c-ab8d-d8a4af85b984/manifest.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 43 additions & 0 deletions public/build/1d60c40a-4e29-408c-ab8d-d8a4af85b984/mf-manifest.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 51 additions & 0 deletions public/build/1d60c40a-4e29-408c-ab8d-d8a4af85b984/mf-stats.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading