Fix create app failure issue because TJDB is disabled (#9082)

Co-authored-by: Akshay <akshaysasidharan93@gmail.com>
This commit is contained in:
blank0537 2024-06-11 20:58:43 +05:30 committed by GitHub
parent c3d9b29b68
commit 91169cf6a7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 2 deletions

View file

@ -337,9 +337,20 @@ const ToolJetDbOperations = ({ optionchanged, options, darkMode, isHorizontalLay
]
);
const triggerTooljetDBStatus = (key) => {
if (window.public_config?.ENABLE_TOOLJET_DB == 'false') {
toast('Tooljet database is not connected.', {
icon: '⚠️',
});
} else if (key === 'addTJDBTable') {
navigate(getPrivateRoute('database'));
}
};
const fetchTables = async () => {
const { error, data } = await tooljetDatabaseService.findAll(organizationId);
triggerTooljetDBStatus();
if (error) {
toast.error(error?.message ?? 'Failed to fetch tables');
return;
@ -495,7 +506,7 @@ const ToolJetDbOperations = ({ optionchanged, options, darkMode, isHorizontalLay
onChange={(value) => {
value?.value && handleTableNameSelect(value?.value);
}}
onAdd={() => navigate(getPrivateRoute('database'))}
onAdd={() => triggerTooljetDBStatus('addTJDBTable')}
addBtnLabel={'Add new table'}
value={generateListForDropdown(tables).find((val) => val?.value === selectedTableId)}
/>

View file

@ -53,8 +53,9 @@ export class ImportExportResourcesService {
let tableNameMapping = {};
const imports = { app: [], tooljet_database: [] };
const importingVersion = importResourcesDto.tooljet_version;
const isTJDBEnabled = process.env.ENABLE_TOOLJET_DB === 'true';
if (importResourcesDto.tooljet_database) {
if (isTJDBEnabled && importResourcesDto.tooljet_database) {
const res = await this.tooljetDbImportExportService.bulkImport(importResourcesDto, importingVersion, cloning);
tableNameMapping = res.tableNameMapping;
imports.tooljet_database = res.tooljet_database;