-
Notifications
You must be signed in to change notification settings - Fork 4.5k
chore: Refactor derived properties #37390
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
Changes from all 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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -15,7 +15,8 @@ import { WDSBaseInputWidget } from "modules/ui-builder/ui/wds/WDSBaseInputWidget | |||||
| import { AsYouType, parseIncompletePhoneNumber } from "libphonenumber-js"; | ||||||
| import { EventType } from "constants/AppsmithActionConstants/ActionConstants"; | ||||||
| import type { KeyDownEvent } from "modules/ui-builder/ui/wds/WDSBaseInputWidget/component/types"; | ||||||
| import derivedProperties from "modules/ui-builder/ui/wds/WDSCurrencyInputWidget/widget/parsedDerivedProperties"; | ||||||
| import derivedPropertyFns from "modules/ui-builder/ui/wds/WDSCurrencyInputWidget/widget/derived"; | ||||||
|
Contributor
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 incorrect import path for derivedPropertyFns The derivedPropertyFns import appears to be from WDSCurrencyInputWidget instead of the current widget's path. Apply this fix: -import derivedPropertyFns from "modules/ui-builder/ui/wds/WDSCurrencyInputWidget/widget/derived";
+import derivedPropertyFns from "./derived";📝 Committable suggestion
Suggested change
|
||||||
| import { parseDerivedProperties } from "widgets/WidgetUtils"; | ||||||
|
|
||||||
| import * as config from "../config"; | ||||||
| import { PhoneInputComponent } from "../component"; | ||||||
|
|
@@ -107,8 +108,10 @@ class WDSPhoneInputWidget extends WDSBaseInputWidget< | |||||
| } | ||||||
|
|
||||||
| static getDerivedPropertiesMap(): DerivedPropertiesMap { | ||||||
| const parsedDerivedProperties = parseDerivedProperties(derivedPropertyFns); | ||||||
|
|
||||||
| return { | ||||||
| isValid: `{{(() => {${derivedProperties.isValid}})()}}`, | ||||||
| isValid: `{{(() => {${parsedDerivedProperties.isValid}})()}}`, | ||||||
|
Comment on lines
+111
to
+114
Contributor
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. 💡 Codebase verification Potential issue with derived properties import The widget is importing derived properties from WDSCurrencyInputWidget instead of having its own implementation: import derivedPropertyFns from "modules/ui-builder/ui/wds/WDSCurrencyInputWidget/widget/derived";This appears to be incorrect as phone input validation would differ from currency input validation. 🔗 Analysis chainVerify complete migration of derived properties Let's ensure no derived properties were missed during the migration. 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Search for any remaining old derived properties implementation
rg -l "getDerivedPropertiesMap.*derivedProperties" "app/client/src/modules/ui-builder/ui/wds"
# Search for consistency in new implementation
rg -l "getDerivedPropertiesMap.*parseDerivedProperties" "app/client/src/modules/ui-builder/ui/wds"
Length of output: 192 Script: #!/bin/bash
# Search for derived properties in the WDSPhoneInputWidget directory
rg -A 5 "derivedProperties|parseDerivedProperties" "app/client/src/modules/ui-builder/ui/wds/WDSPhoneInputWidget"
# Search for getDerivedPropertiesMap implementation
ast-grep --pattern 'getDerivedPropertiesMap() {
$$$
}'
Length of output: 1550 Script: #!/bin/bash
# Search for all derived properties in the widget
ast-grep --pattern 'const derivedPropertyFns = {
$$$
}'
# Check for any other derived properties related functions
rg -A 3 "getDerivedProperties|derivedPropertyFns" "app/client/src/modules/ui-builder/ui/wds/WDSPhoneInputWidget"
Length of output: 1297 |
||||||
| }; | ||||||
| } | ||||||
|
|
||||||
|
|
||||||
| 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}})()}}`, | ||
|
Contributor
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.
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.tsfile that should contain theisValidproperty function. This file needs to be created to complete the derived properties migration.derived.tsin theapp/client/src/modules/ui-builder/ui/wds/WDSCurrencyInputWidget/widget/directoryisValidderived 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