feat: workflow agent node permissions tab (#16092)

This commit is contained in:
Abdul Rahman
2025-11-28 02:57:33 +05:30
committed by GitHub
parent 41a07006ef
commit a343bc1aee
32 changed files with 2191 additions and 420 deletions
@@ -1,6 +1,7 @@
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { isDefined } from 'twenty-shared/utils';
import { In, IsNull, Not, Repository } from 'typeorm';
import {
@@ -174,4 +175,39 @@ export class AiAgentRoleService {
roleToAssignIsSameAsCurrentRole: Boolean(existingRoleTarget),
};
}
public async deleteAgentOnlyRoleIfUnused({
roleId,
roleTargetId,
workspaceId,
}: {
roleId: string;
roleTargetId: string;
workspaceId: string;
}): Promise<void> {
const role = await this.roleRepository.findOne({
where: { id: roleId, workspaceId },
});
if (
!isDefined(role) ||
!role.canBeAssignedToAgents ||
role.canBeAssignedToUsers ||
role.canBeAssignedToApiKeys
) {
return;
}
const remainingAssignments = await this.roleTargetsRepository.count({
where: {
roleId,
workspaceId,
id: Not(roleTargetId),
},
});
if (remainingAssignments === 0) {
await this.roleRepository.delete({ id: roleId, workspaceId });
}
}
}