Skip to content

Commit e079b96

Browse files
committed
Change task icon for task filters
Flagged the ui for Download Logs Solved issue with infinite fetching when the table is scrolled to the end Fixed logs query order by
1 parent 04eacb5 commit e079b96

File tree

1 file changed

+53
-0
lines changed
  • apps/webapp/app/routes/resources.orgs.$organizationSlug.can-view-logs-page

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { type LoaderFunctionArgs } from "@remix-run/server-runtime";
2+
import { typedjson } from "remix-typedjson";
3+
import { requireUser } from "~/services/session.server";
4+
import { prisma } from "~/db.server";
5+
import { FEATURE_FLAG, validateFeatureFlagValue } from "~/v3/featureFlags.server";
6+
import { OrganizationParamsSchema } from "~/utils/pathBuilder";
7+
8+
async function hasLogsPageAccess(
9+
userId: string,
10+
isAdmin: boolean,
11+
isImpersonating: boolean,
12+
organizationSlug: string
13+
): Promise<boolean> {
14+
if (isAdmin || isImpersonating) {
15+
return true;
16+
}
17+
18+
const organization = await prisma.organization.findFirst({
19+
where: {
20+
slug: organizationSlug,
21+
members: { some: { userId } },
22+
},
23+
select: {
24+
featureFlags: true,
25+
},
26+
});
27+
28+
if (!organization?.featureFlags) {
29+
return false;
30+
}
31+
32+
const flags = organization.featureFlags as Record<string, unknown>;
33+
const hasLogsPageAccessResult = validateFeatureFlagValue(
34+
FEATURE_FLAG.hasLogsPageAccess,
35+
flags.hasLogsPageAccess
36+
);
37+
38+
return hasLogsPageAccessResult.success && hasLogsPageAccessResult.data === true;
39+
}
40+
41+
export const loader = async ({ request, params }: LoaderFunctionArgs) => {
42+
const user = await requireUser(request);
43+
const { organizationSlug } = OrganizationParamsSchema.parse(params);
44+
45+
const canViewLogsPage = user.admin || user.isImpersonating || await hasLogsPageAccess(
46+
user.id,
47+
user.admin,
48+
user.isImpersonating,
49+
organizationSlug
50+
);
51+
52+
return typedjson({ canViewLogsPage });
53+
};

0 commit comments

Comments
 (0)