Skip to content

Commit

Permalink
refactor derived properties
Browse files Browse the repository at this point in the history
  • Loading branch information
jsartisan committed Nov 14, 2024
1 parent 8a45e5a commit f088f14
Show file tree
Hide file tree
Showing 28 changed files with 148 additions and 711 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import {
PaginationDirection,
TABLE_COLUMN_ORDER_KEY,
} from "../constants";
import derivedProperties from "./parseDerivedProperties";
import {
deleteLocalTableColumnOrderByWidgetId,
generateLocalNewColumnOrderFromStickyValue,
Expand All @@ -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,
Expand All @@ -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")),
Expand Down Expand Up @@ -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}})()}}`,
orderedTableColumns: `{{(()=>{${parsedDerivedProperties.getOrderedTableColumns}})()}}`,
filteredTableData: `{{(()=>{ ${parsedDerivedProperties.getFilteredTableData}})()}}`,
updatedRows: `{{(()=>{ ${parsedDerivedProperties.getUpdatedRows}})()}}`,
updatedRowIndices: `{{(()=>{ ${parsedDerivedProperties.getUpdatedRowIndices}})()}}`,
updatedRow: `{{(()=>{ ${parsedDerivedProperties.getUpdatedRow}})()}}`,
pageOffset: `{{(()=>{${parsedDerivedProperties.getPageOffset}})()}}`,
isEditableCellsValid: `{{(()=>{ ${parsedDerivedProperties.getEditableCellValidity}})()}}`,
tableHeaders: `{{(()=>{${parsedDerivedProperties.getTableHeaders}})()}}`,
};
}

Expand Down

This file was deleted.

This file was deleted.

7 changes: 5 additions & 2 deletions app/client/src/widgets/DatePickerWidget2/widget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import {
import type { DatePickerType } from "../constants";
import { TimePrecision } from "../constants";
import { DateFormatOptions } from "./constants";
import derivedProperties from "./parseDerivedProperties";
import derivedPropertyFns from "./derived";
import { parseDerivedProperties } from "widgets/WidgetUtils";
import { isAutoLayout } from "layoutSystems/autolayout/utils/flexWidgetUtils";
import type {
AnvilConfig,
Expand Down Expand Up @@ -632,8 +633,10 @@ class DatePickerWidget extends BaseWidget<DatePickerWidget2Props, WidgetState> {
}

static getDerivedPropertiesMap(): DerivedPropertiesMap {
const parsedDerivedProperties = parseDerivedProperties(derivedPropertyFns);

return {
isValid: `{{(()=>{${derivedProperties.isValidDate}})()}}`,
isValid: `{{(()=>{${parsedDerivedProperties.isValidDate}})()}}`,
selectedDate: `{{ this.value ? moment(this.value).toISOString() : "" }}`,
formattedDate: `{{ this.value ? moment(this.value).format(this.dateFormat) : "" }}`,
};
Expand Down

This file was deleted.

This file was deleted.

13 changes: 8 additions & 5 deletions app/client/src/widgets/ListWidget/widget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ import ListPagination, {
ServerSideListPagination,
} from "../component/ListPagination";
import IconSVG from "../icon.svg";
import derivedProperties from "./parseDerivedProperties";
import derivedPropertyFns from "./derived";
import { parseDerivedProperties } from "widgets/WidgetUtils";
import {
PropertyPaneContentConfig,
PropertyPaneStyleConfig,
Expand Down Expand Up @@ -606,11 +607,13 @@ class ListWidget extends BaseWidget<ListWidgetProps<WidgetProps>, WidgetState> {
}

static getDerivedPropertiesMap() {
const parsedDerivedProperties = parseDerivedProperties(derivedPropertyFns);

return {
pageSize: `{{(()=>{${derivedProperties.getPageSize}})()}}`,
selectedItem: `{{(()=>{${derivedProperties.getSelectedItem}})()}}`,
items: `{{(() => {${derivedProperties.getItems}})()}}`,
childAutoComplete: `{{(() => {${derivedProperties.getChildAutoComplete}})()}}`,
pageSize: `{{(()=>{${parsedDerivedProperties.getPageSize}})()}}`,
selectedItem: `{{(()=>{${parsedDerivedProperties.getSelectedItem}})()}}`,
items: `{{(() => {${parsedDerivedProperties.getItems}})()}}`,
childAutoComplete: `{{(() => {${parsedDerivedProperties.getChildAutoComplete}})()}}`,
};
}

Expand Down
40 changes: 0 additions & 40 deletions app/client/src/widgets/ListWidget/widget/parseDerivedProperties.ts

This file was deleted.

Loading

0 comments on commit f088f14

Please sign in to comment.