Skip to content

Commit

Permalink
fixes: validate instance version and update the component label prope…
Browse files Browse the repository at this point in the history
…rty (#8958)

* fixes: validate instance version and update the component label property

* version bump

* fixes: backward compaitobolity
- cases where app is being imported before appdefinitiion normalisation
- cases from current version whwere user do not want to display label

---------

Co-authored-by: stepinfwd <stepinfwd@gmail.com>
  • Loading branch information
arpitnath and stepinfwd committed Mar 1, 2024
1 parent 295ad63 commit e640b44
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.32.1
2.32.2
2 changes: 1 addition & 1 deletion frontend/.version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.32.1
2.32.2
2 changes: 1 addition & 1 deletion server/.version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.32.1
2.32.2
35 changes: 25 additions & 10 deletions server/src/services/app_import_export.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
catchDbException,
extractMajorVersion,
isTooljetVersionWithNormalizedAppDefinitionSchem,
isVersionGreaterThanOrEqual,
} from 'src/helpers/utils.helper';
import { AppEnvironmentService } from './app_environments.service';
import { convertAppDefinitionFromSinglePageToMultiPage } from '../../lib/single-page-to-and-from-multipage-definition-conversion';
Expand Down Expand Up @@ -243,7 +244,8 @@ export class AppImportExportService {
schemaUnifiedAppParams,
user,
externalResourceMappings,
isNormalizedAppDefinitionSchema
isNormalizedAppDefinitionSchema,
tooljetVersion
);
await this.createAdminGroupPermissions(this.entityManager, importedApp);

Expand Down Expand Up @@ -321,7 +323,8 @@ export class AppImportExportService {
appParams: any,
user: User,
externalResourceMappings: Record<string, unknown>,
isNormalizedAppDefinitionSchema: boolean
isNormalizedAppDefinitionSchema: boolean,
tooljetVersion: string
) {
// Old version without app version
// Handle exports prior to 0.12.0
Expand Down Expand Up @@ -384,7 +387,8 @@ export class AppImportExportService {
importingDefaultAppEnvironmentId,
importingPages,
importingComponents,
importingEvents
importingEvents,
tooljetVersion
);

if (!isNormalizedAppDefinitionSchema) {
Expand Down Expand Up @@ -413,7 +417,8 @@ export class AppImportExportService {
pageComponents,
componentEvents,
appResourceMappings.componentsMapping,
isNormalizedAppDefinitionSchema
isNormalizedAppDefinitionSchema,
tooljetVersion
);

const componentLayouts = [];
Expand Down Expand Up @@ -581,7 +586,8 @@ export class AppImportExportService {
importingDefaultAppEnvironmentId: string,
importingPages: Page[],
importingComponents: Component[],
importingEvents: EventHandler[]
importingEvents: EventHandler[],
tooljetVersion: string
): Promise<AppResourceMappings> {
appResourceMappings = { ...appResourceMappings };

Expand Down Expand Up @@ -735,7 +741,8 @@ export class AppImportExportService {
const { properties, styles, general, validation, generalStyles } = migrateProperties(
component.type as NewRevampedComponent,
component,
NewRevampedComponents
NewRevampedComponents,
tooljetVersion
);
newComponent.id = newComponentIdsMap[component.id];
newComponent.name = component.name;
Expand Down Expand Up @@ -1685,8 +1692,11 @@ function convertSinglePageSchemaToMultiPageSchema(appParams: any) {
function migrateProperties(
componentType: NewRevampedComponent,
component: Component,
componentTypes: NewRevampedComponent[]
componentTypes: NewRevampedComponent[],
tooljetVersion: string
) {
const shouldHandleBackwardCompatibility = isVersionGreaterThanOrEqual(tooljetVersion, '2.29.0') ? false : true;

const properties = { ...component.properties };
const styles = { ...component.styles };
const general = { ...component.general };
Expand Down Expand Up @@ -1714,7 +1724,10 @@ function migrateProperties(
delete generalStyles?.boxShadow;
}

if (componentType === 'TextInput' || componentType === 'PasswordInput' || componentType === 'NumberInput') {
if (
shouldHandleBackwardCompatibility &&
(componentType === 'TextInput' || componentType === 'PasswordInput' || componentType === 'NumberInput')
) {
properties.label = '';
}

Expand All @@ -1737,7 +1750,8 @@ function transformComponentData(
data: object,
componentEvents: any[],
componentsMapping: Record<string, string>,
isNormalizedAppDefinitionSchema = true
isNormalizedAppDefinitionSchema = true,
tooljetVersion: string
): Component[] {
const transformedComponents: Component[] = [];

Expand Down Expand Up @@ -1786,7 +1800,8 @@ function transformComponentData(
const { properties, styles, general, validation, generalStyles } = migrateProperties(
componentData.component,
componentData.definition,
NewRevampedComponents
NewRevampedComponents,
tooljetVersion
);
transformedComponent.id = uuid();
transformedComponent.name = componentData.name;
Expand Down

0 comments on commit e640b44

Please sign in to comment.