11import { Outlet , useRouteLoaderData } from "@remix-run/react" ;
2- import { type LoaderFunctionArgs } from "@remix-run/server-runtime" ;
32import { VERSION as coreVersion } from "@trigger.dev/core" ;
43import { type ReactNode } from "react" ;
54import { typedjson , useTypedLoaderData } from "remix-typedjson" ;
@@ -10,51 +9,15 @@ import {
109 OrganizationSettingsSideMenu ,
1110} from "~/components/navigation/OrganizationSettingsSideMenu" ;
1211import { useOrganization } from "~/hooks/useOrganizations" ;
13- import { resolveOrgIdFromSlugForUser } from "~/models/organization.server" ;
14- import { organizationHasProjectRuntimeUpdate } from "~/services/projectRuntimeUpdates.server" ;
1512import { rbac } from "~/services/rbac.server" ;
16- import { requireUserId } from "~/services/session.server" ;
1713import { ssoController } from "~/services/sso.server" ;
1814
1915const SETTINGS_ROUTE_ID = "routes/_app.orgs.$organizationSlug.settings" ;
2016
21- // The side-menu dot links to the Projects settings page, which requires `read` on
22- // `deployments`, so gate the dot on the same ability the page checks.
23- async function canReadDeployments ( {
24- request,
25- userId,
26- organizationSlug,
27- } : {
28- request : Request ;
29- userId : string ;
30- organizationSlug : string ;
31- } ) {
32- // Membership-scoped so the dot is never computed against an org the user is not in.
33- const organizationId = await resolveOrgIdFromSlugForUser ( organizationSlug , userId ) ;
34- if ( ! organizationId ) {
35- return false ;
36- }
37-
38- const auth = await rbac . authenticateAuthorizeSession (
39- request ,
40- { userId, organizationId } ,
41- { action : "read" , resource : { type : "deployments" } }
42- ) ;
43- return auth . ok ;
44- }
45-
46- export const loader = async ( { request, params } : LoaderFunctionArgs ) => {
47- const userId = await requireUserId ( request ) ;
48- const organizationSlug = params . organizationSlug ;
49-
50- const [ isUsingPlugin , isSsoUsingPlugin , hasProjectRuntimeUpdate ] = await Promise . all ( [
17+ export const loader = async ( ) => {
18+ const [ isUsingPlugin , isSsoUsingPlugin ] = await Promise . all ( [
5119 rbac . isUsingPlugin ( ) ,
5220 ssoController . isUsingPlugin ( ) ,
53- organizationSlug
54- ? canReadDeployments ( { request, userId, organizationSlug } ) . then ( ( canRead ) =>
55- canRead ? organizationHasProjectRuntimeUpdate ( { organizationSlug, userId } ) : false
56- )
57- : Promise . resolve ( false ) ,
5821 ] ) ;
5922 return typedjson ( {
6023 buildInfo : {
@@ -66,21 +29,18 @@ export const loader = async ({ request, params }: LoaderFunctionArgs) => {
6629 } satisfies BuildInfo ,
6730 isUsingPlugin,
6831 isSsoUsingPlugin,
69- hasProjectRuntimeUpdate,
7032 } ) ;
7133} ;
7234
7335function SettingsChrome ( {
7436 buildInfo,
7537 isUsingPlugin,
7638 isSsoUsingPlugin,
77- hasProjectRuntimeUpdate,
7839 children,
7940} : {
8041 buildInfo : BuildInfo ;
8142 isUsingPlugin : boolean ;
8243 isSsoUsingPlugin : boolean ;
83- hasProjectRuntimeUpdate : boolean ;
8444 children : ReactNode ;
8545} ) {
8646 const organization = useOrganization ( ) ;
@@ -93,7 +53,6 @@ function SettingsChrome({
9353 buildInfo = { buildInfo }
9454 isUsingPlugin = { isUsingPlugin }
9555 isSsoUsingPlugin = { isSsoUsingPlugin }
96- hasProjectRuntimeUpdate = { hasProjectRuntimeUpdate }
9756 />
9857 < MainBody > { children } </ MainBody >
9958 </ div >
@@ -102,15 +61,13 @@ function SettingsChrome({
10261}
10362
10463export default function Page ( ) {
105- const { buildInfo, isUsingPlugin, isSsoUsingPlugin, hasProjectRuntimeUpdate } =
106- useTypedLoaderData < typeof loader > ( ) ;
64+ const { buildInfo, isUsingPlugin, isSsoUsingPlugin } = useTypedLoaderData < typeof loader > ( ) ;
10765
10866 return (
10967 < SettingsChrome
11068 buildInfo = { buildInfo }
11169 isUsingPlugin = { isUsingPlugin }
11270 isSsoUsingPlugin = { isSsoUsingPlugin }
113- hasProjectRuntimeUpdate = { hasProjectRuntimeUpdate }
11471 >
11572 < Outlet />
11673 </ SettingsChrome >
@@ -127,7 +84,6 @@ export function ErrorBoundary() {
12784 buildInfo : BuildInfo ;
12885 isUsingPlugin : boolean ;
12986 isSsoUsingPlugin : boolean ;
130- hasProjectRuntimeUpdate : boolean ;
13187 }
13288 | undefined ;
13389
@@ -140,7 +96,6 @@ export function ErrorBoundary() {
14096 buildInfo = { data . buildInfo }
14197 isUsingPlugin = { data . isUsingPlugin }
14298 isSsoUsingPlugin = { data . isSsoUsingPlugin }
143- hasProjectRuntimeUpdate = { data . hasProjectRuntimeUpdate }
14499 >
145100 < RouteErrorDisplay />
146101 </ SettingsChrome >
0 commit comments