ToolJet/server/migrations/1638255797809-SetLoadingStateToFalseForExistingTables.ts
Gandharv 6c90a1667b
Feature: undo/redo for canvas 🔥 (#1446)
* feat: add restore shortcut when component is deleted

* change toast messages to hot toast from toastify

* change toast messages to hot toast from toastify

* change toast messages to hot toast from toastify

* on key press match clear the pressed keys

* add react hotkeys hook and delete use-shortcuts custom hook

* change toast messages to hot toast from toastify

* add immer lib

* applyPatches from immer + add undo redo on appdefination changes

* remove notification on undo

* add can-undo + can-redo checks

* add missing can-redo to handlePatchAdd

* add component versioning on componentDefinitionChanged

* set default value of loading state to interpolated boolean false for table

* set canUndo on initial load to false

* fix last element not getting removed on undo

* Remove console log

* add migration to change loadingState for existing tables

* set loadingstate value based on the previous value

* fix: app crash on inspector opening

* add check for selectedComponentId inside components def

* update template definitions for loadingState

* fix alert for success, error, info for button notifications
2021-12-11 04:41:24 +05:30

46 lines
1.6 KiB
TypeScript

import { AppVersion } from '../src/entities/app_version.entity';
import { MigrationInterface, QueryRunner } from 'typeorm';
export class SetLoadingStateToFalseForExistingTables1638255797809 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
const entityManager = queryRunner.manager;
const queryBuilder = queryRunner.connection.createQueryBuilder();
const appVersionRepository = entityManager.getRepository(AppVersion);
const appVersions = await appVersionRepository.find();
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') {
component.component.definition.properties.loadingState = {
value: `{{${component.component.definition.properties.loadingState}}}`,
};
components[componentId] = {
...component,
component: {
...component.component,
definition: {
...component.component.definition,
},
},
};
}
}
definition['components'] = components;
version.definition = definition;
await queryBuilder.update(AppVersion).set({ definition }).where('id = :id', { id: version.id }).execute();
}
}
}
public async down(queryRunner: QueryRunner): Promise<void> {}
}