Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 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
4 changes: 3 additions & 1 deletion app/client/src/constants/WidgetConstants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ export const layoutConfigurations: LayoutConfigurations = {
FLUID: { minWidth: -1, maxWidth: -1 },
};

export const LATEST_PAGE_VERSION = 31;

export const LATEST_PAGE_VERSION = 32;


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 @@ -173,6 +173,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 @@ -812,6 +812,11 @@ const transformDSL = (currentDSL: ContainerWidgetProps<WidgetProps>) => {

if (currentDSL.version === 30) {
currentDSL = migrateIsDisabledToButtonColumn(currentDSL);
currentDSL.version = 31;
}

if (currentDSL.version === 31) {
currentDSL = migrateTableDefaultSelectedRow(currentDSL);
currentDSL.version = LATEST_PAGE_VERSION;
}
return currentDSL;
Expand Down Expand Up @@ -839,6 +844,20 @@ const addIsDisabledToButtonColumn = (
return currentDSL;
};

export const migrateTableDefaultSelectedRow = (
currentDSL: ContainerWidgetProps<WidgetProps>,
) => {
if (currentDSL.type === WidgetTypes.TABLE_WIDGET) {
if (!currentDSL.defaultSelectedRow) currentDSL.defaultSelectedRow = "0";
}
if (currentDSL.children && currentDSL.children.length) {
currentDSL.children = currentDSL.children.map((child) =>
migrateTableDefaultSelectedRow(child),
);
}
return currentDSL;
};

const migrateIsDisabledToButtonColumn = (
currentDSL: ContainerWidgetProps<WidgetProps>,
) => {
Expand Down
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