mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-15 15:41:27 +00:00
refactor: move overview resource env determination logic to the client side to preserve ordering of resources
This commit is contained in:
@@ -36,14 +36,21 @@ export const dynamicSecretDALFactory = (db: TDbClient) => {
|
||||
.whereIn("folderId", folderIds)
|
||||
.where((bd) => {
|
||||
if (search) {
|
||||
void bd.whereILike("name", `%${search}%`);
|
||||
void bd.whereILike(`${TableName.DynamicSecret}.name`, `%${search}%`);
|
||||
}
|
||||
})
|
||||
.leftJoin(TableName.SecretFolder, `${TableName.SecretFolder}.id`, `${TableName.DynamicSecret}.folderId`)
|
||||
.leftJoin(TableName.Environment, `${TableName.SecretFolder}.envId`, `${TableName.Environment}.id`)
|
||||
.select(
|
||||
selectAllTableCols(TableName.DynamicSecret),
|
||||
db.raw(`DENSE_RANK() OVER (ORDER BY "name" ${orderDirection ?? OrderByDirection.ASC}) as rank`)
|
||||
db.ref("slug").withSchema(TableName.Environment).as("environment"),
|
||||
db.raw(
|
||||
`DENSE_RANK() OVER (ORDER BY ${TableName.DynamicSecret}."name" ${
|
||||
orderDirection ?? OrderByDirection.ASC
|
||||
}) as rank`
|
||||
)
|
||||
)
|
||||
.orderBy(orderBy, orderDirection);
|
||||
.orderBy(`${TableName.DynamicSecret}.${orderBy}`, orderDirection);
|
||||
|
||||
if (limit) {
|
||||
const rankOffset = offset + 1;
|
||||
|
||||
@@ -486,15 +486,7 @@ export const dynamicSecretServiceFactory = ({
|
||||
...params
|
||||
});
|
||||
|
||||
// map dynamic secrets to their respective env
|
||||
const folderEnvMap: Map<string, string> = new Map(folders.map((folder) => [folder.id, folder.environment.slug]));
|
||||
const data: { [key: string]: Array<(typeof dynamicSecretCfg)[number]> } = {};
|
||||
dynamicSecretCfg.forEach((secret) => {
|
||||
const slug = folderEnvMap.get(secret.folderId);
|
||||
data[slug!] = [...(data[slug!] ?? []), secret];
|
||||
});
|
||||
|
||||
return data;
|
||||
return dynamicSecretCfg;
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user