Fix admin pannel server variable config tab (#21017)

## Before

<img width="1046" height="490" alt="image"
src="https://github.com/user-attachments/assets/450557de-fcf5-4b51-afdb-36c0c36e43d8"
/>


## After

<img width="1040" height="414" alt="image"
src="https://github.com/user-attachments/assets/4a5fe2ab-85d6-4431-9397-6f81ae24055d"
/>
This commit is contained in:
martmull
2026-05-29 11:55:11 +02:00
committed by GitHub
parent 3e2c50c6cf
commit c2df39405c
10 changed files with 353 additions and 136 deletions
@@ -48,20 +48,7 @@ export class ApplicationRegistrationVariableService {
order: { key: 'ASC' },
});
return variables.map((variable) => {
const { encryptedValue } = variable;
return {
...variable,
isFilled: variable.isFilled,
value:
encryptedValue !== ''
? variable.isSecret
? '•••••••••••••'
: this.encryptionService.decryptVersioned(encryptedValue)
: null,
};
});
return variables.map((variable) => this.toObfuscatedDTO(variable));
}
async createVariable(
@@ -90,58 +77,28 @@ export class ApplicationRegistrationVariableService {
input: UpdateApplicationRegistrationVariableInput,
workspaceId: string,
): Promise<ApplicationRegistrationVariableEntity> {
const { id, update } = input;
const variable = await this.variableRepository.findOne({
where: { id },
});
if (!variable) {
throw new ApplicationRegistrationException(
`Variable with id ${id} not found`,
ApplicationRegistrationExceptionCode.VARIABLE_NOT_FOUND,
);
}
const variable = await this.findVariableOrThrow(input.id);
await this.assertRegistrationOwnedByWorkspace(
variable.applicationRegistrationId,
workspaceId,
);
const updateData: Record<string, unknown> = {};
return this.applyVariableUpdate(input);
}
if (isDefined(update.value)) {
updateData.encryptedValue = this.encryptionService.encryptVersioned(
update.value,
);
}
async updateVariableGlobal(
input: UpdateApplicationRegistrationVariableInput,
): Promise<ApplicationRegistrationVariableDTO> {
await this.findVariableOrThrow(input.id);
if (isDefined(update.resetValue) && update.resetValue) {
updateData.encryptedValue = '';
}
const entity = await this.applyVariableUpdate(input);
if (isDefined(update.description)) {
updateData.description = update.description;
}
if (Object.keys(updateData).length > 0) {
await this.variableRepository.update(id, updateData);
}
return this.variableRepository.findOneOrFail({ where: { id } });
return this.toObfuscatedDTO(entity);
}
async deleteVariable(id: string, workspaceId: string): Promise<boolean> {
const variable = await this.variableRepository.findOne({
where: { id },
});
if (!variable) {
throw new ApplicationRegistrationException(
`Variable with id ${id} not found`,
ApplicationRegistrationExceptionCode.VARIABLE_NOT_FOUND,
);
}
const variable = await this.findVariableOrThrow(id);
await this.assertRegistrationOwnedByWorkspace(
variable.applicationRegistrationId,
@@ -241,6 +198,68 @@ export class ApplicationRegistrationVariableService {
return result;
}
private async findVariableOrThrow(
id: string,
): Promise<ApplicationRegistrationVariableEntity> {
const variable = await this.variableRepository.findOne({
where: { id },
});
if (!variable) {
throw new ApplicationRegistrationException(
`Variable with id ${id} not found`,
ApplicationRegistrationExceptionCode.VARIABLE_NOT_FOUND,
);
}
return variable;
}
private async applyVariableUpdate(
input: UpdateApplicationRegistrationVariableInput,
): Promise<ApplicationRegistrationVariableEntity> {
const { id, update } = input;
const updateData: Record<string, unknown> = {};
if (isDefined(update.value)) {
updateData.encryptedValue = this.encryptionService.encryptVersioned(
update.value,
);
}
if (isDefined(update.resetValue) && update.resetValue) {
updateData.encryptedValue = '';
}
if (isDefined(update.description)) {
updateData.description = update.description;
}
if (Object.keys(updateData).length > 0) {
await this.variableRepository.update(id, updateData);
}
return this.variableRepository.findOneOrFail({ where: { id } });
}
private toObfuscatedDTO(
variable: ApplicationRegistrationVariableEntity,
): ApplicationRegistrationVariableDTO {
const { encryptedValue } = variable;
return {
...variable,
isFilled: variable.isFilled,
value:
encryptedValue !== ''
? variable.isSecret
? '•••••••••••••'
: this.encryptionService.decryptVersioned(encryptedValue)
: null,
};
}
private async assertRegistrationOwnedByWorkspace(
registrationId: string,
workspaceId: string,