-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
84e8d21
commit 6ee884c
Showing
11 changed files
with
376 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
124 changes: 124 additions & 0 deletions
124
...ug]/(app)/(resources)/resource-providers/integrations/azure/UpdateAzureProviderDialog.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
"use client"; | ||
|
||
import type { UpdateResourceProviderAzure } from "@ctrlplane/db/schema"; | ||
import type * as SCHEMA from "@ctrlplane/db/schema"; | ||
import { useState } from "react"; | ||
import { useRouter } from "next/navigation"; | ||
|
||
import { updateResourceProviderAzure } from "@ctrlplane/db/schema"; | ||
import { Button } from "@ctrlplane/ui/button"; | ||
import { | ||
Dialog, | ||
DialogContent, | ||
DialogHeader, | ||
DialogTitle, | ||
DialogTrigger, | ||
} from "@ctrlplane/ui/dialog"; | ||
import { | ||
Form, | ||
FormControl, | ||
FormField, | ||
FormItem, | ||
FormLabel, | ||
FormMessage, | ||
useForm, | ||
} from "@ctrlplane/ui/form"; | ||
import { Input } from "@ctrlplane/ui/input"; | ||
|
||
type UpdateAzureProviderDialogProps = { | ||
workspaceId: string; | ||
resourceProvider: SCHEMA.ResourceProvider; | ||
azureConfig: SCHEMA.ResourceProviderAzure; | ||
children: React.ReactNode; | ||
onClose?: () => void; | ||
}; | ||
|
||
export const UpdateAzureProviderDialog: React.FC< | ||
UpdateAzureProviderDialogProps | ||
> = ({ workspaceId, resourceProvider, azureConfig, children, onClose }) => { | ||
const [open, setOpen] = useState(false); | ||
const form = useForm({ | ||
schema: updateResourceProviderAzure, | ||
defaultValues: { ...azureConfig, ...resourceProvider }, | ||
}); | ||
const router = useRouter(); | ||
|
||
const onSubmit = form.handleSubmit((data: UpdateResourceProviderAzure) => { | ||
setOpen(false); | ||
router.push( | ||
`/api/azure/${workspaceId}/${data.tenantId}/${data.subscriptionId}/${data.name}?resourceProviderId=${resourceProvider.id}`, | ||
); | ||
}); | ||
|
||
return ( | ||
<Dialog | ||
open={open} | ||
onOpenChange={(o) => { | ||
setOpen(o); | ||
if (!o) onClose?.(); | ||
}} | ||
> | ||
<DialogTrigger asChild>{children}</DialogTrigger> | ||
<DialogContent> | ||
<DialogHeader> | ||
<DialogTitle>Configure Azure</DialogTitle> | ||
</DialogHeader> | ||
<Form {...form}> | ||
<form onSubmit={onSubmit} className="space-y-4"> | ||
<FormField | ||
control={form.control} | ||
name="name" | ||
render={({ field }) => ( | ||
<FormItem> | ||
<FormLabel>Name</FormLabel> | ||
<FormControl> | ||
<Input {...field} /> | ||
</FormControl> | ||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
|
||
<FormField | ||
control={form.control} | ||
name="tenantId" | ||
render={({ field }) => ( | ||
<FormItem> | ||
<FormLabel>Tenant ID</FormLabel> | ||
<FormControl> | ||
<Input {...field} /> | ||
</FormControl> | ||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
|
||
<FormField | ||
control={form.control} | ||
name="subscriptionId" | ||
render={({ field }) => ( | ||
<FormItem> | ||
<FormLabel>Subscription ID</FormLabel> | ||
<FormControl> | ||
<Input {...field} /> | ||
</FormControl> | ||
</FormItem> | ||
)} | ||
/> | ||
|
||
<Button | ||
type="submit" | ||
disabled={ | ||
!form.formState.isValid || | ||
form.formState.isSubmitting || | ||
!form.formState.isDirty | ||
} | ||
> | ||
Save | ||
</Button> | ||
</form> | ||
</Form> | ||
</DialogContent> | ||
</Dialog> | ||
); | ||
}; |
65 changes: 65 additions & 0 deletions
65
...ug]/(app)/(resources)/resource-providers/integrations/azure/[resourceProviderId]/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import Link from "next/link"; | ||
import { notFound } from "next/navigation"; | ||
import { IconExternalLink } from "@tabler/icons-react"; | ||
|
||
import { cn } from "@ctrlplane/ui"; | ||
import { buttonVariants } from "@ctrlplane/ui/button"; | ||
|
||
import { api } from "~/trpc/server"; | ||
|
||
type Params = { resourceProviderId: string }; | ||
|
||
export default async function AzureProviderPage({ | ||
params, | ||
}: { | ||
params: Params; | ||
}) { | ||
const { resourceProviderId } = params; | ||
|
||
const provider = | ||
await api.resource.provider.managed.azure.byProviderId(resourceProviderId); | ||
|
||
if (provider == null) return notFound(); | ||
|
||
const portalUrl = `https://portal.azure.com/#@${provider.azure_tenant.tenantId}/resource/subscriptions/${provider.resource_provider_azure.subscriptionId}/users`; | ||
|
||
return ( | ||
<div className="mx-auto max-w-2xl space-y-6 p-4"> | ||
<div> | ||
<h1 className="text-2xl font-bold">Next steps</h1> | ||
<p className="text-sm text-muted-foreground"> | ||
To allow Ctrlplane to scan your Azure resources, you need to grant the | ||
Azure service principal the necessary permissions. | ||
</p> | ||
</div> | ||
|
||
<div className="space-y-4"> | ||
<div className="space-y-2"> | ||
<h2 className="text-lg font-medium"> | ||
Step 1: Go to Access Control (IAM) in the Azure portal | ||
</h2> | ||
<Link | ||
href={portalUrl} | ||
className={cn( | ||
buttonVariants({ variant: "outline" }), | ||
"flex w-fit items-center gap-2", | ||
)} | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
<IconExternalLink className="h-4 w-4" /> Go to IAM | ||
</Link> | ||
</div> | ||
<h2 className="text-lg font-medium"> | ||
Step 2: Click "Add role assignment" | ||
</h2> | ||
<div className="space-y-2"> | ||
<h2 className="text-lg font-medium"> | ||
Step 3: Configure the role assignment | ||
</h2> | ||
<h3></h3> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.