-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored all FieldDisplay types for performance optimization (#5768)
This PR is the second part of #5693. It optimizes all remaining field types. The observed improvements are : - x2 loading time improvement on table rows - more consistent render time Here's a summary of measured improvements, what's given here is the average of hundreds of renders with a React Profiler component. (in our Storybook performance stories) | Component | Before (µs) | After (µs) | | ----- | ------------- | --- | | TextFieldDisplay | 127 | 83 | | EmailFieldDisplay | 117 | 83 | | NumberFieldDisplay | 97 | 56 | | DateFieldDisplay | 240 | 52 | | CurrencyFieldDisplay | 236 | 110 | | FullNameFieldDisplay | 131 | 85 | | AddressFieldDisplay | 118 | 81 | | BooleanFieldDisplay | 130 | 100 | | JSONFieldDisplay | 248 | 49 | | LinksFieldDisplay | 1180 | 140 | | LinkFieldDisplay | 140 | 78 | | MultiSelectFieldDisplay | 770 | 130 | | SelectFieldDisplay | 230 | 87 |
- Loading branch information
1 parent
007e0e8
commit 03b3c8a
Showing
101 changed files
with
17,163 additions
and
15,791 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 5 additions & 3 deletions
8
.../modules/object-record/record-field/meta-types/display/components/AddressFieldDisplay.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
.../modules/object-record/record-field/meta-types/display/components/BooleanFieldDisplay.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import { useBooleanField } from '@/object-record/record-field/meta-types/hooks/useBooleanField'; | ||
import { useBooleanFieldDisplay } from '@/object-record/record-field/meta-types/hooks/useBooleanFieldDisplay'; | ||
import { BooleanDisplay } from '@/ui/field/display/components/BooleanDisplay'; | ||
|
||
export const BooleanFieldDisplay = () => { | ||
const { fieldValue } = useBooleanField(); | ||
const { fieldValue } = useBooleanFieldDisplay(); | ||
|
||
return <BooleanDisplay value={fieldValue} />; | ||
}; |
5 changes: 2 additions & 3 deletions
5
...modules/object-record/record-field/meta-types/display/components/CurrencyFieldDisplay.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
import { useCurrencyFieldDisplay } from '@/object-record/record-field/meta-types/hooks/useCurrencyFieldDisplay'; | ||
import { CurrencyDisplay } from '@/ui/field/display/components/CurrencyDisplay'; | ||
|
||
import { useCurrencyField } from '../../hooks/useCurrencyField'; | ||
|
||
export const CurrencyFieldDisplay = () => { | ||
const { fieldValue } = useCurrencyField(); | ||
const { fieldValue } = useCurrencyFieldDisplay(); | ||
|
||
return <CurrencyDisplay currencyValue={fieldValue} />; | ||
}; |
5 changes: 2 additions & 3 deletions
5
...src/modules/object-record/record-field/meta-types/display/components/DateFieldDisplay.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
import { useDateFieldDisplay } from '@/object-record/record-field/meta-types/hooks/useDateFieldDisplay'; | ||
import { DateDisplay } from '@/ui/field/display/components/DateDisplay'; | ||
|
||
import { useDateField } from '../../hooks/useDateField'; | ||
|
||
export const DateFieldDisplay = () => { | ||
const { fieldValue } = useDateField(); | ||
const { fieldValue } = useDateFieldDisplay(); | ||
|
||
return <DateDisplay value={fieldValue} />; | ||
}; |
5 changes: 2 additions & 3 deletions
5
...modules/object-record/record-field/meta-types/display/components/DateTimeFieldDisplay.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
import { useDateTimeFieldDisplay } from '@/object-record/record-field/meta-types/hooks/useDateTimeFieldDisplay'; | ||
import { DateTimeDisplay } from '@/ui/field/display/components/DateTimeDisplay'; | ||
|
||
import { useDateTimeField } from '../../hooks/useDateTimeField'; | ||
|
||
export const DateTimeFieldDisplay = () => { | ||
const { fieldValue } = useDateTimeField(); | ||
const { fieldValue } = useDateTimeFieldDisplay(); | ||
|
||
return <DateTimeDisplay value={fieldValue} />; | ||
}; |
5 changes: 2 additions & 3 deletions
5
...rc/modules/object-record/record-field/meta-types/display/components/EmailFieldDisplay.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
import { useEmailFieldDisplay } from '@/object-record/record-field/meta-types/hooks/useEmailFieldDisplay'; | ||
import { EmailDisplay } from '@/ui/field/display/components/EmailDisplay'; | ||
|
||
import { useEmailField } from '../../hooks/useEmailField'; | ||
|
||
export const EmailFieldDisplay = () => { | ||
const { fieldValue } = useEmailField(); | ||
const { fieldValue } = useEmailFieldDisplay(); | ||
|
||
return <EmailDisplay value={fieldValue} />; | ||
}; |
10 changes: 6 additions & 4 deletions
10
...modules/object-record/record-field/meta-types/display/components/FullNameFieldDisplay.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 9 additions & 13 deletions
22
...src/modules/object-record/record-field/meta-types/display/components/JsonFieldDisplay.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,15 @@ | ||
import { useJsonField } from '@/object-record/record-field/meta-types/hooks/useJsonField'; | ||
import { isFieldRawJsonValue } from '@/object-record/record-field/types/guards/isFieldRawJsonValue'; | ||
import { useJsonFieldDisplay } from '@/object-record/record-field/meta-types/hooks/useJsonFieldDisplay'; | ||
import { JsonDisplay } from '@/ui/field/display/components/JsonDisplay'; | ||
import { isDefined } from '~/utils/isDefined'; | ||
|
||
export const JsonFieldDisplay = () => { | ||
const { fieldValue, maxWidth } = useJsonField(); | ||
const { fieldValue, maxWidth } = useJsonFieldDisplay(); | ||
|
||
return ( | ||
<JsonDisplay | ||
text={ | ||
isFieldRawJsonValue(fieldValue) && isDefined(fieldValue) | ||
? JSON.stringify(fieldValue) | ||
: '' | ||
} | ||
maxWidth={maxWidth} | ||
/> | ||
); | ||
if (!isDefined(fieldValue)) { | ||
return <></>; | ||
} | ||
|
||
const value = JSON.stringify(fieldValue); | ||
|
||
return <JsonDisplay text={value} maxWidth={maxWidth} />; | ||
}; |
5 changes: 2 additions & 3 deletions
5
...src/modules/object-record/record-field/meta-types/display/components/LinkFieldDisplay.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
import { useLinkFieldDisplay } from '@/object-record/record-field/meta-types/hooks/useLinkFieldDisplay'; | ||
import { LinkDisplay } from '@/ui/field/display/components/LinkDisplay'; | ||
|
||
import { useLinkField } from '../../hooks/useLinkField'; | ||
|
||
export const LinkFieldDisplay = () => { | ||
const { fieldValue } = useLinkField(); | ||
const { fieldValue } = useLinkFieldDisplay(); | ||
|
||
return <LinkDisplay value={fieldValue} />; | ||
}; |
4 changes: 2 additions & 2 deletions
4
...rc/modules/object-record/record-field/meta-types/display/components/LinksFieldDisplay.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.