mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
fix: correct secret approval query filters column references, correct count query and handle pagination reset on frontend
This commit is contained in:
@@ -670,6 +670,7 @@ export const secretApprovalRequestDALFactory = (db: TDbClient) => {
|
|||||||
.select(
|
.select(
|
||||||
db.ref("projectId").withSchema(TableName.Environment),
|
db.ref("projectId").withSchema(TableName.Environment),
|
||||||
db.ref("slug").withSchema(TableName.Environment).as("environment"),
|
db.ref("slug").withSchema(TableName.Environment).as("environment"),
|
||||||
|
db.ref("name").withSchema(TableName.Environment).as("environmentName"),
|
||||||
db.ref("id").withSchema(TableName.SecretApprovalRequestReviewer).as("reviewerId"),
|
db.ref("id").withSchema(TableName.SecretApprovalRequestReviewer).as("reviewerId"),
|
||||||
db.ref("reviewerUserId").withSchema(TableName.SecretApprovalRequestReviewer),
|
db.ref("reviewerUserId").withSchema(TableName.SecretApprovalRequestReviewer),
|
||||||
db.ref("status").withSchema(TableName.SecretApprovalRequestReviewer).as("reviewerStatus"),
|
db.ref("status").withSchema(TableName.SecretApprovalRequestReviewer).as("reviewerStatus"),
|
||||||
@@ -699,30 +700,30 @@ export const secretApprovalRequestDALFactory = (db: TDbClient) => {
|
|||||||
)
|
)
|
||||||
.as("inner");
|
.as("inner");
|
||||||
|
|
||||||
const countQuery = (await (tx || db)
|
|
||||||
.select(db.raw("count(*) OVER() as total_count"))
|
|
||||||
.from(innerQuery.clone().distinctOn(`${TableName.SecretApprovalRequest}.id`))) as Array<{
|
|
||||||
total_count: number;
|
|
||||||
}>;
|
|
||||||
|
|
||||||
const query = (tx || db).select("*").from(innerQuery).orderBy("createdAt", "desc") as typeof innerQuery;
|
const query = (tx || db).select("*").from(innerQuery).orderBy("createdAt", "desc") as typeof innerQuery;
|
||||||
|
|
||||||
if (search) {
|
if (search) {
|
||||||
void query.where((qb) => {
|
void query.where((qb) => {
|
||||||
void qb
|
void qb
|
||||||
.whereRaw(`CONCAT_WS(' ', ??, ??) ilike ?`, [
|
.whereRaw(`CONCAT_WS(' ', ??, ??) ilike ?`, [
|
||||||
db.ref("firstName").withSchema("committerUser"),
|
db.ref("committerUserFirstName"),
|
||||||
db.ref("lastName").withSchema("committerUser"),
|
db.ref("committerUserLastName"),
|
||||||
`%${search}%`
|
`%${search}%`
|
||||||
])
|
])
|
||||||
.orWhereRaw(`?? ilike ?`, [db.ref("username").withSchema("committerUser"), `%${search}%`])
|
.orWhereRaw(`?? ilike ?`, [db.ref("committerUserUsername"), `%${search}%`])
|
||||||
.orWhereRaw(`?? ilike ?`, [db.ref("email").withSchema("committerUser"), `%${search}%`])
|
.orWhereRaw(`?? ilike ?`, [db.ref("committerUserEmail"), `%${search}%`])
|
||||||
.orWhereILike(`${TableName.Environment}.name`, `%${search}%`)
|
.orWhereILike(`environmentName`, `%${search}%`)
|
||||||
.orWhereILike(`${TableName.Environment}.slug`, `%${search}%`)
|
.orWhereILike(`environment`, `%${search}%`)
|
||||||
.orWhereILike(`${TableName.SecretApprovalPolicy}.secretPath`, `%${search}%`);
|
.orWhereILike(`policySecretPath`, `%${search}%`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const countQuery = (await (tx || db)
|
||||||
|
.select(db.raw("count(*) OVER() as total_count"))
|
||||||
|
.from(query.clone().as("outer"))) as Array<{
|
||||||
|
total_count: number;
|
||||||
|
}>;
|
||||||
|
|
||||||
const rankOffset = offset + 1;
|
const rankOffset = offset + 1;
|
||||||
const docs = await (tx || db)
|
const docs = await (tx || db)
|
||||||
.with("w", query)
|
.with("w", query)
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ import {
|
|||||||
PreferenceKey,
|
PreferenceKey,
|
||||||
setUserTablePreference
|
setUserTablePreference
|
||||||
} from "@app/helpers/userTablePreferences";
|
} from "@app/helpers/userTablePreferences";
|
||||||
import { usePagination } from "@app/hooks";
|
import { usePagination, useResetPageHelper } from "@app/hooks";
|
||||||
import {
|
import {
|
||||||
useGetSecretApprovalRequestCount,
|
useGetSecretApprovalRequestCount,
|
||||||
useGetSecretApprovalRequests,
|
useGetSecretApprovalRequests,
|
||||||
@@ -99,6 +99,12 @@ export const SecretApprovalRequest = () => {
|
|||||||
const totalApprovalCount = data?.totalCount ?? 0;
|
const totalApprovalCount = data?.totalCount ?? 0;
|
||||||
const secretApprovalRequests = data?.approvals ?? [];
|
const secretApprovalRequests = data?.approvals ?? [];
|
||||||
|
|
||||||
|
useResetPageHelper({
|
||||||
|
totalCount: totalApprovalCount,
|
||||||
|
offset,
|
||||||
|
setPage
|
||||||
|
});
|
||||||
|
|
||||||
const { data: secretApprovalRequestCount, isSuccess: isSecretApprovalReqCountSuccess } =
|
const { data: secretApprovalRequestCount, isSuccess: isSecretApprovalReqCountSuccess } =
|
||||||
useGetSecretApprovalRequestCount({ projectId });
|
useGetSecretApprovalRequestCount({ projectId });
|
||||||
const { user: userSession } = useUser();
|
const { user: userSession } = useUser();
|
||||||
|
|||||||
Reference in New Issue
Block a user