mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-23 08:58:26 +00:00
delete constant from all envs
This commit is contained in:
parent
2c3b085b0d
commit
7ec16143f5
2 changed files with 7 additions and 2 deletions
|
|
@ -113,7 +113,7 @@ export class OrganizationConstantController implements IOrganizationConstantCont
|
|||
async delete(@User() user, @Param('id') constantId, @Query('environmentId') environmentId) {
|
||||
const { organizationId } = user;
|
||||
|
||||
await this.organizationConstantsService.delete(constantId, organizationId, environmentId);
|
||||
await this.organizationConstantsService.delete(constantId, organizationId);
|
||||
|
||||
return { statusCode: 204 };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ export class OrganizationConstantsUtilService implements IOrganizationConstantsU
|
|||
async deleteOrgEnvironmentConstant(
|
||||
constantId: string,
|
||||
organizationId: string,
|
||||
environmentId: string
|
||||
environmentId?: string
|
||||
): Promise<DeleteResult> {
|
||||
return await dbTransactionWrap(async (manager: EntityManager) => {
|
||||
const constantToDelete = await this.organizationConstantRepository.findOneByIdAndOrganizationId(
|
||||
|
|
@ -95,6 +95,11 @@ export class OrganizationConstantsUtilService implements IOrganizationConstantsU
|
|||
throw new Error('Constant not found');
|
||||
}
|
||||
|
||||
// If no environmentId is provided, delete the constant from all environments
|
||||
if (!environmentId) {
|
||||
return this.organizationConstantRepository.deleteOneById(constantId);
|
||||
}
|
||||
|
||||
if (constantToDelete.orgEnvironmentConstantValues.length === 1) {
|
||||
return this.organizationConstantRepository.deleteOneById(constantId);
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue