ToolJet/server/data-migrations/1661331234770-RestructureTableColumnSizesAndActionsToHaveAValueKeyThatPointsToItsContents.ts
Sherfin Shamsudeen b5507b4ac5
Refactor table component (#3933)
* Updated the table UI

* made the search bar in sync with current applied theme in the application

* updated the UI of the table widget

* adjust x axis in the footer

* made the search text vertically center

* Load text color using new api in Table

* Load action buttons data using new api in table

* Revert usage of new api for table actions

* Use new api to load most properties and styles

* Move logic for loading styles and propeties to another file

* Table: Move loading of actions to separate file

* Move functions to expose data to codehinter to Box.jsx

* Table: Get loadingState from new api

* Table: Use reducer for storing table column properties

* Table: minor refactoring on reducer

* Table: Replace the use of internal state variable componentState

* Abstract out Filter as a separate component

* Move table column definitions to a separate file

* Move action column definition to a separate file

* Move IndeterminateCheckbox to a separate file

* Completely remove any requirement of loading from definition inside loadPropertiesAndStyles

* Reduce the use of reducer dispatch calls in Table.jsx

* Remove the usage of __TjDoNotResolve__

* Load actions without new API

* Update migration to make columnSizes follow default format

* Fix migration to restructure table column sizes data

* Do not update columnSizes property if incoming value is empty

* Remove unnecessary code

* Remove unnecessary linting

* Remove unnecessary reducer action

* Remove unnecessary code

* Merge table changeSet data into table details reducer instead of filter reducer

* Make compact and spacious cell sizing work for table

* Remove custom handling of onRowClicked for Table

* Fix issues with table visibility, border radius and disabled state

* Resolve the issue with invalid date crashing the table

* fixes:widget crash is only for those tables which do not have any actions associated with it yet. (#4078)

* Remove unnecessary code

Co-authored-by: Manish Kushare <manish.altcampus@gmail.com>
Co-authored-by: Arpit <arpitnath42@gmail.com>
2022-09-21 16:23:02 +05:30

46 lines
1.5 KiB
TypeScript

import { MigrationInterface, QueryRunner } from 'typeorm';
import { AppVersion } from '../src/entities/app_version.entity';
export class RestructureTableColumnSizesAndActionsToHaveAValueKeyThatPointsToItsContents1661331234770
implements MigrationInterface
{
public async up(queryRunner: QueryRunner): Promise<void> {
const entityManager = queryRunner.manager;
const appVersions = await entityManager.find(AppVersion);
for (const version of appVersions) {
const definition = version['definition'];
if (definition) {
const components = definition['components'];
for (const componentId of Object.keys(components)) {
const component = components[componentId];
if (component.component.component === 'Table') {
const columnSizes = { value: component.component.definition.properties.columnSizes };
components[componentId] = {
...component,
component: {
...component.component,
definition: {
...component.component.definition,
properties: {
...component.component.definition.properties,
columnSizes,
},
},
},
};
}
}
definition['components'] = components;
version.definition = definition;
await entityManager.update(AppVersion, { id: version.id }, { definition });
}
}
}
public async down(queryRunner: QueryRunner): Promise<void> {}
}