mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-23 08:58:26 +00:00
cleanup
This commit is contained in:
parent
01d73bd3f9
commit
dba41a8739
2 changed files with 29 additions and 61 deletions
|
|
@ -266,12 +266,7 @@ export class AppImportExportService {
|
|||
|
||||
const currentTooljetVersion = !cloning ? tooljetVersion : null;
|
||||
|
||||
const importedApp = await this.createImportedAppForUser(
|
||||
this.entityManager, //create new BC
|
||||
schemaUnifiedAppParams,
|
||||
user,
|
||||
isGitApp
|
||||
);
|
||||
const importedApp = await this.createImportedAppForUser(this.entityManager, schemaUnifiedAppParams, user, isGitApp);
|
||||
|
||||
const resourceMapping = await this.setupImportedAppAssociations(
|
||||
this.entityManager,
|
||||
|
|
@ -353,17 +348,11 @@ export class AppImportExportService {
|
|||
}
|
||||
}
|
||||
|
||||
async createImportedAppForUser(
|
||||
manager: EntityManager,
|
||||
appParams: any,
|
||||
user: User,
|
||||
isGitApp = false,
|
||||
organizationId?: string
|
||||
): Promise<App> {
|
||||
async createImportedAppForUser(manager: EntityManager, appParams: any, user: User, isGitApp = false): Promise<App> {
|
||||
return await catchDbException(async () => {
|
||||
const importedApp = manager.create(App, {
|
||||
name: appParams.name,
|
||||
organizationId: user?.organizationId || organizationId,
|
||||
organizationId: user?.organizationId,
|
||||
userId: user.id, //fetch super admin user id for EE
|
||||
slug: null,
|
||||
icon: appParams.icon,
|
||||
|
|
@ -426,22 +415,14 @@ export class AppImportExportService {
|
|||
user: User,
|
||||
externalResourceMappings: Record<string, unknown>,
|
||||
isNormalizedAppDefinitionSchema: boolean,
|
||||
tooljetVersion: string | null,
|
||||
organizationId?: string
|
||||
tooljetVersion: string | null
|
||||
) {
|
||||
// Old version without app version
|
||||
// Handle exports prior to 0.12.0
|
||||
// TODO: have version based conditional based on app versions
|
||||
// isLessThanExportVersion(appParams.tooljet_version, 'v0.12.0')
|
||||
if (!appParams?.appVersions) {
|
||||
await this.performLegacyAppImport(
|
||||
manager,
|
||||
importedApp,
|
||||
appParams,
|
||||
externalResourceMappings,
|
||||
user,
|
||||
organizationId
|
||||
);
|
||||
await this.performLegacyAppImport(manager, importedApp, appParams, externalResourceMappings, user);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -472,8 +453,7 @@ export class AppImportExportService {
|
|||
importedApp,
|
||||
importingAppVersions,
|
||||
appResourceMappings,
|
||||
isNormalizedAppDefinitionSchema,
|
||||
organizationId
|
||||
isNormalizedAppDefinitionSchema
|
||||
);
|
||||
appResourceMappings.appDefaultEnvironmentMapping = appDefaultEnvironmentMapping;
|
||||
appResourceMappings.appVersionMapping = appVersionMapping;
|
||||
|
|
@ -499,8 +479,7 @@ export class AppImportExportService {
|
|||
importingPages,
|
||||
importingComponents,
|
||||
importingEvents,
|
||||
tooljetVersion,
|
||||
organizationId
|
||||
tooljetVersion
|
||||
);
|
||||
|
||||
if (!isNormalizedAppDefinitionSchema) {
|
||||
|
|
@ -707,8 +686,7 @@ export class AppImportExportService {
|
|||
importingPages: Page[],
|
||||
importingComponents: Component[],
|
||||
importingEvents: EventHandler[],
|
||||
tooljetVersion: string | null,
|
||||
organizationId?: string
|
||||
tooljetVersion: string | null
|
||||
): Promise<AppResourceMappings> {
|
||||
appResourceMappings = { ...appResourceMappings };
|
||||
|
||||
|
|
@ -721,8 +699,7 @@ export class AppImportExportService {
|
|||
user,
|
||||
importingAppEnvironments,
|
||||
importingAppVersion,
|
||||
appResourceMappings,
|
||||
organizationId
|
||||
appResourceMappings
|
||||
);
|
||||
appResourceMappings.appEnvironmentMapping = appEnvironmentMapping;
|
||||
|
||||
|
|
@ -730,8 +707,7 @@ export class AppImportExportService {
|
|||
manager,
|
||||
importingAppVersion,
|
||||
user,
|
||||
appResourceMappings,
|
||||
organizationId
|
||||
appResourceMappings
|
||||
);
|
||||
appResourceMappings.defaultDataSourceIdMapping = defaultDataSourceIdMapping;
|
||||
|
||||
|
|
@ -750,8 +726,7 @@ export class AppImportExportService {
|
|||
manager,
|
||||
importingDataSource,
|
||||
appResourceMappings.appVersionMapping[importingAppVersion.id],
|
||||
user,
|
||||
organizationId
|
||||
user
|
||||
);
|
||||
|
||||
// TODO: Have version based conditional based on app versions
|
||||
|
|
@ -799,7 +774,7 @@ export class AppImportExportService {
|
|||
|
||||
const { dataQueryMapping } = await this.createDataQueriesForAppVersion(
|
||||
manager,
|
||||
user?.organizationId || organizationId,
|
||||
user?.organizationId,
|
||||
importingDataQueriesForAppVersion,
|
||||
importingDataSource,
|
||||
dataSourceForAppVersion,
|
||||
|
|
@ -1187,11 +1162,10 @@ export class AppImportExportService {
|
|||
manager: EntityManager,
|
||||
appVersion: AppVersion,
|
||||
user: User,
|
||||
appResourceMappings: AppResourceMappings,
|
||||
organizationId?: string
|
||||
appResourceMappings: AppResourceMappings
|
||||
) {
|
||||
const defaultDataSourceIds = await this.createDefaultDataSourceForVersion(
|
||||
user?.organizationId || organizationId,
|
||||
user?.organizationId,
|
||||
appResourceMappings.appVersionMapping[appVersion.id],
|
||||
DefaultDataSourceKinds,
|
||||
manager
|
||||
|
|
@ -1205,8 +1179,7 @@ export class AppImportExportService {
|
|||
manager: EntityManager,
|
||||
dataSource: DataSource,
|
||||
appVersionId: string,
|
||||
user: User,
|
||||
organizationId?: string
|
||||
user: User
|
||||
): Promise<DataSource> {
|
||||
const isDefaultDatasource = DefaultDataSourceNames.includes(dataSource.name as DefaultDataSourceName);
|
||||
const isPlugin = !!dataSource.pluginId;
|
||||
|
|
@ -1231,7 +1204,7 @@ export class AppImportExportService {
|
|||
kind: dataSource.kind,
|
||||
type: DataSourceTypes.DEFAULT,
|
||||
scope: 'global',
|
||||
organizationId: user?.organizationId || organizationId,
|
||||
organizationId: user?.organizationId,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
|
@ -1242,7 +1215,7 @@ export class AppImportExportService {
|
|||
kind: dataSource.kind,
|
||||
type: In([DataSourceTypes.DEFAULT, DataSourceTypes.SAMPLE]),
|
||||
scope: 'global',
|
||||
organizationId: user?.organizationId || organizationId,
|
||||
organizationId: user?.organizationId,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
|
@ -1260,7 +1233,7 @@ export class AppImportExportService {
|
|||
|
||||
if (plugin) {
|
||||
const newDataSource = manager.create(DataSource, {
|
||||
organizationId: user?.organizationId || organizationId,
|
||||
organizationId: user?.organizationId,
|
||||
name: dataSource.name,
|
||||
kind: dataSource.kind,
|
||||
type: DataSourceTypes.DEFAULT,
|
||||
|
|
@ -1275,7 +1248,7 @@ export class AppImportExportService {
|
|||
|
||||
const createNewGlobalDs = async (ds: DataSource): Promise<DataSource> => {
|
||||
const newDataSource = manager.create(DataSource, {
|
||||
organizationId: user?.organizationId || organizationId,
|
||||
organizationId: user?.organizationId,
|
||||
name: dataSource.name,
|
||||
kind: dataSource.kind,
|
||||
type: DataSourceTypes.DEFAULT,
|
||||
|
|
@ -1299,12 +1272,11 @@ export class AppImportExportService {
|
|||
user: User,
|
||||
appEnvironments: Record<string, any>[],
|
||||
appVersion: AppVersion,
|
||||
appResourceMappings: AppResourceMappings,
|
||||
organizationId?: string
|
||||
appResourceMappings: AppResourceMappings
|
||||
) {
|
||||
appResourceMappings = { ...appResourceMappings };
|
||||
const currentOrgEnvironments = await this.appEnvironmentUtilService.getAll(
|
||||
user?.organizationId || organizationId,
|
||||
user?.organizationId,
|
||||
appVersion.appId,
|
||||
manager
|
||||
);
|
||||
|
|
@ -1361,13 +1333,12 @@ export class AppImportExportService {
|
|||
importedApp: App,
|
||||
appVersions: AppVersion[],
|
||||
appResourceMappings: AppResourceMappings,
|
||||
isNormalizedAppDefinitionSchema: boolean,
|
||||
organizationId?: string
|
||||
isNormalizedAppDefinitionSchema: boolean
|
||||
) {
|
||||
appResourceMappings = { ...appResourceMappings };
|
||||
const { appVersionMapping, appDefaultEnvironmentMapping } = appResourceMappings;
|
||||
const organization: Organization = await manager.findOne(Organization, {
|
||||
where: { id: user?.organizationId || organizationId },
|
||||
where: { id: user?.organizationId },
|
||||
relations: ['appEnvironments'],
|
||||
});
|
||||
let currentEnvironmentId: string;
|
||||
|
|
@ -1566,8 +1537,7 @@ export class AppImportExportService {
|
|||
importedApp: App,
|
||||
appParams: any,
|
||||
externalResourceMappings: any,
|
||||
user: any,
|
||||
organizationId?: string
|
||||
user: any
|
||||
) {
|
||||
const dataSourceMapping = {};
|
||||
const dataQueryMapping = {};
|
||||
|
|
@ -1587,7 +1557,7 @@ export class AppImportExportService {
|
|||
|
||||
// Create default data sources
|
||||
const defaultDataSourceIds = await this.createDefaultDataSourceForVersion(
|
||||
user?.organizationId || organizationId,
|
||||
user?.organizationId,
|
||||
version.id,
|
||||
DefaultDataSourceKinds,
|
||||
manager
|
||||
|
|
@ -1595,7 +1565,7 @@ export class AppImportExportService {
|
|||
let envIdArray: string[] = [];
|
||||
|
||||
const organization: Organization = await manager.findOne(Organization, {
|
||||
where: { id: user?.organizationId || organizationId },
|
||||
where: { id: user?.organizationId },
|
||||
relations: ['appEnvironments'],
|
||||
});
|
||||
envIdArray = [...organization.appEnvironments.map((env) => env.id)];
|
||||
|
|
@ -1604,7 +1574,7 @@ export class AppImportExportService {
|
|||
await Promise.all(
|
||||
defaultAppEnvironments.map(async (en) => {
|
||||
const env = manager.create(AppEnvironment, {
|
||||
organizationId: user?.organizationId || organizationId,
|
||||
organizationId: user?.organizationId,
|
||||
name: en.name,
|
||||
isDefault: en.isDefault,
|
||||
priority: en.priority,
|
||||
|
|
@ -1671,7 +1641,7 @@ export class AppImportExportService {
|
|||
? this.replaceTooljetDbTableIds(
|
||||
query.options,
|
||||
externalResourceMappings['tooljet_database'],
|
||||
user?.organizationId || organizationId
|
||||
user?.organizationId
|
||||
)
|
||||
: query.options,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -14,14 +14,12 @@ import { ERROR_HANDLER } from '@modules/group-permissions/constants/error';
|
|||
import { RolesRepository } from './repository';
|
||||
import { AddUserRoleObject } from '@modules/group-permissions/types';
|
||||
import { IRolesUtilService } from './interfaces/IUtilService';
|
||||
import { LicenseUserService } from '@modules/licensing/services/user.service';
|
||||
|
||||
@Injectable()
|
||||
export class RolesUtilService implements IRolesUtilService {
|
||||
constructor(
|
||||
protected groupPermissionsRepository: GroupPermissionsRepository,
|
||||
protected roleRepository: RolesRepository,
|
||||
protected licenseUserService: LicenseUserService
|
||||
protected roleRepository: RolesRepository
|
||||
) {}
|
||||
|
||||
async changeEndUserToEditor(
|
||||
|
|
|
|||
Loading…
Reference in a new issue