@@ -46,10 +46,11 @@ import {
4646} from "~/components/primitives/Table" ;
4747import { TextLink } from "~/components/primitives/TextLink" ;
4848import { useOrganization } from "~/hooks/useOrganizations" ;
49+ import { useHasAdminAccess } from "~/hooks/useUser" ;
4950import { redirectWithErrorMessage , redirectWithSuccessMessage } from "~/models/message.server" ;
5051import { findProjectBySlug } from "~/models/project.server" ;
5152import { type Region , RegionsPresenter } from "~/presenters/v3/RegionsPresenter.server" ;
52- import { requireUserId } from "~/services/session.server" ;
53+ import { requireUser , requireUserId } from "~/services/session.server" ;
5354import {
5455 docsPath ,
5556 EnvironmentParamSchema ,
@@ -60,14 +61,15 @@ import {
6061import { SetDefaultRegionService } from "~/v3/services/setDefaultRegion.server" ;
6162
6263export const loader = async ( { request, params } : LoaderFunctionArgs ) => {
63- const userId = await requireUserId ( request ) ;
64+ const user = await requireUser ( request ) ;
6465 const { projectParam } = ProjectParamSchema . parse ( params ) ;
6566
6667 const presenter = new RegionsPresenter ( ) ;
6768 const [ error , result ] = await tryCatch (
6869 presenter . call ( {
69- userId,
70+ userId : user . id ,
7071 projectSlug : projectParam ,
72+ isAdmin : user . admin || user . isImpersonating ,
7173 } )
7274 ) ;
7375
@@ -86,10 +88,10 @@ const FormSchema = z.object({
8688} ) ;
8789
8890export const action = async ( { request, params } : ActionFunctionArgs ) => {
89- const userId = await requireUserId ( request ) ;
91+ const user = await requireUser ( request ) ;
9092 const { organizationSlug, projectParam, envParam } = EnvironmentParamSchema . parse ( params ) ;
9193
92- const project = await findProjectBySlug ( organizationSlug , projectParam , userId ) ;
94+ const project = await findProjectBySlug ( organizationSlug , projectParam , user . id ) ;
9395
9496 const redirectPath = regionsPath (
9597 { slug : organizationSlug } ,
@@ -113,6 +115,7 @@ export const action = async ({ request, params }: ActionFunctionArgs) => {
113115 service . call ( {
114116 projectId : project . id ,
115117 regionId : parsedFormData . data . regionId ,
118+ isAdmin : user . admin || user . isImpersonating ,
116119 } )
117120 ) ;
118121
@@ -126,6 +129,7 @@ export const action = async ({ request, params }: ActionFunctionArgs) => {
126129export default function Page ( ) {
127130 const { regions, isPaying } = useTypedLoaderData < typeof loader > ( ) ;
128131 const organization = useOrganization ( ) ;
132+ const isAdmin = useHasAdminAccess ( ) ;
129133
130134 return (
131135 < PageContainer >
@@ -162,6 +166,7 @@ export default function Page() {
162166 < TableHeaderCell > Cloud Provider</ TableHeaderCell >
163167 < TableHeaderCell > Location</ TableHeaderCell >
164168 < TableHeaderCell > Static IPs</ TableHeaderCell >
169+ { isAdmin && < TableHeaderCell > Admin</ TableHeaderCell > }
165170 < TableHeaderCell
166171 alignment = "right"
167172 tooltip = {
@@ -240,6 +245,9 @@ export default function Page() {
240245 "Not available"
241246 ) }
242247 </ TableCell >
248+ { isAdmin && (
249+ < TableCell > { region . isHidden ? "Hidden" : "Visible" } </ TableCell >
250+ ) }
243251 { region . isDefault ? (
244252 < TableCell alignment = "right" >
245253 < Badge variant = "small" className = "inline-grid" >
@@ -259,8 +267,9 @@ export default function Page() {
259267 ) ;
260268 } )
261269 ) }
270+
262271 < TableRow className = "h-[3.125rem]" >
263- < TableCell colSpan = { 4 } >
272+ < TableCell colSpan = { isAdmin ? 5 : 4 } >
264273 < Paragraph variant = "extra-small" > Suggest a new region</ Paragraph >
265274 </ TableCell >
266275 < TableCellMenu
0 commit comments