11'use client' ;
22
3- import { useState , type KeyboardEvent } from 'react' ;
3+ import { type KeyboardEvent , useState } from 'react' ;
44import { Button } from '@radix-ui/themes' ;
55
66const MAX_COMPONENTS_ON_PAGE = 100 ;
77
88export function GitHubDomainChecker ( ) {
99 const [ domain , setDomain ] = useState ( '' ) ;
1010 const [ result , setResult ] = useState < {
11- type : 'github' | 'enterprise' | null ;
1211 message : string ;
12+ type : 'github' | 'enterprise' | null ;
1313 } > ( { type : null , message : '' } ) ;
1414
1515 const checkDomain = ( ) => {
@@ -19,27 +19,30 @@ export function GitHubDomainChecker() {
1919 }
2020
2121 const cleanDomain = domain . trim ( ) . toLowerCase ( ) ;
22-
22+
2323 // Remove protocol if present
2424 const domainWithoutProtocol = cleanDomain . replace ( / ^ h t t p s ? : \/ \/ / , '' ) ;
25-
25+
2626 // Remove trailing slash and path
2727 const baseDomain = domainWithoutProtocol . split ( '/' ) [ 0 ] ;
2828
2929 if ( baseDomain === 'github.com' || baseDomain === 'www.github.com' ) {
3030 setResult ( {
3131 type : 'github' ,
32- message : 'You should use the regular GitHub integration. This is GitHub.com, the public GitHub service.' ,
32+ message :
33+ 'You should use the regular GitHub integration. This is GitHub.com, the public GitHub service.' ,
3334 } ) ;
3435 } else if ( baseDomain . includes ( 'github' ) ) {
3536 setResult ( {
3637 type : 'enterprise' ,
37- message : 'You should use GitHub Enterprise integration. This appears to be a GitHub Enterprise Server instance.' ,
38+ message :
39+ 'You should use GitHub Enterprise integration. This appears to be a GitHub Enterprise Server instance.' ,
3840 } ) ;
3941 } else {
4042 setResult ( {
4143 type : 'enterprise' ,
42- message : 'You should use GitHub Enterprise integration. This appears to be a custom GitHub Enterprise Server domain.' ,
44+ message :
45+ 'You should use GitHub Enterprise integration. This appears to be a custom GitHub Enterprise Server domain.' ,
4346 } ) ;
4447 }
4548 } ;
@@ -52,7 +55,7 @@ export function GitHubDomainChecker() {
5255
5356 const inputClassName =
5457 'form-input w-full rounded-md border-[1.5px] focus:ring-2 focus:ring-accent-purple/20 border-gray-200' ;
55-
58+
5659 // This is to avoid conflicts in case multiple instances of this component are used on the page
5760 const randomCounter = Math . round ( Math . random ( ) * MAX_COMPONENTS_ON_PAGE ) ;
5861
@@ -61,10 +64,11 @@ export function GitHubDomainChecker() {
6164 < div >
6265 < h3 className = "text-lg font-medium mb-2" > GitHub Domain Checker</ h3 >
6366 < p className = "text-sm text-gray-600 mb-4" >
64- Enter your GitHub domain below to determine whether you should use the GitHub or GitHub Enterprise integration.
67+ Enter your GitHub domain below to determine whether you should use the GitHub or
68+ GitHub Enterprise integration.
6569 </ p >
6670 </ div >
67-
71+
6872 < div className = "flex w-full gap-2" >
6973 < div className = "flex-1" >
7074 < label htmlFor = { `github-domain-${ randomCounter } ` } className = "sr-only" >
@@ -80,51 +84,56 @@ export function GitHubDomainChecker() {
8084 onKeyPress = { handleKeyPress }
8185 />
8286 </ div >
83- < Button
84- type = "button"
85- size = "3"
86- onClick = { checkDomain }
87- className = "rounded-md"
88- >
87+ < Button type = "button" size = "3" onClick = { checkDomain } className = "rounded-md" >
8988 Check Domain
9089 </ Button >
9190 </ div >
9291
9392 { result . message && (
94- < div className = { `p-4 rounded-md ${
95- result . type === 'github'
96- ? 'bg-green-50 border border-green-200'
97- : result . type === 'enterprise'
98- ? 'bg-blue-50 border border-blue-200'
99- : 'bg-yellow-50 border border-yellow-200'
100- } `} >
93+ < div
94+ className = { `p-4 rounded-md ${
95+ result . type === 'github'
96+ ? 'bg-green-50 border border-green-200'
97+ : result . type === 'enterprise'
98+ ? 'bg-blue-50 border border-blue-200'
99+ : 'bg-yellow-50 border border-yellow-200'
100+ } `}
101+ >
101102 < div className = "flex items-start" >
102- < div className = { `flex-shrink-0 w-5 h-5 rounded-full mr-3 mt-0.5 ${
103- result . type === 'github'
104- ? 'bg-green-500'
105- : result . type === 'enterprise'
106- ? 'bg-blue-500'
107- : 'bg-yellow-500'
108- } `} />
109- < div >
110- < p className = { `font-medium ${
103+ < div
104+ className = { `flex-shrink-0 w-5 h-5 rounded-full mr-3 mt-0.5 ${
111105 result . type === 'github'
112- ? 'text -green-800 '
106+ ? 'bg -green-500 '
113107 : result . type === 'enterprise'
114- ? 'text-blue-800'
115- : 'text-yellow-800'
116- } `} >
117- { result . type === 'github' ? 'Use GitHub Integration' :
118- result . type === 'enterprise' ? 'Use GitHub Enterprise Integration' :
119- 'Domain Check' }
120- </ p >
121- < p className = { `text-sm mt-1 ${
122- result . type === 'github'
123- ? 'text-green-700'
108+ ? 'bg-blue-500'
109+ : 'bg-yellow-500'
110+ } `}
111+ />
112+ < div >
113+ < p
114+ className = { `font-medium ${
115+ result . type === 'github'
116+ ? 'text-green-800'
117+ : result . type === 'enterprise'
118+ ? 'text-blue-800'
119+ : 'text-yellow-800'
120+ } `}
121+ >
122+ { result . type === 'github'
123+ ? 'Use GitHub Integration'
124124 : result . type === 'enterprise'
125- ? 'text-blue-700'
126- : 'text-yellow-700'
127- } `} >
125+ ? 'Use GitHub Enterprise Integration'
126+ : 'Domain Check' }
127+ </ p >
128+ < p
129+ className = { `text-sm mt-1 ${
130+ result . type === 'github'
131+ ? 'text-green-700'
132+ : result . type === 'enterprise'
133+ ? 'text-blue-700'
134+ : 'text-yellow-700'
135+ } `}
136+ >
128137 { result . message }
129138 </ p >
130139 </ div >
@@ -133,4 +142,4 @@ export function GitHubDomainChecker() {
133142 ) }
134143 </ div >
135144 ) ;
136- }
145+ }
0 commit comments