ToolJet/server/migrations/1653472569828-addedInstructionTextPropInFilePickerWidget.ts
Manish Kushare 29db040eea
added instruction text property in file picker widget to add custom instructions (#2731)
* added instruction text property  in file pciker to make user unable to provide custom instructions

* Added default instruction text

* made the changes to make sure existing app do not crashes because of instructionText prop

* Solve issue -  existing file pickers wont display anything if we don't default to the default instruction text

* changes in operation.json file

* migration script for adding instructionText prop

* removed unwanted operations.json file

Co-authored-by: Kavin Venkatachalam <kavin.saratha@gmail.com>
2022-06-16 17:53:31 +05:30

42 lines
1.4 KiB
TypeScript

import { MigrationInterface, QueryRunner } from 'typeorm';
import { AppVersion } from '../src/entities/app_version.entity';
export class addedInstructionTextPropInFilePickerWidget1653472569828 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 === 'FilePicker') {
component.component.definition.properties.instructionText = {
value: 'Drag and Drop some files here, or click to select files',
};
components[componentId] = {
...component,
component: {
...component.component,
definition: {
...component.component.definition,
},
},
};
}
}
definition['components'] = components;
version.definition = definition;
await entityManager.update(AppVersion, { id: version.id }, { definition });
}
}
}
public async down(queryRunner: QueryRunner): Promise<void> {}
}