Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/client/src/constants/WidgetConstants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export const layoutConfigurations: LayoutConfigurations = {
FLUID: { minWidth: -1, maxWidth: -1 },
};

export const LATEST_PAGE_VERSION = 30;
export const LATEST_PAGE_VERSION = 31;

export const GridDefaults = {
DEFAULT_CELL_SIZE: 1,
Expand Down
1 change: 1 addition & 0 deletions app/client/src/mockResponses/WidgetConfigResponse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ const WidgetConfigResponse: WidgetConfigReducerState = {
TABLE_WIDGET: {
rows: 7 * GRID_DENSITY_MIGRATION_V1,
columns: 9 * GRID_DENSITY_MIGRATION_V1,
defaultSelectedRow: "0",
label: "Data",
widgetName: "Table",
searchKey: "",
Expand Down
19 changes: 19 additions & 0 deletions app/client/src/utils/WidgetPropsUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -806,12 +806,31 @@ const transformDSL = (currentDSL: ContainerWidgetProps<WidgetProps>) => {

if (currentDSL.version === 29) {
currentDSL = migrateToNewMultiSelect(currentDSL);
currentDSL.version = 30;
}

if (currentDSL.version === 30) {
currentDSL = migrateTableDefaultSelectedRow(currentDSL);
currentDSL.version = LATEST_PAGE_VERSION;
}

return currentDSL;
};

export const migrateTableDefaultSelectedRow = (
currentDSL: ContainerWidgetProps<WidgetProps>,
) => {
if (currentDSL.type === WidgetTypes.TABLE_WIDGET) {
if (!currentDSL.defaultSelectedRow) currentDSL.defaultSelectedRow = 0;

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.

can u change the zero to a string and check if the migration works?

}
if (currentDSL.children && currentDSL.children.length) {
currentDSL.children = currentDSL.children.map((child) =>
migrateTableDefaultSelectedRow(child),
);
}
return currentDSL;
};

export const migrateToNewMultiSelect = (
currentDSL: ContainerWidgetProps<WidgetProps>,
) => {
Expand Down
2 changes: 1 addition & 1 deletion app/client/src/widgets/TableWidget/TableWidgetConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface TableWidgetProps extends WidgetProps, WithMeta, TableStyles {
label: string;
searchText: string;
defaultSearchText: string;
defaultSelectedRow?: number | number[];
defaultSelectedRow?: number | number[] | string;
tableData: Array<Record<string, unknown>>;
onPageChange?: string;
pageSize: number;
Expand Down