-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: Refactor derived properties #37390
base: release
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,7 +43,6 @@ import { | |
PaginationDirection, | ||
TABLE_COLUMN_ORDER_KEY, | ||
} from "../constants"; | ||
import derivedProperties from "./parseDerivedProperties"; | ||
import { | ||
deleteLocalTableColumnOrderByWidgetId, | ||
generateLocalNewColumnOrderFromStickyValue, | ||
|
@@ -61,7 +60,7 @@ import { | |
} from "./utilities"; | ||
import type { BatchPropertyUpdatePayload } from "actions/controlActions"; | ||
import equal from "fast-deep-equal/es6"; | ||
import { sanitizeKey } from "widgets/WidgetUtils"; | ||
import { parseDerivedProperties, sanitizeKey } from "widgets/WidgetUtils"; | ||
import { | ||
PlainTextCell, | ||
URLCell, | ||
|
@@ -82,6 +81,7 @@ import * as config from "../config"; | |
import { getAnvilWidgetDOMId } from "layoutSystems/common/utils/LayoutElementPositionsObserver/utils"; | ||
import type { CanvasWidgetsReduxState } from "reducers/entityReducers/canvasWidgetsReducer"; | ||
import { klonaRegularWithTelemetry } from "utils/helpers"; | ||
import derivedPropertyFns from "./derived"; | ||
|
||
const ReactTableComponent = lazy(async () => | ||
retryPromise(async () => import("../component")), | ||
|
@@ -194,20 +194,22 @@ export class WDSTableWidget extends BaseWidget<TableWidgetProps, WidgetState> { | |
} | ||
|
||
static getDerivedPropertiesMap() { | ||
const parsedDerivedProperties = parseDerivedProperties(derivedPropertyFns); | ||
|
||
return { | ||
selectedRow: `{{(()=>{${derivedProperties.getSelectedRow}})()}}`, | ||
triggeredRow: `{{(()=>{${derivedProperties.getTriggeredRow}})()}}`, | ||
selectedRows: `{{(()=>{${derivedProperties.getSelectedRows}})()}}`, | ||
selectedRow: `{{(()=>{${parsedDerivedProperties.getSelectedRow}})()}}`, | ||
triggeredRow: `{{(()=>{${parsedDerivedProperties.getTriggeredRow}})()}}`, | ||
selectedRows: `{{(()=>{${parsedDerivedProperties.getSelectedRows}})()}}`, | ||
triggerRowSelection: "{{!!this.onRowSelected}}", | ||
processedTableData: `{{(()=>{${derivedProperties.getProcessedTableData}})()}}`, | ||
orderedTableColumns: `{{(()=>{${derivedProperties.getOrderedTableColumns}})()}}`, | ||
filteredTableData: `{{(()=>{ ${derivedProperties.getFilteredTableData}})()}}`, | ||
updatedRows: `{{(()=>{ ${derivedProperties.getUpdatedRows}})()}}`, | ||
updatedRowIndices: `{{(()=>{ ${derivedProperties.getUpdatedRowIndices}})()}}`, | ||
updatedRow: `{{(()=>{ ${derivedProperties.getUpdatedRow}})()}}`, | ||
pageOffset: `{{(()=>{${derivedProperties.getPageOffset}})()}}`, | ||
isEditableCellsValid: `{{(()=>{ ${derivedProperties.getEditableCellValidity}})()}}`, | ||
tableHeaders: `{{(()=>{${derivedProperties.getTableHeaders}})()}}`, | ||
processedTableData: `{{(()=>{${parsedDerivedProperties.getProcessedTableData}})()}}`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix: Cannot access The reference to Apply this diff to fix the issue: -static getDerivedPropertiesMap() {
+getDerivedPropertiesMap() {
...
triggerRowSelection: "{{!!this.onRowSelected}}",
...
} Consider moving
|
||
orderedTableColumns: `{{(()=>{${parsedDerivedProperties.getOrderedTableColumns}})()}}`, | ||
filteredTableData: `{{(()=>{ ${parsedDerivedProperties.getFilteredTableData}})()}}`, | ||
updatedRows: `{{(()=>{ ${parsedDerivedProperties.getUpdatedRows}})()}}`, | ||
updatedRowIndices: `{{(()=>{ ${parsedDerivedProperties.getUpdatedRowIndices}})()}}`, | ||
updatedRow: `{{(()=>{ ${parsedDerivedProperties.getUpdatedRow}})()}}`, | ||
pageOffset: `{{(()=>{${parsedDerivedProperties.getPageOffset}})()}}`, | ||
isEditableCellsValid: `{{(()=>{ ${parsedDerivedProperties.getEditableCellValidity}})()}}`, | ||
tableHeaders: `{{(()=>{${parsedDerivedProperties.getTableHeaders}})()}}`, | ||
}; | ||
} | ||
|
||
|
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -39,7 +39,8 @@ import { | |||||||||||||||||||||||
import type { InputComponentProps } from "../component"; | ||||||||||||||||||||||||
import InputComponent from "../component"; | ||||||||||||||||||||||||
import { getParsedText, isInputTypeEmailOrPassword } from "./Utilities"; | ||||||||||||||||||||||||
import derivedProperties from "./parsedDerivedProperties"; | ||||||||||||||||||||||||
import derivedPropertyFns from "./derived"; | ||||||||||||||||||||||||
import { parseDerivedProperties } from "widgets/WidgetUtils"; | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
import IconSVG from "../icon.svg"; | ||||||||||||||||||||||||
import ThumbnailSVG from "../thumbnail.svg"; | ||||||||||||||||||||||||
|
@@ -640,8 +641,10 @@ class InputWidget extends BaseInputWidget<InputWidgetProps, WidgetState> { | |||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
static getDerivedPropertiesMap(): DerivedPropertiesMap { | ||||||||||||||||||||||||
const parsedDerivedProperties = parseDerivedProperties(derivedPropertyFns); | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
return merge(super.getDerivedPropertiesMap(), { | ||||||||||||||||||||||||
isValid: `{{(() => {${derivedProperties.isValid}})()}}`, | ||||||||||||||||||||||||
isValid: `{{(() => {${parsedDerivedProperties.isValid}})()}}`, | ||||||||||||||||||||||||
}); | ||||||||||||||||||||||||
Comment on lines
+644
to
648
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Replace super with class name in static context Using static getDerivedPropertiesMap(): DerivedPropertiesMap {
const parsedDerivedProperties = parseDerivedProperties(derivedPropertyFns);
- return merge(super.getDerivedPropertiesMap(), {
+ return merge(BaseInputWidget.getDerivedPropertiesMap(), {
isValid: `{{(() => {${parsedDerivedProperties.isValid}})()}}`,
});
} 📝 Committable suggestion
Suggested change
🧰 Tools🪛 Biome[error] 646-646: Using super in a static context can be confusing. super refers to a parent class. (lint/complexity/noThisInStatic) |
||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Derived properties implementation is incomplete
The implementation is missing the
derived.ts
file that should contain theisValid
property function. This file needs to be created to complete the derived properties migration.derived.ts
in theapp/client/src/modules/ui-builder/ui/wds/WDSCurrencyInputWidget/widget/
directoryisValid
derived property function🔗 Analysis chain
Verify derived properties migration
The implementation looks good, using the new parseDerivedProperties utility. Let's verify the derived properties implementation.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 2514
Script:
Length of output: 353
Script:
Length of output: 11154
Script:
Length of output: 767