mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-23 17:08:34 +00:00
fixes: importing apps With Normalized AppDefinition Schem and legacy support
This commit is contained in:
parent
53aa28da2b
commit
1094fb14bb
5 changed files with 31 additions and 9 deletions
2
.version
2
.version
|
|
@ -1 +1 @@
|
|||
2.26.2
|
||||
2.27.0
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
2.26.2
|
||||
2.27.0
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
2.26.2
|
||||
2.27.0
|
||||
|
|
|
|||
|
|
@ -235,3 +235,11 @@ export function extractMajorVersion(version) {
|
|||
export function isTooljetVersionWithNormalizedAppDefinitionSchem(version) {
|
||||
return semver.satisfies(semver.coerce(version), '>= 2.24.0');
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a given Tooljet version is compatible with the grid compatibility fix.
|
||||
*/
|
||||
|
||||
export function shouldApplyGridCompatibilityFix(version) {
|
||||
return semver.satisfies(semver.coerce(version), '>= 2.24.0 < 2.27.0');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import {
|
|||
catchDbException,
|
||||
extractMajorVersion,
|
||||
isTooljetVersionWithNormalizedAppDefinitionSchem,
|
||||
shouldApplyGridCompatibilityFix,
|
||||
} from 'src/helpers/utils.helper';
|
||||
import { AppEnvironmentService } from './app_environments.service';
|
||||
import { convertAppDefinitionFromSinglePageToMultiPage } from '../../lib/single-page-to-and-from-multipage-definition-conversion';
|
||||
|
|
@ -58,6 +59,10 @@ const DefaultDataSourceNames: DefaultDataSourceName[] = [
|
|||
];
|
||||
const DefaultDataSourceKinds: DefaultDataSourceKind[] = ['restapi', 'runjs', 'runpy', 'tooljetdb', 'workflows'];
|
||||
|
||||
function resolveGridPositionForComponent(dimension: number) {
|
||||
return Math.round((dimension * 43) / 100);
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class AppImportExportService {
|
||||
constructor(
|
||||
|
|
@ -228,6 +233,9 @@ export class AppImportExportService {
|
|||
? true
|
||||
: isTooljetVersionWithNormalizedAppDefinitionSchem(importedAppTooljetVersion);
|
||||
|
||||
const shouldUpdateForGridCompatibility: boolean =
|
||||
!cloning && shouldApplyGridCompatibilityFix(importedAppTooljetVersion);
|
||||
|
||||
const importedApp = await this.createImportedAppForUser(this.entityManager, schemaUnifiedAppParams, user);
|
||||
|
||||
await this.setupImportedAppAssociations(
|
||||
|
|
@ -236,7 +244,8 @@ export class AppImportExportService {
|
|||
schemaUnifiedAppParams,
|
||||
user,
|
||||
externalResourceMappings,
|
||||
isNormalizedAppDefinitionSchema
|
||||
isNormalizedAppDefinitionSchema,
|
||||
shouldUpdateForGridCompatibility
|
||||
);
|
||||
await this.createAdminGroupPermissions(this.entityManager, importedApp);
|
||||
|
||||
|
|
@ -314,7 +323,8 @@ export class AppImportExportService {
|
|||
appParams: any,
|
||||
user: User,
|
||||
externalResourceMappings: Record<string, unknown>,
|
||||
isNormalizedAppDefinitionSchema: boolean
|
||||
isNormalizedAppDefinitionSchema: boolean,
|
||||
shouldUpdateForGridCompatibility: boolean
|
||||
) {
|
||||
// Old version without app version
|
||||
// Handle exports prior to 0.12.0
|
||||
|
|
@ -377,7 +387,8 @@ export class AppImportExportService {
|
|||
importingDefaultAppEnvironmentId,
|
||||
importingPages,
|
||||
importingComponents,
|
||||
importingEvents
|
||||
importingEvents,
|
||||
shouldUpdateForGridCompatibility
|
||||
);
|
||||
|
||||
if (!isNormalizedAppDefinitionSchema) {
|
||||
|
|
@ -438,7 +449,7 @@ export class AppImportExportService {
|
|||
const newLayout = new Layout();
|
||||
newLayout.type = type;
|
||||
newLayout.top = layout.top;
|
||||
newLayout.left = layout.left;
|
||||
newLayout.left = resolveGridPositionForComponent(layout.left);
|
||||
newLayout.width = layout.width;
|
||||
newLayout.height = layout.height;
|
||||
newLayout.componentId = appResourceMappings.componentsMapping[componentId];
|
||||
|
|
@ -574,7 +585,8 @@ export class AppImportExportService {
|
|||
importingDefaultAppEnvironmentId: string,
|
||||
importingPages: Page[],
|
||||
importingComponents: Component[],
|
||||
importingEvents: EventHandler[]
|
||||
importingEvents: EventHandler[],
|
||||
shouldUpdateForGridCompatibility: boolean
|
||||
): Promise<AppResourceMappings> {
|
||||
appResourceMappings = { ...appResourceMappings };
|
||||
|
||||
|
|
@ -740,7 +752,9 @@ export class AppImportExportService {
|
|||
const newLayout = new Layout();
|
||||
newLayout.type = layout.type;
|
||||
newLayout.top = layout.top;
|
||||
newLayout.left = layout.left;
|
||||
newLayout.left = shouldUpdateForGridCompatibility
|
||||
? resolveGridPositionForComponent(layout.left)
|
||||
: layout.left;
|
||||
newLayout.width = layout.width;
|
||||
newLayout.height = layout.height;
|
||||
newLayout.component = savedComponent;
|
||||
|
|
|
|||
Loading…
Reference in a new issue